Ejemplo n.º 1
0
 public void FixedUpdate()
 {
     if (state == STATUS.CLOSING)
     {
         if (AnimationUtil.IsAnimationDone(animator, "StatusCardClose"))
         {
             state = STATUS.CLOSED;
             CloseEvent.Invoke(new StatusCardCloseEvent(unit));
             Destroy(gameObject);
         }
     }
 }
Ejemplo n.º 2
0
        public new void FixedUpdate()
        {
            base.FixedUpdate();

            switch (GetState())
            {
            case Unit.STATES.WALKING:
                if (Mathf.Abs(Velocity.x) == 0 && Mathf.Abs(Velocity.z) == 0)
                {
                    TrySetState(Unit.STATES.NEUTRAL);
                }
                break;

            case Unit.STATES.NEUTRAL:
                if (Mathf.Abs(Velocity.x) > 0 || Mathf.Abs(Velocity.z) > 0)
                {
                    TrySetState(Unit.STATES.WALKING);
                }
                break;

            case Unit.STATES.ATTACK:
                if (AnimationUtil.IsAnimationDone(animator, "PlayerAttack"))
                {
                    TrySetState(Unit.STATES.NEUTRAL);
                }
                break;

            case Unit.STATES.DAMAGE:
                if (!damageFlowStarted)
                {
                    damageFlowStarted = true;
                    StartCoroutine(DamageStateFlow());
                }
                break;
            }

            if (Dimension == Unit.DIMENSION.LEFT)
            {
                transform.localScale = new Vector3(-1, 1, 1);
            }
            else
            {
                transform.localScale = new Vector3(1, 1, 1);
            }
            UpdateAnimator();
        }
Ejemplo n.º 3
0
        public new void FixedUpdate()
        {
            base.FixedUpdate();
            switch (GetState())
            {
            case Unit.STATES.WALKING:
                if (enableAI)
                {
                    var plan = behaviourExecutor.Execute(gameContext, GetComponent <IUnit>());
                    plan?.Execute(gameContext, GetComponent <IUnit>());
                }
                if (Mathf.Abs(Velocity.x) == 0 && Mathf.Abs(Velocity.z) == 0)
                {
                    TrySetState(Unit.STATES.NEUTRAL);
                }
                break;

            case Unit.STATES.NEUTRAL:
                if (enableAI)
                {
                    var plan = behaviourExecutor.Execute(gameContext, GetComponent <IUnit>());
                    plan?.Execute(gameContext, GetComponent <IUnit>());
                }
                if (Mathf.Abs(Velocity.x) > 0 || Mathf.Abs(Velocity.z) > 0)
                {
                    TrySetState(Unit.STATES.WALKING);
                }
                break;

            case Unit.STATES.ATTACK:
                if (AnimationUtil.IsAnimationDone(animator, "Enemy02Attack"))
                {
                    TrySetState(Unit.STATES.NEUTRAL);
                }
                break;

            case Unit.STATES.DAMAGE:
                if (!damageFlowStarted)
                {
                    damageFlowStarted = true;
                    StartCoroutine(DamageStateFlow());
                }
                break;

            case Unit.STATES.DEAD:
                if (!deadFlowStarted)
                {
                    deadFlowStarted = true;
                    StartCoroutine(DeadStateFlow());
                }
                break;
            }

            if (Dimension == Unit.DIMENSION.LEFT)
            {
                transform.localScale = new Vector3(-1, 1, 1);
            }
            else
            {
                transform.localScale = new Vector3(1, 1, 1);
            }
            UpdateAnimator();
        }