Commit c46a4135 authored by 16도재형's avatar 16도재형

페이즈 1에서 2로 넘어가는거 만들어야하는데 거미가 안살아남, enemy 브랜치 머지하고 다시작업함

parent 7d77c1cd
This diff is collapsed.
This diff is collapsed.
...@@ -7,9 +7,11 @@ public class JiJooMove : StateMachineBehaviour { ...@@ -7,9 +7,11 @@ public class JiJooMove : StateMachineBehaviour {
float verticalSpeed; float verticalSpeed;
GameObject player; GameObject player;
Transform animatorRoot; Transform animatorRoot;
Rigidbody2D rb2D;
JiJoo enemy; JiJoo enemy;
Vector2Int dir; Vector2Int dir;
Vector2Int destination; Vector2Int destination;
Vector2 velocity;
float time; float time;
float timer = 0; float timer = 0;
...@@ -19,29 +21,37 @@ public class JiJooMove : StateMachineBehaviour { ...@@ -19,29 +21,37 @@ public class JiJooMove : StateMachineBehaviour {
animatorRoot = animator.transform.parent; animatorRoot = animator.transform.parent;
enemy = animator.GetComponent<JiJoo>(); enemy = animator.GetComponent<JiJoo>();
player = GameManager.Instance.player; player = GameManager.Instance.player;
rb2D = enemy.transform.parent.GetComponent<Rigidbody2D>();
horizontalSpeed = enemy.horizontalSpeed; horizontalSpeed = enemy.horizontalSpeed;
verticalSpeed = enemy.verticalSpeed; verticalSpeed = enemy.verticalSpeed;
dir = enemy.MoveDirection(); dir = enemy.MoveDirection();
enemy.transform.eulerAngles = new Vector3(0, 0, JiJoo.Vector2ToZAngle(dir));
enemy.transform.parent.GetComponent<Rigidbody2D>().velocity = dir * new Vector2(horizontalSpeed, verticalSpeed);
destination = enemy.gridPosition + dir; destination = enemy.gridPosition + dir;
if (destination.x < 0 || destination.x >= 6 || destination.y < 0 || destination.y >= 6)
{
animator.SetTrigger("IdleTrigger");
return;
}
enemy.transform.eulerAngles = new Vector3(0, 0, JiJoo.Vector2ToZAngle(dir));
velocity = dir * new Vector2(horizontalSpeed, verticalSpeed);
Vector2 realVector = JiJoo.RealPosition(destination) - JiJoo.RealPosition(enemy.gridPosition); Vector2 realVector = JiJoo.RealPosition(destination) - JiJoo.RealPosition(enemy.gridPosition);
time = realVector.x / horizontalSpeed + realVector.y / verticalSpeed; time = Mathf.Abs(realVector.x) / horizontalSpeed + Mathf.Abs(realVector.y) / verticalSpeed;
timer = 0;
} }
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
if (timer > time) rb2D.MovePosition(rb2D.position + velocity * Time.deltaTime);
if (timer > time)
{ {
enemy.transform.parent.GetComponent<Rigidbody2D>().velocity = Vector2.zero; Debug.Log("end");
enemy.gridPosition = destination; enemy.gridPosition = destination;
enemy.transform.position = JiJoo.RealPosition(destination); enemy.transform.parent.transform.localPosition = JiJoo.RealPosition(destination);
animator.SetTrigger("IdleTrigger"); animator.SetTrigger("IdleTrigger");
} }
timer += Time.deltaTime;
} }
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
......
...@@ -25,7 +25,7 @@ public abstract class JiJoo : Boss { ...@@ -25,7 +25,7 @@ public abstract class JiJoo : Boss {
playerDirection = GameManager.Instance.player.transform.position - transform.position; playerDirection = GameManager.Instance.player.transform.position - transform.position;
bossRoom.transitionUpdate[0] += Phase1Transition; bossRoom.transitionUpdate[0] += Phase1Transition;
//transitionUpdate[1] += Phase2Transition; bossRoom.transitionUpdate[1] += Phase2Transition;
bossRoom.phaseUpdate[0] += Phase1; bossRoom.phaseUpdate[0] += Phase1;
//phaseUpdate[1] += Phase2; //phaseUpdate[1] += Phase2;
} }
...@@ -44,8 +44,8 @@ public abstract class JiJoo : Boss { ...@@ -44,8 +44,8 @@ public abstract class JiJoo : Boss {
protected void Phase1Transition() protected void Phase1Transition()
{ {
Debug.Log("aaa");
animator.runtimeAnimatorController = animators[bossRoom.CurPhase]; animator.runtimeAnimatorController = animators[bossRoom.CurPhase];
bossRoom.isTransitionFinished = true;
} }
protected void Phase2Transition() protected void Phase2Transition()
{ {
...@@ -60,6 +60,50 @@ public abstract class JiJoo : Boss { ...@@ -60,6 +60,50 @@ public abstract class JiJoo : Boss {
} }
public override void GetDamaged(PlayerAttackInfo attack)
{
if (Invisible) { return; }
float prevHealth = currHealth;
currHealth -= attack.damage;
if (currHealth <= 0)
{
Invisible = true;
animator.SetTrigger("DeadTrigger");
StopCoroutine("OnFire");
GetComponent<SpriteRenderer>().color = Color.white;
if (bossRoom.CurPhase == bossRoom.totalPhase - 1)
{
currHealth = 1;
}
}
DebuffApply(attack.debuffTime);
float knockbackDist = attack.damage * attack.knockBackMultiplier / weight;
float knockbackTime = (knockbackDist >= 0.5f) ? 0.5f : knockbackDist;
if (MovementLock) // 넉백이 진행 중
{
StopCoroutine("Knockback");
}
StartCoroutine(Knockback(knockbackDist, knockbackTime));
float currHealthPercentage = currHealth / maxHealth;
float prevHealthPercentage = prevHealth / maxHealth;
foreach (float percentage in knockbackPercentage)
{
if (currHealthPercentage > percentage) { break; }
if (prevHealthPercentage > percentage)
{
animator.SetTrigger("DamagedTrigger");
break;
}
}
animator.SetTrigger("TrackTrigger");
}
public abstract Vector2Int MoveDirection(); public abstract Vector2Int MoveDirection();
public IEnumerator Heal(float hp, float time) public IEnumerator Heal(float hp, float time)
...@@ -70,6 +114,7 @@ public abstract class JiJoo : Boss { ...@@ -70,6 +114,7 @@ public abstract class JiJoo : Boss {
yield return null; yield return null;
currHealth += (delta * t / time); currHealth += (delta * t / time);
} }
currHealth = hp;
} }
public static float Vector2ToZAngle(Vector2Int dir) public static float Vector2ToZAngle(Vector2Int dir)
......
...@@ -28,7 +28,7 @@ public class JiJooRoom : BossRoomInGame { ...@@ -28,7 +28,7 @@ public class JiJooRoom : BossRoomInGame {
protected void Phase1Transition() protected void Phase1Transition()
{ {
Debug.Log("come");
} }
protected void Phase2Transition() protected void Phase2Transition()
{ {
......
...@@ -75,7 +75,7 @@ public class BossRoomInGame : RoomInGame { ...@@ -75,7 +75,7 @@ public class BossRoomInGame : RoomInGame {
IEnumerator Phase(int phase) IEnumerator Phase(int phase)
{ {
isTransitionFinished = false; isTransitionFinished = false;
Debug.Log(transitionUpdate[phase].GetInvocationList().GetLength(0)); Debug.Log(transitionUpdate[phase].GetInvocationList().Length);
while (!isTransitionFinished) while (!isTransitionFinished)
{ {
if (transitionUpdate[phase] != null) if (transitionUpdate[phase] != null)
......
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