Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
tetra-tower
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Oenos
tetra-tower
Commits
5b77dbee
Commit
5b77dbee
authored
Feb 14, 2019
by
18류지석
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InventoryManager Singleton으로 개편. 애드온 아이템효과를 적용할 준비가 다 되었다.
parent
f10c39a4
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
135 additions
and
22 deletions
+135
-22
AttackProperty.cs
Assets/Scripts/Characters/AttackProperty.cs
+18
-5
Enemy.cs
Assets/Scripts/Characters/Enemy/Enemy.cs
+1
-1
PlayerAttack.cs
Assets/Scripts/Characters/PlayerAttack.cs
+2
-1
PlayerAttackInfo.cs
Assets/Scripts/Characters/PlayerAttackInfo.cs
+9
-6
Enumerators.cs
Assets/Scripts/Enumerators.cs
+2
-1
Addon.cs
Assets/Scripts/Item/Addon.cs
+30
-0
AddonDrag.cs
Assets/Scripts/Item/AddonDrag.cs
+1
-1
DroppedItem.cs
Assets/Scripts/Item/DroppedItem.cs
+1
-1
InventoryManager.cs
Assets/Scripts/Item/InventoryManager.cs
+1
-1
Item.cs
Assets/Scripts/Item/Item.cs
+68
-3
ItemDrag.cs
Assets/Scripts/Item/ItemDrag.cs
+1
-1
ItemRoomInGame.cs
Assets/Scripts/TetrisMap/Rooms/ItemRoomInGame.cs
+1
-1
No files found.
Assets/Scripts/Characters/AttackProperty.cs
View file @
5b77dbee
...
@@ -5,14 +5,16 @@ using UnityEngine;
...
@@ -5,14 +5,16 @@ using UnityEngine;
public
class
AttackProperty
:
MonoBehaviour
{
public
class
AttackProperty
:
MonoBehaviour
{
public
float
damage
=
0
;
public
float
damage
=
0
;
public
float
knockBackMultiplier
=
1f
;
public
float
knockBackMultiplier
=
1f
;
public
int
debuffNum
=
0
;
public
float
[]
debuffTime
=
new
float
[(
int
)
EnemyDebuffCase
.
END_POINTER
];
public
EnemyDebuffCase
[]
debuffType
=
new
EnemyDebuffCase
[
10
];
public
int
[]
debuffTime
=
new
int
[
10
];
EffectManager
effectManager
;
EffectManager
effectManager
;
PlayerAttack
playerAttack
;
InventoryManager
inventoryManager
;
private
void
Awake
()
private
void
Awake
()
{
{
effectManager
=
EffectManager
.
Instance
;
effectManager
=
EffectManager
.
Instance
;
playerAttack
=
transform
.
parent
.
GetComponentInChildren
<
PlayerAttack
>();
inventoryManager
=
InventoryManager
.
Instance
;
}
}
private
void
OnTriggerEnter2D
(
Collider2D
collision
)
private
void
OnTriggerEnter2D
(
Collider2D
collision
)
...
@@ -21,11 +23,22 @@ public class AttackProperty : MonoBehaviour{
...
@@ -21,11 +23,22 @@ public class AttackProperty : MonoBehaviour{
Bounds
tmpBounds
=
new
Bounds
();
Bounds
tmpBounds
=
new
Bounds
();
if
(
collision
.
CompareTag
(
"Enemy"
)
&&
!
collision
.
transform
.
GetChild
(
0
).
GetComponent
<
Enemy
>().
Invisible
)
if
(
collision
.
CompareTag
(
"Enemy"
)
&&
!
collision
.
transform
.
GetChild
(
0
).
GetComponent
<
Enemy
>().
Invisible
)
{
{
PlayerAttackInfo
curAttack
=
new
PlayerAttackInfo
(
damage
,
knockBackMultiplier
,
debuff
Num
,
debuffType
,
debuff
Time
);
PlayerAttackInfo
curAttack
=
new
PlayerAttackInfo
(
damage
,
knockBackMultiplier
,
debuffTime
);
Enemy
enemyInfo
=
collision
.
transform
.
GetChild
(
0
).
GetComponent
<
Enemy
>();
Enemy
enemyInfo
=
collision
.
transform
.
GetChild
(
0
).
GetComponent
<
Enemy
>();
string
combo
=
playerAttack
.
comboArray
;
foreach
(
Item
tmpItem
in
inventoryManager
.
itemList
)
for
(
int
i
=
0
;
i
<
tmpItem
.
skillNum
;
i
++)
{
if
(
tmpItem
.
combo
[
i
].
Equals
(
combo
))
{
tmpItem
.
AttackCalculation
(
curAttack
,
enemyInfo
,
combo
);
break
;
}
}
collision
.
transform
.
GetChild
(
0
).
GetComponent
<
Enemy
>().
GetDamaged
(
curAttack
);
collision
.
transform
.
GetChild
(
0
).
GetComponent
<
Enemy
>().
GetDamaged
(
curAttack
);
//make effect
//make effect
foreach
(
Collider2D
col
in
GetComponents
<
Collider2D
>())
foreach
(
Collider2D
col
in
GetComponents
<
Collider2D
>())
if
(
col
.
isActiveAndEnabled
)
if
(
col
.
isActiveAndEnabled
)
...
...
Assets/Scripts/Characters/Enemy/Enemy.cs
View file @
5b77dbee
...
@@ -49,7 +49,7 @@ public class Enemy : MonoBehaviour {
...
@@ -49,7 +49,7 @@ public class Enemy : MonoBehaviour {
private
void
Awake
()
private
void
Awake
()
{
{
enemyManager
=
EnemyManager
.
Instance
;
enemyManager
=
EnemyManager
.
Instance
;
inventoryManager
=
GameObject
.
Find
(
"InventoryManager"
).
GetComponent
<
InventoryManager
>()
;
inventoryManager
=
InventoryManager
.
Instance
;
lifeStoneManager
=
GameObject
.
Find
(
"UI Canvas"
).
transform
.
GetChild
(
0
).
GetComponent
<
LifeStoneManager
>();
lifeStoneManager
=
GameObject
.
Find
(
"UI Canvas"
).
transform
.
GetChild
(
0
).
GetComponent
<
LifeStoneManager
>();
animator
=
GetComponent
<
Animator
>();
animator
=
GetComponent
<
Animator
>();
}
}
...
...
Assets/Scripts/Characters/PlayerAttack.cs
View file @
5b77dbee
...
@@ -14,7 +14,7 @@ public class PlayerAttack : MonoBehaviour {
...
@@ -14,7 +14,7 @@ public class PlayerAttack : MonoBehaviour {
public
Animator
anim
;
public
Animator
anim
;
public
AnimatorOverrideController
aoc
;
public
AnimatorOverrideController
aoc
;
public
AnimationClip
[]
normalAttack
=
new
AnimationClip
[
3
];
public
AnimationClip
[]
normalAttack
=
new
AnimationClip
[
3
];
public
InventoryManager
inventoryManager
;
InventoryManager
inventoryManager
;
public
LifeStoneManager
lifeStoneManager
;
public
LifeStoneManager
lifeStoneManager
;
float
comboEndTime
;
float
comboEndTime
;
...
@@ -24,6 +24,7 @@ public class PlayerAttack : MonoBehaviour {
...
@@ -24,6 +24,7 @@ public class PlayerAttack : MonoBehaviour {
void
Awake
()
void
Awake
()
{
{
inventoryManager
=
InventoryManager
.
Instance
;
playerController
=
GetComponent
<
PlayerController
>();
playerController
=
GetComponent
<
PlayerController
>();
anim
=
GetComponent
<
Animator
>();
anim
=
GetComponent
<
Animator
>();
aoc
=
new
AnimatorOverrideController
(
anim
.
runtimeAnimatorController
);
aoc
=
new
AnimatorOverrideController
(
anim
.
runtimeAnimatorController
);
...
...
Assets/Scripts/Characters/PlayerAttackInfo.cs
View file @
5b77dbee
...
@@ -5,15 +5,18 @@ using UnityEngine;
...
@@ -5,15 +5,18 @@ using UnityEngine;
public
class
PlayerAttackInfo
{
public
class
PlayerAttackInfo
{
public
float
damage
=
0
;
public
float
damage
=
0
;
public
float
knockBackMultiplier
=
1f
;
public
float
knockBackMultiplier
=
1f
;
public
int
debuffNum
=
0
;
public
float
[]
debuffTime
=
new
float
[(
int
)
EnemyDebuffCase
.
END_POINTER
];
public
EnemyDebuffCase
[]
debuffType
=
new
EnemyDebuffCase
[
10
];
public
PlayerAttackInfo
(
float
damage
,
float
knockBackMultiplier
,
float
[]
debuffTime
)
public
int
[]
debuffTime
=
new
int
[
10
];
public
PlayerAttackInfo
(
float
damage
,
float
knockBackMultiplier
,
int
debuffNum
,
EnemyDebuffCase
[]
debuffType
,
int
[]
debuffTime
)
{
{
this
.
damage
=
damage
;
this
.
damage
=
damage
;
this
.
knockBackMultiplier
=
knockBackMultiplier
;
this
.
knockBackMultiplier
=
knockBackMultiplier
;
this
.
debuffNum
=
debuffNum
;
this
.
debuffType
=
debuffType
;
this
.
debuffTime
=
debuffTime
;
this
.
debuffTime
=
debuffTime
;
}
}
public
PlayerAttackInfo
(
PlayerAttackInfo
origin
)
{
damage
=
origin
.
damage
;
knockBackMultiplier
=
origin
.
knockBackMultiplier
;
debuffTime
=
origin
.
debuffTime
;
}
}
}
Assets/Scripts/Enumerators.cs
View file @
5b77dbee
...
@@ -4,7 +4,8 @@
...
@@ -4,7 +4,8 @@
ice
,
ice
,
stun
,
stun
,
blind
,
blind
,
charm
charm
,
END_POINTER
};
};
public
enum
PlayerDebuffCase
public
enum
PlayerDebuffCase
{
{
...
...
Assets/Scripts/Item/Addon.cs
View file @
5b77dbee
...
@@ -24,4 +24,34 @@ public abstract class Addon {
...
@@ -24,4 +24,34 @@ public abstract class Addon {
highlight
=
null
;
highlight
=
null
;
sizeInventory
=
new
Vector2
(
0
,
0
);
sizeInventory
=
new
Vector2
(
0
,
0
);
}
}
public
virtual
float
DamageAdder
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
return
0f
;
}
public
virtual
float
DamageMultiplier
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
return
1f
;
}
public
virtual
float
[]
DebuffAdder
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
float
[]
varArray
=
new
float
[(
int
)
EnemyDebuffCase
.
END_POINTER
];
for
(
int
i
=
0
;
i
<
(
int
)
EnemyDebuffCase
.
END_POINTER
;
i
++)
varArray
[
i
]
=
0f
;
return
varArray
;
}
public
virtual
float
[]
DebuffMultiplier
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
float
[]
varArray
=
new
float
[(
int
)
EnemyDebuffCase
.
END_POINTER
];
for
(
int
i
=
0
;
i
<
(
int
)
EnemyDebuffCase
.
END_POINTER
;
i
++)
varArray
[
i
]
=
1f
;
return
varArray
;
}
public
virtual
float
KnockBackAdder
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
return
0f
;
}
public
virtual
float
KnockBackMultiplier
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
return
1f
;
}
}
}
Assets/Scripts/Item/AddonDrag.cs
View file @
5b77dbee
...
@@ -12,7 +12,7 @@ public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDra
...
@@ -12,7 +12,7 @@ public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDra
void
Start
()
void
Start
()
{
{
ui
=
GameObject
.
Find
(
"InventoryCanvas"
).
GetComponent
<
InventoryUI
>();
ui
=
GameObject
.
Find
(
"InventoryCanvas"
).
GetComponent
<
InventoryUI
>();
manager
=
GameObject
.
Find
(
"InventoryManager"
).
GetComponent
<
InventoryManager
>()
;
manager
=
InventoryManager
.
Instance
;
addonGroup
=
ui
.
gameObject
.
transform
.
Find
(
"AddonGroup"
);
addonGroup
=
ui
.
gameObject
.
transform
.
Find
(
"AddonGroup"
);
discardBin
=
ui
.
gameObject
.
transform
.
Find
(
"DiscardBin"
);
discardBin
=
ui
.
gameObject
.
transform
.
Find
(
"DiscardBin"
);
}
}
...
...
Assets/Scripts/Item/DroppedItem.cs
View file @
5b77dbee
...
@@ -34,7 +34,7 @@ public class DroppedItem : MonoBehaviour, IPlayerInteraction
...
@@ -34,7 +34,7 @@ public class DroppedItem : MonoBehaviour, IPlayerInteraction
}
}
public
void
Init
(
Addon
_addon
,
Vector3
pos
)
public
void
Init
(
Addon
_addon
,
Vector3
pos
)
{
{
inventoryManager
=
GameObject
.
Find
(
"InventoryManager"
).
GetComponent
<
InventoryManager
>()
;
inventoryManager
=
InventoryManager
.
Instance
;
addon
=
_addon
;
addon
=
_addon
;
itemAddon
=
true
;
itemAddon
=
true
;
rb2D
=
GetComponent
<
Rigidbody2D
>();
rb2D
=
GetComponent
<
Rigidbody2D
>();
...
...
Assets/Scripts/Item/InventoryManager.cs
View file @
5b77dbee
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine
;
public
class
InventoryManager
:
MonoBehaviour
{
public
class
InventoryManager
:
Singleton
<
InventoryManager
>
{
public
List
<
Item
>
itemList
=
new
List
<
Item
>();
public
List
<
Item
>
itemList
=
new
List
<
Item
>();
public
List
<
Addon
>
addonList
=
new
List
<
Addon
>();
public
List
<
Addon
>
addonList
=
new
List
<
Addon
>();
...
...
Assets/Scripts/Item/Item.cs
View file @
5b77dbee
...
@@ -64,10 +64,75 @@ public abstract class Item {
...
@@ -64,10 +64,75 @@ public abstract class Item {
{
{
}
}
public
v
oid
AttackCalculation
(
PlayerAttackInfo
attackInfo
,
Enemy
enemyInf
o
)
public
v
irtual
void
AttackCalculation
(
PlayerAttackInfo
attackInfo
,
Enemy
enemyInfo
,
string
comb
o
)
{
{
PlayerAttackInfo
originInfo
=
new
PlayerAttackInfo
(
attackInfo
);
float
[]
tmpArray
;
attackInfo
.
damage
+=
DamageAdder
(
originInfo
,
enemyInfo
,
combo
);
attackInfo
.
knockBackMultiplier
+=
KnockBackAdder
(
originInfo
,
enemyInfo
,
combo
);
tmpArray
=
DebuffAdder
(
originInfo
,
enemyInfo
,
combo
);
for
(
int
i
=
0
;
i
<
(
int
)
EnemyDebuffCase
.
END_POINTER
;
i
++)
attackInfo
.
debuffTime
[
i
]
+=
tmpArray
[
i
];
for
(
int
j
=
0
;
j
<
attachable
.
Length
;
j
++)
{
if
(
attachable
[
j
]
&&
addons
[
j
]
!=
null
)
{
attackInfo
.
damage
+=
addons
[
j
].
DamageAdder
(
originInfo
,
enemyInfo
,
combo
);
attackInfo
.
knockBackMultiplier
+=
addons
[
j
].
KnockBackAdder
(
originInfo
,
enemyInfo
,
combo
);
tmpArray
=
addons
[
j
].
DebuffAdder
(
originInfo
,
enemyInfo
,
combo
);
for
(
int
i
=
0
;
i
<
(
int
)
EnemyDebuffCase
.
END_POINTER
;
i
++)
attackInfo
.
debuffTime
[
i
]
+=
tmpArray
[
i
];
}
}
attackInfo
.
damage
*=
DamageMultiplier
(
originInfo
,
enemyInfo
,
combo
);
attackInfo
.
knockBackMultiplier
*=
KnockBackMultiplier
(
originInfo
,
enemyInfo
,
combo
);
tmpArray
=
DebuffMultiplier
(
originInfo
,
enemyInfo
,
combo
);
for
(
int
i
=
0
;
i
<
(
int
)
EnemyDebuffCase
.
END_POINTER
;
i
++)
attackInfo
.
debuffTime
[
i
]
*=
tmpArray
[
i
];
for
(
int
j
=
0
;
j
<
attachable
.
Length
;
j
++)
{
if
(
attachable
[
j
]
&&
addons
[
j
]
!=
null
)
{
attackInfo
.
damage
*=
addons
[
j
].
DamageMultiplier
(
originInfo
,
enemyInfo
,
combo
);
attackInfo
.
knockBackMultiplier
*=
addons
[
j
].
KnockBackMultiplier
(
originInfo
,
enemyInfo
,
combo
);
tmpArray
=
addons
[
j
].
DebuffMultiplier
(
originInfo
,
enemyInfo
,
combo
);
for
(
int
i
=
0
;
i
<
(
int
)
EnemyDebuffCase
.
END_POINTER
;
i
++)
attackInfo
.
debuffTime
[
i
]
*=
tmpArray
[
i
];
}
}
}
}
public
virtual
float
DamageAdder
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
return
0f
;
}
public
virtual
float
DamageMultiplier
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
return
1f
;
}
public
virtual
float
[]
DebuffAdder
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
float
[]
varArray
=
new
float
[(
int
)
EnemyDebuffCase
.
END_POINTER
];
for
(
int
i
=
0
;
i
<
(
int
)
EnemyDebuffCase
.
END_POINTER
;
i
++)
varArray
[
i
]
=
0f
;
return
varArray
;
}
public
virtual
float
[]
DebuffMultiplier
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
float
[]
varArray
=
new
float
[(
int
)
EnemyDebuffCase
.
END_POINTER
];
for
(
int
i
=
0
;
i
<
(
int
)
EnemyDebuffCase
.
END_POINTER
;
i
++)
varArray
[
i
]
=
1f
;
return
varArray
;
}
public
virtual
float
KnockBackAdder
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
return
0f
;
}
public
virtual
float
KnockBackMultiplier
(
PlayerAttackInfo
attackInfo
,
Enemy
enemInfo
,
string
combo
)
{
return
1f
;
}
}
}
Assets/Scripts/Item/ItemDrag.cs
View file @
5b77dbee
...
@@ -12,7 +12,7 @@ public class ItemDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag
...
@@ -12,7 +12,7 @@ public class ItemDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag
void
Start
()
void
Start
()
{
{
ui
=
GameObject
.
Find
(
"InventoryCanvas"
).
GetComponent
<
InventoryUI
>();
ui
=
GameObject
.
Find
(
"InventoryCanvas"
).
GetComponent
<
InventoryUI
>();
manager
=
GameObject
.
Find
(
"InventoryManager"
).
GetComponent
<
InventoryManager
>()
;
manager
=
InventoryManager
.
Instance
;
discardBin
=
ui
.
gameObject
.
transform
.
Find
(
"DiscardBin"
);
discardBin
=
ui
.
gameObject
.
transform
.
Find
(
"DiscardBin"
);
}
}
public
void
OnBeginDrag
(
PointerEventData
eventData
)
public
void
OnBeginDrag
(
PointerEventData
eventData
)
...
...
Assets/Scripts/TetrisMap/Rooms/ItemRoomInGame.cs
View file @
5b77dbee
...
@@ -8,7 +8,7 @@ public class ItemRoomInGame : RoomInGame {
...
@@ -8,7 +8,7 @@ public class ItemRoomInGame : RoomInGame {
{
{
base
.
RoomEnter
();
base
.
RoomEnter
();
Room
room
=
transform
.
parent
.
GetComponent
<
Room
>();
Room
room
=
transform
.
parent
.
GetComponent
<
Room
>();
InventoryManager
inventoryManager
=
GameObject
.
Find
(
"InventoryManager"
).
GetComponent
<
InventoryManager
>()
;
InventoryManager
inventoryManager
=
InventoryManager
.
Instance
;
LifeStoneManager
lifeStoneManager
=
GameObject
.
Find
(
"LifeStoneUI"
).
GetComponent
<
LifeStoneManager
>();
LifeStoneManager
lifeStoneManager
=
GameObject
.
Find
(
"LifeStoneUI"
).
GetComponent
<
LifeStoneManager
>();
int
probability
=
Random
.
Range
(
0
,
100
);
int
probability
=
Random
.
Range
(
0
,
100
);
Vector3
itemPosition
=
transform
.
Find
(
"item spot"
).
position
;
Vector3
itemPosition
=
transform
.
Find
(
"item spot"
).
position
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment