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

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

parent 53d1fe96
...@@ -1108,11 +1108,6 @@ MonoBehaviour: ...@@ -1108,11 +1108,6 @@ MonoBehaviour:
type: 2} type: 2}
m_PrefabInternal: {fileID: 1711972807} m_PrefabInternal: {fileID: 1711972807}
m_Script: {fileID: 11500000, guid: 7fe540ec78947fc449eabc76bd87823d, type: 3} 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 --- !u!224 &1209430809 stripped
RectTransform: RectTransform:
m_CorrespondingSourceObject: {fileID: 224402251087470820, guid: c179f0931cfabec428a868a6edc543b0, m_CorrespondingSourceObject: {fileID: 224402251087470820, guid: c179f0931cfabec428a868a6edc543b0,
...@@ -1155,7 +1150,7 @@ Transform: ...@@ -1155,7 +1150,7 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 1207417820} - {fileID: 1787348170}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
...@@ -1347,6 +1342,11 @@ Prefab: ...@@ -1347,6 +1342,11 @@ Prefab:
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: 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} - target: {fileID: 4549734214569802, guid: 3d077a5f727dd1e4780e9265ed26e036, type: 2}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: 2 value: 2
...@@ -1399,6 +1399,11 @@ Prefab: ...@@ -1399,6 +1399,11 @@ Prefab:
propertyPath: lifeStoneManager propertyPath: lifeStoneManager
value: value:
objectReference: {fileID: 1206751493} objectReference: {fileID: 1206751493}
- target: {fileID: 114402380471012178, guid: 3d077a5f727dd1e4780e9265ed26e036,
type: 2}
propertyPath: debuffTime.Array.data[0]
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3d077a5f727dd1e4780e9265ed26e036, type: 2} m_SourcePrefab: {fileID: 100100000, guid: 3d077a5f727dd1e4780e9265ed26e036, type: 2}
m_IsPrefabAsset: 0 m_IsPrefabAsset: 0
...@@ -1640,6 +1645,10 @@ Prefab: ...@@ -1640,6 +1645,10 @@ Prefab:
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0443c2e9410bbe545bda40dc30fa6a63, type: 2} m_SourcePrefab: {fileID: 100100000, guid: 0443c2e9410bbe545bda40dc30fa6a63, type: 2}
m_IsPrefabAsset: 0 m_IsPrefabAsset: 0
--- !u!4 &1787348170 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 1787348169}
--- !u!114 &1908917313 stripped --- !u!114 &1908917313 stripped
MonoBehaviour: MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 114939219159237616, guid: 62a83d11a7addc342ad436145784e698, m_CorrespondingSourceObject: {fileID: 114939219159237616, guid: 62a83d11a7addc342ad436145784e698,
......
...@@ -31,7 +31,7 @@ public class EnemyMeleeIdle : StateMachineBehaviour { ...@@ -31,7 +31,7 @@ public class EnemyMeleeIdle : StateMachineBehaviour {
animator.SetTrigger("TrackTrigger"); animator.SetTrigger("TrackTrigger");
return; return;
} }
if (!enemy.DuringKnockback) if (!enemy.KnockbackLock)
{ {
float span = animatorRoot.position.x - origin.x; float span = animatorRoot.position.x - origin.x;
......
...@@ -8,13 +8,9 @@ public class Enemy : MonoBehaviour { ...@@ -8,13 +8,9 @@ public class Enemy : MonoBehaviour {
// data // data
// debuff // debuff
float[] immunity_time = new float[5] { 0.0f, 3.0f, 6.0f, 6.0f, 6.0f };//면역 시간 float[] immunity_time = new float[(int)EnemyDebuffCase.END_POINTER] { 0.0f, 3.0f, 6.0f, 6.0f, 6.0f };
bool[] immunity = new bool[] { false, }; //현재 에너미가 디버프 상태에 대해서 면역인지를 체크하는 변수 DebuffState[] debuffState;
struct EnemyDebuff float fireDuration = 0.0f;
{
public EnemyDebuffCase Case;
public float Duration;
}
// stat // stat
public int monsterID; public int monsterID;
...@@ -37,7 +33,8 @@ public class Enemy : MonoBehaviour { ...@@ -37,7 +33,8 @@ public class Enemy : MonoBehaviour {
// for movement // for movement
private Animator animator; private Animator animator;
public bool Invisible { get; private set; } 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; } public float PlayerDistance { get; private set; }
private readonly float knockbackCritPoint = 0.25f; private readonly float knockbackCritPoint = 0.25f;
...@@ -45,16 +42,6 @@ public class Enemy : MonoBehaviour { ...@@ -45,16 +42,6 @@ public class Enemy : MonoBehaviour {
public bool[] WallTest { get; private set; } public bool[] WallTest { get; private set; }
public bool[] CliffTest { 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 // drop item
private int[] dropTable; private int[] dropTable;
...@@ -69,13 +56,16 @@ public class Enemy : MonoBehaviour { ...@@ -69,13 +56,16 @@ public class Enemy : MonoBehaviour {
WallTest = new bool[] { false, false }; WallTest = new bool[] { false, false };
CliffTest = 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() private void Start()
{ {
MoveDir = (int)NumeratedDir.Left; MoveDir = (int)NumeratedDir.Left;
currHealth = maxHealth; currHealth = maxHealth;
Invisible = DuringKnockback = false; Invisible = KnockbackLock = false;
dropTable = enemyManager.DropTableByID[monsterID]; dropTable = enemyManager.DropTableByID[monsterID];
//Physics2D.IgnoreCollision(enemyManager.Player.gameObject.GetComponent<Collider2D>(), transform.parent.GetComponent<Collider2D>()); //Physics2D.IgnoreCollision(enemyManager.Player.gameObject.GetComponent<Collider2D>(), transform.parent.GetComponent<Collider2D>());
PlayerDistance = Vector2.Distance(enemyManager.Player.transform.position, transform.parent.position); PlayerDistance = Vector2.Distance(enemyManager.Player.transform.position, transform.parent.position);
...@@ -127,7 +117,7 @@ public class Enemy : MonoBehaviour { ...@@ -127,7 +117,7 @@ public class Enemy : MonoBehaviour {
// - Change direction, and speed of rigidbody of enemy // - Change direction, and speed of rigidbody of enemy
public void ChangeVelocityX(float val) public void ChangeVelocityX(float val)
{ {
if (!DuringKnockback) if (!KnockbackLock && !DebuffLock)
{ {
Vector2 tempVelocity = transform.parent.GetComponent<Rigidbody2D>().velocity; Vector2 tempVelocity = transform.parent.GetComponent<Rigidbody2D>().velocity;
tempVelocity.x = val; tempVelocity.x = val;
...@@ -144,7 +134,7 @@ public class Enemy : MonoBehaviour { ...@@ -144,7 +134,7 @@ public class Enemy : MonoBehaviour {
public void ChangeDir(object dir) public void ChangeDir(object dir)
{ {
if (!DuringKnockback) if (!KnockbackLock && !DebuffLock)
{ {
MoveDir = (int)dir; MoveDir = (int)dir;
transform.parent.eulerAngles = ((NumeratedDir)dir == NumeratedDir.Left) ? new Vector2(0, 0) : new Vector2(0, 180); transform.parent.eulerAngles = ((NumeratedDir)dir == NumeratedDir.Left) ? new Vector2(0, 0) : new Vector2(0, 180);
...@@ -160,7 +150,7 @@ public class Enemy : MonoBehaviour { ...@@ -160,7 +150,7 @@ public class Enemy : MonoBehaviour {
// - Knockback coroutine // - Knockback coroutine
IEnumerator Knockback(float knockbackDist, float knockbackTime) IEnumerator Knockback(float knockbackDist, float knockbackTime)
{ {
DuringKnockback = true; KnockbackLock = true;
int knockbackDir = (enemyManager.Player.transform.position.x - transform.parent.position.x >= 0) ? -1 : 1; int knockbackDir = (enemyManager.Player.transform.position.x - transform.parent.position.x >= 0) ? -1 : 1;
float knockbackVelocity = knockbackDir * knockbackDist / knockbackTime; float knockbackVelocity = knockbackDir * knockbackDist / knockbackTime;
SudoChangeDir(knockbackDir * -1); SudoChangeDir(knockbackDir * -1);
...@@ -176,7 +166,7 @@ public class Enemy : MonoBehaviour { ...@@ -176,7 +166,7 @@ public class Enemy : MonoBehaviour {
} }
yield return new WaitForFixedUpdate(); yield return new WaitForFixedUpdate();
} }
DuringKnockback = false; KnockbackLock = false;
ChangeVelocityX(0.0f); ChangeVelocityX(0.0f);
} }
...@@ -196,7 +186,7 @@ public class Enemy : MonoBehaviour { ...@@ -196,7 +186,7 @@ public class Enemy : MonoBehaviour {
float knockbackDist = attack.damage * attack.knockBackMultiplier / weight; float knockbackDist = attack.damage * attack.knockBackMultiplier / weight;
float knockbackTime = (knockbackDist >= 0.5f) ? 0.5f : knockbackDist; float knockbackTime = (knockbackDist >= 0.5f) ? 0.5f : knockbackDist;
if (DuringKnockback) if (KnockbackLock)
{ {
StopCoroutine("Knockback"); StopCoroutine("Knockback");
} }
...@@ -207,6 +197,14 @@ public class Enemy : MonoBehaviour { ...@@ -207,6 +197,14 @@ public class Enemy : MonoBehaviour {
animator.SetFloat("knockbackTime", knockbackTime); animator.SetFloat("knockbackTime", knockbackTime);
animator.SetTrigger("DamagedTrigger"); 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) public void GetDamaged(float damage)
...@@ -221,25 +219,29 @@ public class Enemy : MonoBehaviour { ...@@ -221,25 +219,29 @@ public class Enemy : MonoBehaviour {
} }
// - Apply debuff // - Apply debuff
private void DebuffApply(EnemyDebuff debuff) private void DebuffApply(EnemyDebuffCase debuff, float duration)
{ {
IEnumerator debuffFunc = null; IEnumerator debuffFunc = null;
switch (debuff.Case) int intCase = (int)debuff;
if (debuffState[intCase] == DebuffState.Immune) return;
debuffState[intCase] = DebuffState.On;
switch (debuff)
{ {
case EnemyDebuffCase.fire: case EnemyDebuffCase.Fire:
debuffFunc = OnFire(debuff.Duration); if (fireDuration != 0.0f) { fireDuration += duration; }
else { debuffFunc = OnFire(duration); }
break; break;
case EnemyDebuffCase.ice: case EnemyDebuffCase.Ice:
debuffFunc = OnIce(debuff.Duration); debuffFunc = OnIce(duration);
break; break;
case EnemyDebuffCase.stun: case EnemyDebuffCase.Stun:
debuffFunc = OnStun(debuff.Duration); debuffFunc = OnStun(duration);
break; break;
case EnemyDebuffCase.blind: case EnemyDebuffCase.Blind:
debuffFunc = OnBlind(debuff.Duration); debuffFunc = OnBlind(duration);
break; break;
case EnemyDebuffCase.charm: case EnemyDebuffCase.Charm:
debuffFunc = OnCharm(debuff.Duration); debuffFunc = OnCharm(duration);
break; break;
default: default:
break; break;
...@@ -250,24 +252,36 @@ public class Enemy : MonoBehaviour { ...@@ -250,24 +252,36 @@ public class Enemy : MonoBehaviour {
// - Debuff coroutine // - Debuff coroutine
IEnumerator OnFire(float duration) IEnumerator OnFire(float duration)
{ {
int dotCount = 0; fireDuration = duration;
float dotGap = 1.0f;
while(true) while(true)
{ {
dotCount += 1; fireDuration -= dotGap;
if (duration < dotCount) { break; } if (fireDuration <= 0.0f) {
fireDuration = 0;
break;
}
yield return new WaitForSeconds(1.0f); yield return new WaitForSeconds(1.0f);
GetDamaged(lifeStoneManager.lifeStoneRowNum * 3); GetDamaged(lifeStoneManager.lifeStoneRowNum * 3);
} }
debuffState[(int)EnemyDebuffCase.Fire] = DebuffState.Off;
} }
IEnumerator OnIce(float duration) IEnumerator OnIce(float duration)
{ {
yield return null; ChangeVelocityX(0.0f);
DebuffLock = true;
yield return new WaitForSeconds(duration);
OffDebuff(EnemyDebuffCase.Ice);
} }
IEnumerator OnStun(float duration) IEnumerator OnStun(float duration)
{ {
ChangeVelocityX(0.0f);
DebuffLock = true;
yield return new WaitForSeconds(duration);
OffDebuff(EnemyDebuffCase.Ice);
yield return null; yield return null;
} }
...@@ -281,11 +295,18 @@ public class Enemy : MonoBehaviour { ...@@ -281,11 +295,18 @@ public class Enemy : MonoBehaviour {
yield return null; yield return null;
} }
IEnumerator ImmunityTimer(EnemyDebuff sCase) IEnumerator ImmuneTimer(EnemyDebuffCase Case, float duration)
{ {
yield return new WaitForSeconds(immunity_time[(int)sCase.Case]); debuffState[(int)Case] = DebuffState.Immune;
immunity[(int)sCase.Case] = false; yield return new WaitForSeconds(duration);
} debuffState[(int)Case] = DebuffState.Off;
}
private void OffDebuff(EnemyDebuffCase Case)
{
DebuffLock = false;
ImmuneTimer(Case, immunity_time[(int)Case]);
}
// Animation Event // Animation Event
......
public enum EnemyDebuffCase public enum EnemyDebuffCase
{ {
fire, Fire,
ice, Ice,
stun, Stun,
blind, Blind,
charm, Charm,
END_POINTER END_POINTER
}; };
public enum DebuffState
{
Off,
On,
Immune,
}
public enum NumeratedDir public enum NumeratedDir
{ {
Left = -1, 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