Exemplo n.º 1
0
    public void DoUpdate(FsmFrameInfo state, ControlManager c, ref EnemyFrameInfo frameInfo)
    {
        this.frameInfo = frameInfo;
        if (frameInfo.damageInfo != null)
        {
            Damage(frameInfo.damageInfo);
        }

        if (state.hasChanged)
        {
            if (state.curr == AnimStates.ATTACK1)
            {
                frameInfo.isAttacking = true;
                if (c.isMoved)
                {
                    Face(c.move);
                }
            }
            else if (state.curr == AnimStates.ATTACK2)
            {
                frameInfo.isAttacking = true;
                if (c.isMoved)
                {
                    Face(c.move);
                }
            }
            else if (state.curr == AnimStates.ATTACK3)
            {
                frameInfo.isAttacking = true;
                if (c.isMoved)
                {
                    Face(c.move);
                }
            }
            else if (state.curr == AnimStates.CHARGEATTACK)
            {
                frameInfo.isChargeAttacking = true;
                if (c.isMoved)
                {
                    Face(c.move);
                }
            }
        }

        if (state.curr == AnimStates.IDLE)
        {
            if (c.isMoved)
            {
                Walk(c.move);
            }
        }
        else if (state.curr == AnimStates.WALK)
        {
            if (c.isMoved)
            {
                Walk(c.move);
            }
        }
    }
Exemplo n.º 2
0
    private void Awake()
    {
        fsm            = GetComponent <Animator>();
        player         = GetComponent <Player>();
        playerAnimator = GetComponent <PlayerAnimator>();
        playerAudio    = GetComponent <PlayerAudio>();

        state     = new FsmFrameInfo(AnimStates.ENTRY);
        frameInfo = new PlayerFrameInfo();

        GameManager manager = Toolbox.GetOrAddComponent <GameManager>();

        manager.RegisterPlayer(this);
#if UNITY_EDITOR
        state.DebugInit(fsm);
#endif
    }
Exemplo n.º 3
0
    public void DoUpdate(FsmFrameInfo state, ControlManager c, ref PlayerFrameInfo frameInfo)
    {
        this.frameInfo = frameInfo;
        if (frameInfo.damageInfo != null)
        {
            Damage(frameInfo.damageInfo);
        }

        if (state.hasChanged)
        {
            if (state.prev == AnimStates.ROLL)
            {
                StopRoll();
            }

            if (state.curr == AnimStates.ATTACK1)
            {
                frameInfo.isAttacking = true;
                ResetCharge();
                if (c.isMoved)
                {
                    Face(c.move);
                }
            }
            else if (state.curr == AnimStates.ATTACK2)
            {
                frameInfo.isAttacking = true;
                ResetCharge();
                if (c.isMoved)
                {
                    Face(c.move);
                }
            }
            else if (state.curr == AnimStates.ATTACK3)
            {
                frameInfo.isAttacking = true;
                ResetCharge();
                if (c.isMoved)
                {
                    Face(c.move);
                }
            }
            else if (state.curr == AnimStates.CHARGEATTACK)
            {
                frameInfo.isChargeAttacking = true;
                ResetCharge();
                if (c.isMoved)
                {
                    Face(c.move);
                }
            }
            else if (state.curr == AnimStates.ROLL)
            {
                if (c.isMoved)
                {
                    StartRoll(c.move);
                }
                else
                {
                    StartRoll(FaceDir);
                }
            }
        }

        if (state.curr == AnimStates.IDLE)
        {
            if (c.isAttackHeld)
            {
                AddCharge(Time.deltaTime);
            }
            if (c.isMoved)
            {
                Walk(c.move);
            }
            if (c.isAttackReleased)
            {
                if (IsFullyCharged)
                {
                    frameInfo.toChargeAttack = true;
                }
                else if (IsCharging)
                {
                    frameInfo.toAttack = true;
                }
                ResetCharge();
            }
        }
        else if (state.curr == AnimStates.WALK)
        {
            if (c.isAttackHeld)
            {
                AddCharge(Time.deltaTime);
            }
            if (c.isMoved)
            {
                Walk(c.move);
            }
            if (c.isAttackReleased)
            {
                if (IsFullyCharged)
                {
                    frameInfo.toChargeAttack = true;
                }
                else if (IsCharging)
                {
                    frameInfo.toAttack = true;
                }
                ResetCharge();
            }
        }
        else if (state.curr == AnimStates.ROLL)
        {
            mover.UpdateVelocity();
        }
    }