Ejemplo n.º 1
0
    void Start()
    {
        m_playerScript = m_player.GetComponent <PlayerScript>();
        m_frontScript  = m_frontSprite.GetComponent <SpriteScript>();
        m_backScript   = m_backSprite.GetComponent <SpriteScript>();
        m_rightScript  = m_rightSprite.GetComponent <SpriteScript>();
        m_leftScript   = m_leftSprite.GetComponent <SpriteScript>();

        m_lastState = m_playerScript.m_state;

        m_frontScript.PlayNext(SpriteScript.Sprite.FrontIdle, false);
        m_backScript.PlayNext(SpriteScript.Sprite.SideBackIdle, false);
        m_rightScript.PlayNext(SpriteScript.Sprite.SideFrontIdle, false);
        m_leftScript.PlayNext(SpriteScript.Sprite.SideBackIdle, false);
    }
Ejemplo n.º 2
0
    void UpdateState()
    {
        switch (m_playerScript.m_state)
        {
        case PlayerScript.State.Idle:
        {
            m_frontScript.PlayNext(SpriteScript.Sprite.FrontIdle, false);
            m_backScript.PlayNext(SpriteScript.Sprite.SideBackIdle, false);

            if (m_lastState == PlayerScript.State.Right)
            {
                m_rightScript.PlayNext(SpriteScript.Sprite.SideFrontIdle, false);
                m_leftScript.PlayNext(SpriteScript.Sprite.SideBackIdle, false);
            }
            if (m_lastState == PlayerScript.State.Left)
            {
                m_rightScript.PlayNext(SpriteScript.Sprite.SideBackIdle, false);
                m_leftScript.PlayNext(SpriteScript.Sprite.SideFrontIdle, false);
            }
            break;
        }

        case PlayerScript.State.Right:
        {
            if (m_playerScript.m_speedBoost != 0f)
            {
                m_frontScript.PlayNext(SpriteScript.Sprite.FrontRunEscape);
                m_backScript.PlayNext(SpriteScript.Sprite.FrontRunEscape);
            }
            else
            {
                m_frontScript.PlayNext(SpriteScript.Sprite.FrontRun);
                m_backScript.PlayNext(SpriteScript.Sprite.FrontRun);
            }

            m_rightScript.PlayNext(SpriteScript.Sprite.SideFrontRun);
            m_leftScript.PlayNext(SpriteScript.Sprite.SideBackRun);

            m_frontScript.ReverseSprite(false);
            m_backScript.ReverseSprite(true);
            m_rightScript.ReverseSprite(false);
            m_leftScript.ReverseSprite(false);

            m_lastState = PlayerScript.State.Right;
            break;
        }

        case PlayerScript.State.Left:
        {
            if (m_playerScript.m_speedBoost != 0f)
            {
                m_frontScript.PlayNext(SpriteScript.Sprite.FrontRunEscape);
                m_backScript.PlayNext(SpriteScript.Sprite.FrontRunEscape);
            }
            else
            {
                m_frontScript.PlayNext(SpriteScript.Sprite.FrontRun);
                m_backScript.PlayNext(SpriteScript.Sprite.FrontRun);
            }

            m_rightScript.PlayNext(SpriteScript.Sprite.SideBackRun);
            m_leftScript.PlayNext(SpriteScript.Sprite.SideFrontRun);

            m_frontScript.ReverseSprite(true);
            m_backScript.ReverseSprite(false);
            m_rightScript.ReverseSprite(true);
            m_leftScript.ReverseSprite(true);

            m_lastState = PlayerScript.State.Left;
            break;
        }

        case PlayerScript.State.Jump:
        {
            m_frontScript.PlayNext(SpriteScript.Sprite.FrontDash, true);
            m_backScript.PlayNext(SpriteScript.Sprite.BackDash, true);
            m_rightScript.PlayNext(SpriteScript.Sprite.SideDash, true);
            m_leftScript.PlayNext(SpriteScript.Sprite.SideDash, true);

            m_frontScript.ReverseSprite(false);
            m_backScript.ReverseSprite(false);
            m_rightScript.ReverseSprite(true);
            m_leftScript.ReverseSprite(false);
            break;
        }

        case PlayerScript.State.Stun:
        {
            m_frontScript.PlayNext(SpriteScript.Sprite.FrontFall, false);
            m_backScript.PlayNext(SpriteScript.Sprite.SideBackFall, false);
            if (m_lastState == PlayerScript.State.Right)
            {
                m_rightScript.PlayNext(SpriteScript.Sprite.SideBackFall, false);
                m_leftScript.PlayNext(SpriteScript.Sprite.FrontFall, false);
            }
            else
            {
                m_rightScript.PlayNext(SpriteScript.Sprite.FrontFall, false);
                m_leftScript.PlayNext(SpriteScript.Sprite.SideBackFall, false);
            }
            break;
        }
        }
    }