Commit 714cad0c authored by 15김민규's avatar 15김민규

디버프 적용은 시켰는데 이거 맵 프리팹이 없어서 시작하자마자 떨어지는데?

parent 53d1fe96
......@@ -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: 1207417820}
- {fileID: 1787348170}
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,
......
......@@ -31,7 +31,7 @@ public class EnemyMeleeIdle : StateMachineBehaviour {
animator.SetTrigger("TrackTrigger");
return;
}
if (!enemy.DuringKnockback)
if (!enemy.KnockbackLock)
{
float span = animatorRoot.position.x - origin.x;
......
......@@ -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 = DuringKnockback = false;
Invisible = KnockbackLock = 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 (!DuringKnockback)
if (!KnockbackLock && !DebuffLock)
{
Vector2 tempVelocity = transform.parent.GetComponent<Rigidbody2D>().velocity;
tempVelocity.x = val;
......@@ -144,7 +134,7 @@ public class Enemy : MonoBehaviour {
public void ChangeDir(object dir)
{
if (!DuringKnockback)
if (!KnockbackLock && !DebuffLock)
{
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)
{
DuringKnockback = true;
KnockbackLock = 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();
}
DuringKnockback = false;
KnockbackLock = 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 (DuringKnockback)
if (KnockbackLock)
{
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(EnemyDebuffCase 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.ice:
debuffFunc = OnIce(debuff.Duration);
case EnemyDebuffCase.Ice:
debuffFunc = OnIce(duration);
break;
case EnemyDebuffCase.stun:
debuffFunc = OnStun(debuff.Duration);
case EnemyDebuffCase.Stun:
debuffFunc = OnStun(duration);
break;
case EnemyDebuffCase.blind:
debuffFunc = OnBlind(debuff.Duration);
case EnemyDebuffCase.Blind:
debuffFunc = OnBlind(duration);
break;
case EnemyDebuffCase.charm:
debuffFunc = OnCharm(debuff.Duration);
case EnemyDebuffCase.Charm:
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
......
public enum EnemyDebuffCase
{
fire,
ice,
stun,
blind,
charm,
Fire,
Ice,
Stun,
Blind,
Charm,
END_POINTER
};
public enum DebuffState
{
Off,
On,
Immune,
}
public enum NumeratedDir
{
Left = -1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment