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
714cad0c
Commit
714cad0c
authored
Feb 17, 2019
by
15김민규
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
디버프 적용은 시켰는데 이거 맵 프리팹이 없어서 시작하자마자 떨어지는데?
parent
53d1fe96
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
57 deletions
+94
-57
testEnemy.unity
Assets/Scenes/testEnemy.unity
+15
-6
EnemyMeleeIdle.cs
...Scripts/Characters/Enemy/Animator State/EnemyMeleeIdle.cs
+1
-1
Enemy.cs
Assets/Scripts/Characters/Enemy/Enemy.cs
+66
-45
Enumerators.cs
Assets/Scripts/Enumerators.cs
+12
-5
No files found.
Assets/Scenes/testEnemy.unity
View file @
714cad0c
...
...
@@ -1108,11 +1108,6 @@ MonoBehaviour:
type
:
2
}
m_PrefabInternal
:
{
fileID
:
1711972807
}
m_Script
:
{
fileID
:
11500000
,
guid
:
7fe540ec78947fc449eabc76bd87823d
,
type
:
3
}
---
!u!4
&1207417820
stripped
Transform
:
m_CorrespondingSourceObject
:
{
fileID
:
4874486600194970
,
guid
:
0443c2e9410bbe545bda40dc30fa6a63
,
type
:
2
}
m_PrefabInternal
:
{
fileID
:
1787348169
}
---
!u!224
&1209430809
stripped
RectTransform
:
m_CorrespondingSourceObject
:
{
fileID
:
224402251087470820
,
guid
:
c179f0931cfabec428a868a6edc543b0
,
...
...
@@ -1155,7 +1150,7 @@ Transform:
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
-
{
fileID
:
1
20741782
0
}
-
{
fileID
:
1
78734817
0
}
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
4
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
...
...
@@ -1347,6 +1342,11 @@ Prefab:
m_Modification
:
m_TransformParent
:
{
fileID
:
0
}
m_Modifications
:
-
target
:
{
fileID
:
114402380471012178
,
guid
:
3d077a5f727dd1e4780e9265ed26e036
,
type
:
2
}
propertyPath
:
debuffTime.Array.size
value
:
5
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4549734214569802
,
guid
:
3d077a5f727dd1e4780e9265ed26e036
,
type
:
2
}
propertyPath
:
m_LocalPosition.x
value
:
2
...
...
@@ -1399,6 +1399,11 @@ Prefab:
propertyPath
:
lifeStoneManager
value
:
objectReference
:
{
fileID
:
1206751493
}
-
target
:
{
fileID
:
114402380471012178
,
guid
:
3d077a5f727dd1e4780e9265ed26e036
,
type
:
2
}
propertyPath
:
debuffTime.Array.data[0]
value
:
1
objectReference
:
{
fileID
:
0
}
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
3d077a5f727dd1e4780e9265ed26e036
,
type
:
2
}
m_IsPrefabAsset
:
0
...
...
@@ -1640,6 +1645,10 @@ Prefab:
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
0443c2e9410bbe545bda40dc30fa6a63
,
type
:
2
}
m_IsPrefabAsset
:
0
---
!u!4
&1787348170
stripped
Transform
:
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
1787348169
}
---
!u!114
&1908917313
stripped
MonoBehaviour
:
m_CorrespondingSourceObject
:
{
fileID
:
114939219159237616
,
guid
:
62a83d11a7addc342ad436145784e698
,
...
...
Assets/Scripts/Characters/Enemy/Animator State/EnemyMeleeIdle.cs
View file @
714cad0c
...
...
@@ -31,7 +31,7 @@ public class EnemyMeleeIdle : StateMachineBehaviour {
animator
.
SetTrigger
(
"TrackTrigger"
);
return
;
}
if
(!
enemy
.
DuringKnockba
ck
)
if
(!
enemy
.
KnockbackLo
ck
)
{
float
span
=
animatorRoot
.
position
.
x
-
origin
.
x
;
...
...
Assets/Scripts/Characters/Enemy/Enemy.cs
View file @
714cad0c
...
...
@@ -8,13 +8,9 @@ public class Enemy : MonoBehaviour {
// data
// debuff
float
[]
immunity_time
=
new
float
[
5
]
{
0.0f
,
3.0f
,
6.0f
,
6.0f
,
6.0f
};
//면역 시간
bool
[]
immunity
=
new
bool
[]
{
false
,
};
//현재 에너미가 디버프 상태에 대해서 면역인지를 체크하는 변수
struct
EnemyDebuff
{
public
EnemyDebuffCase
Case
;
public
float
Duration
;
}
float
[]
immunity_time
=
new
float
[(
int
)
EnemyDebuffCase
.
END_POINTER
]
{
0.0f
,
3.0f
,
6.0f
,
6.0f
,
6.0f
};
DebuffState
[]
debuffState
;
float
fireDuration
=
0.0f
;
// stat
public
int
monsterID
;
...
...
@@ -37,7 +33,8 @@ public class Enemy : MonoBehaviour {
// for movement
private
Animator
animator
;
public
bool
Invisible
{
get
;
private
set
;
}
public
bool
DuringKnockback
{
get
;
private
set
;
}
public
bool
KnockbackLock
{
get
;
private
set
;
}
public
bool
DebuffLock
{
get
;
private
set
;
}
public
float
PlayerDistance
{
get
;
private
set
;
}
private
readonly
float
knockbackCritPoint
=
0.25f
;
...
...
@@ -45,16 +42,6 @@ public class Enemy : MonoBehaviour {
public
bool
[]
WallTest
{
get
;
private
set
;
}
public
bool
[]
CliffTest
{
get
;
private
set
;
}
/* Inspector에서 WallTest와 CliffTest를 확인해보고 싶으면 주석을 풀으시오
public bool[] WallTest { get { return wallTest; } private set { wallTest = value; } } // {left, right}
public bool[] CliffTest { get { return cliffTest; } private set { cliffTest = value; } } // {left, right}
[SerializeField]
private bool[] wallTest;
[SerializeField]
private bool[] cliffTest;
*/
// drop item
private
int
[]
dropTable
;
...
...
@@ -69,13 +56,16 @@ public class Enemy : MonoBehaviour {
WallTest
=
new
bool
[]
{
false
,
false
};
CliffTest
=
new
bool
[]
{
false
,
false
};
DebuffState
_temp
=
DebuffState
.
Off
;
debuffState
=
new
DebuffState
[(
int
)
EnemyDebuffCase
.
END_POINTER
]
{
_temp
,
_temp
,
_temp
,
_temp
,
_temp
};
}
private
void
Start
()
{
MoveDir
=
(
int
)
NumeratedDir
.
Left
;
currHealth
=
maxHealth
;
Invisible
=
DuringKnockba
ck
=
false
;
Invisible
=
KnockbackLo
ck
=
false
;
dropTable
=
enemyManager
.
DropTableByID
[
monsterID
];
//Physics2D.IgnoreCollision(enemyManager.Player.gameObject.GetComponent<Collider2D>(), transform.parent.GetComponent<Collider2D>());
PlayerDistance
=
Vector2
.
Distance
(
enemyManager
.
Player
.
transform
.
position
,
transform
.
parent
.
position
);
...
...
@@ -127,7 +117,7 @@ public class Enemy : MonoBehaviour {
// - Change direction, and speed of rigidbody of enemy
public
void
ChangeVelocityX
(
float
val
)
{
if
(!
DuringKnockba
ck
)
if
(!
KnockbackLock
&&
!
DebuffLo
ck
)
{
Vector2
tempVelocity
=
transform
.
parent
.
GetComponent
<
Rigidbody2D
>().
velocity
;
tempVelocity
.
x
=
val
;
...
...
@@ -144,7 +134,7 @@ public class Enemy : MonoBehaviour {
public
void
ChangeDir
(
object
dir
)
{
if
(!
DuringKnockba
ck
)
if
(!
KnockbackLock
&&
!
DebuffLo
ck
)
{
MoveDir
=
(
int
)
dir
;
transform
.
parent
.
eulerAngles
=
((
NumeratedDir
)
dir
==
NumeratedDir
.
Left
)
?
new
Vector2
(
0
,
0
)
:
new
Vector2
(
0
,
180
);
...
...
@@ -160,7 +150,7 @@ public class Enemy : MonoBehaviour {
// - Knockback coroutine
IEnumerator
Knockback
(
float
knockbackDist
,
float
knockbackTime
)
{
DuringKnockba
ck
=
true
;
KnockbackLo
ck
=
true
;
int
knockbackDir
=
(
enemyManager
.
Player
.
transform
.
position
.
x
-
transform
.
parent
.
position
.
x
>=
0
)
?
-
1
:
1
;
float
knockbackVelocity
=
knockbackDir
*
knockbackDist
/
knockbackTime
;
SudoChangeDir
(
knockbackDir
*
-
1
);
...
...
@@ -176,7 +166,7 @@ public class Enemy : MonoBehaviour {
}
yield
return
new
WaitForFixedUpdate
();
}
DuringKnockba
ck
=
false
;
KnockbackLo
ck
=
false
;
ChangeVelocityX
(
0.0f
);
}
...
...
@@ -196,7 +186,7 @@ public class Enemy : MonoBehaviour {
float
knockbackDist
=
attack
.
damage
*
attack
.
knockBackMultiplier
/
weight
;
float
knockbackTime
=
(
knockbackDist
>=
0.5f
)
?
0.5f
:
knockbackDist
;
if
(
DuringKnockba
ck
)
if
(
KnockbackLo
ck
)
{
StopCoroutine
(
"Knockback"
);
}
...
...
@@ -207,6 +197,14 @@ public class Enemy : MonoBehaviour {
animator
.
SetFloat
(
"knockbackTime"
,
knockbackTime
);
animator
.
SetTrigger
(
"DamagedTrigger"
);
}
for
(
int
i
=
0
;
i
<
(
int
)
EnemyDebuffCase
.
END_POINTER
;
i
++)
{
if
(
attack
.
debuffTime
[
i
]
>
0.0f
)
{
DebuffApply
((
EnemyDebuffCase
)
i
,
attack
.
debuffTime
[
i
]);
}
}
}
public
void
GetDamaged
(
float
damage
)
...
...
@@ -221,25 +219,29 @@ public class Enemy : MonoBehaviour {
}
// - Apply debuff
private
void
DebuffApply
(
EnemyDebuff
debuff
)
private
void
DebuffApply
(
EnemyDebuff
Case
debuff
,
float
duration
)
{
IEnumerator
debuffFunc
=
null
;
switch
(
debuff
.
Case
)
{
case
EnemyDebuffCase
.
fire
:
debuffFunc
=
OnFire
(
debuff
.
Duration
);
int
intCase
=
(
int
)
debuff
;
if
(
debuffState
[
intCase
]
==
DebuffState
.
Immune
)
return
;
debuffState
[
intCase
]
=
DebuffState
.
On
;
switch
(
debuff
)
{
case
EnemyDebuffCase
.
Fire
:
if
(
fireDuration
!=
0.0f
)
{
fireDuration
+=
duration
;
}
else
{
debuffFunc
=
OnFire
(
duration
);
}
break
;
case
EnemyDebuffCase
.
i
ce
:
debuffFunc
=
OnIce
(
d
ebuff
.
D
uration
);
case
EnemyDebuffCase
.
I
ce
:
debuffFunc
=
OnIce
(
duration
);
break
;
case
EnemyDebuffCase
.
s
tun
:
debuffFunc
=
OnStun
(
d
ebuff
.
D
uration
);
case
EnemyDebuffCase
.
S
tun
:
debuffFunc
=
OnStun
(
duration
);
break
;
case
EnemyDebuffCase
.
b
lind
:
debuffFunc
=
OnBlind
(
d
ebuff
.
D
uration
);
case
EnemyDebuffCase
.
B
lind
:
debuffFunc
=
OnBlind
(
duration
);
break
;
case
EnemyDebuffCase
.
c
harm
:
debuffFunc
=
OnCharm
(
d
ebuff
.
D
uration
);
case
EnemyDebuffCase
.
C
harm
:
debuffFunc
=
OnCharm
(
duration
);
break
;
default
:
break
;
...
...
@@ -250,24 +252,36 @@ public class Enemy : MonoBehaviour {
// - Debuff coroutine
IEnumerator
OnFire
(
float
duration
)
{
int
dotCount
=
0
;
fireDuration
=
duration
;
float
dotGap
=
1.0f
;
while
(
true
)
{
dotCount
+=
1
;
if
(
duration
<
dotCount
)
{
break
;
}
fireDuration
-=
dotGap
;
if
(
fireDuration
<=
0.0f
)
{
fireDuration
=
0
;
break
;
}
yield
return
new
WaitForSeconds
(
1.0f
);
GetDamaged
(
lifeStoneManager
.
lifeStoneRowNum
*
3
);
}
debuffState
[(
int
)
EnemyDebuffCase
.
Fire
]
=
DebuffState
.
Off
;
}
IEnumerator
OnIce
(
float
duration
)
{
yield
return
null
;
ChangeVelocityX
(
0.0f
);
DebuffLock
=
true
;
yield
return
new
WaitForSeconds
(
duration
);
OffDebuff
(
EnemyDebuffCase
.
Ice
);
}
IEnumerator
OnStun
(
float
duration
)
{
ChangeVelocityX
(
0.0f
);
DebuffLock
=
true
;
yield
return
new
WaitForSeconds
(
duration
);
OffDebuff
(
EnemyDebuffCase
.
Ice
);
yield
return
null
;
}
...
...
@@ -281,10 +295,17 @@ public class Enemy : MonoBehaviour {
yield
return
null
;
}
IEnumerator
ImmunityTimer
(
EnemyDebuff
sCase
)
IEnumerator
ImmuneTimer
(
EnemyDebuffCase
Case
,
float
duration
)
{
debuffState
[(
int
)
Case
]
=
DebuffState
.
Immune
;
yield
return
new
WaitForSeconds
(
duration
);
debuffState
[(
int
)
Case
]
=
DebuffState
.
Off
;
}
private
void
OffDebuff
(
EnemyDebuffCase
Case
)
{
yield
return
new
WaitForSeconds
(
immunity_time
[(
int
)
sCase
.
Case
])
;
immunity
[(
int
)
sCase
.
Case
]
=
false
;
DebuffLock
=
false
;
ImmuneTimer
(
Case
,
immunity_time
[(
int
)
Case
])
;
}
// Animation Event
...
...
Assets/Scripts/Enumerators.cs
View file @
714cad0c
public
enum
EnemyDebuffCase
{
f
ire
,
i
ce
,
s
tun
,
b
lind
,
c
harm
,
F
ire
,
I
ce
,
S
tun
,
B
lind
,
C
harm
,
END_POINTER
};
public
enum
DebuffState
{
Off
,
On
,
Immune
,
}
public
enum
NumeratedDir
{
Left
=
-
1
,
...
...
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