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
2d694d73
Commit
2d694d73
authored
Jan 07, 2019
by
18김상언
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enemy가 받는 디버프 관련 코드 작성 중
현재 Enemy의 행동 관련 코드가 없어 완성하진 못했음. 우선 해야하는 부분: 빙결 상태일 때랑 매혹 상태일 때 디버프 해제되는 부분
parent
0a4852f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
2 deletions
+83
-2
Enemy.cs
Assets/Scripts/Characters/Enemy.cs
+83
-2
No files found.
Assets/Scripts/Characters/Enemy.cs
View file @
2d694d73
using
System.Collections
;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
Enemy
:
MonoBehaviour
{
private
readonly
float
maxHealth
;
private
readonly
float
weight
;
public
float
playerMaxHealth
;
//다른 스크립트에 있는 플레이어 최대체력 가져와야함
private
float
currHealth
;
float
[]
immunity_time
=
new
float
[
5
]
{
0.0f
,
3.0f
,
6.0f
,
6.0f
,
6.0f
};
//면역 시간
bool
[]
immunity
=
new
bool
[]
{
false
,
};
//현재 에너미가 디버프 상태에 대해서 면역인지를 체크하는 변수
enum
debuffCase
{
fire
,
ice
,
stun
,
blind
,
charm
};
private
EnemyManager
.
State
currState
;
private
List
<
int
[
]>
dropTable
;
// [item ID, numerator]
private
Dictionary
<
EnemyManager
.
State
,
EnemyManager
.
Action
<
int
>>
actionByState
;
...
...
@@ -26,6 +31,7 @@ public class Enemy : MonoBehaviour {
}
float
knockback_dist
=
damage
*
unitDist
/
weight
;
// do something - knockback animation
}
private
List
<
int
[
]>
GetDropTable
(
uint
id
)
{
List
<
int
[
]>
resultList
=
new
List
<
int
[
]>
();
...
...
@@ -39,7 +45,7 @@ public class Enemy : MonoBehaviour {
int
dropItemId
=
-
1
;
if
(
dropTable
!=
null
)
{
float
denominator
=
dropTable
[
dropTable
.
Count
-
1
][
1
];
float
numerator
=
Random
.
Range
(
0f
,
denominator
);
float
numerator
=
UnityEngine
.
Random
.
Range
(
0f
,
denominator
);
foreach
(
var
drop
in
dropTable
)
{
if
(
numerator
<=
drop
[
1
])
{
...
...
@@ -53,5 +59,80 @@ public class Enemy : MonoBehaviour {
// destroy itself (or, deactivate for pooling)
Destroy
(
gameObject
);
}
struct
EnemyDebuffed
{
public
debuffCase
Case
;
public
float
debuffTime
;
}
IEnumerator
DebuffCase
(
EnemyDebuffed
sCase
)
{
if
(
sCase
.
Case
==
debuffCase
.
fire
)
{
StartCoroutine
(
OnFire
(
sCase
));
}
else
if
(
sCase
.
Case
==
debuffCase
.
ice
&&
!
immunity
[(
int
)
debuffCase
.
ice
])
{
//Enemy 정지하는 코드 필요
immunity
[(
int
)
debuffCase
.
ice
]
=
true
;
yield
return
StartCoroutine
(
DebuffDoing
(
sCase
));
}
else
if
(
sCase
.
Case
==
debuffCase
.
stun
&&
!
immunity
[(
int
)
debuffCase
.
stun
])
{
//Enemy 정지하는 코드 필요
immunity
[(
int
)
debuffCase
.
stun
]
=
true
;
yield
return
StartCoroutine
(
DebuffDoing
(
sCase
));
}
else
if
(
sCase
.
Case
==
debuffCase
.
blind
&&
!
immunity
[(
int
)
debuffCase
.
blind
])
{
//Enemy의 공격이 적중하지 않는 코드 필요
immunity
[(
int
)
debuffCase
.
stun
]
=
true
;
yield
return
StartCoroutine
(
DebuffDoing
(
sCase
));
}
else
if
(
sCase
.
Case
==
debuffCase
.
charm
&&
!
immunity
[(
int
)
debuffCase
.
charm
])
{
//Enemy 공격이 플레이어 회복하는 코드 필요
immunity
[(
int
)
debuffCase
.
stun
]
=
true
;
yield
return
StartCoroutine
(
DebuffDoing
(
sCase
));
}
}
IEnumerator
OnFire
(
EnemyDebuffed
sCase
)
{
for
(
int
i
=
0
;
i
<
sCase
.
debuffTime
/
1
;
i
++)
{
yield
return
new
WaitForSeconds
(
1.0f
);
currHealth
=
currHealth
-
playerMaxHealth
/
10
;
}
}
IEnumerator
DebuffDoing
(
EnemyDebuffed
sCase
)
{
yield
return
new
WaitForSeconds
(
sCase
.
debuffTime
);
yield
return
StartCoroutine
(
DebuffEnd
(
sCase
));
}
IEnumerator
DebuffEnd
(
EnemyDebuffed
sCase
)
{
//다시 동작하는 코드 필요
yield
return
StartCoroutine
(
ImmunityTimer
(
sCase
));
}
IEnumerator
ImmunityTimer
(
EnemyDebuffed
sCase
)
{
yield
return
new
WaitForSeconds
(
immunity_time
[(
int
)
sCase
.
Case
]);
immunity
[(
int
)
sCase
.
Case
]
=
false
;
}
}
//얼음일때 깨어나기
//공격이 적중했을 때 매혹에서 깨어나기
\ No newline at end of file
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