コード例 #1
0
        public void ButtonHold(GameObject gameObject)
        {
            ADSR = gameObject.GetComponent <ADSRManager>();
            var Movement = ADSR.GetDirection();

            gameObject.GetComponent <SpriteRenderer>().flipX = false;

            // if statement fixes bug that caused player to be in None state when switching directions mid-jump
            // Changing to the None state prevented the player from moving in the opposite direction on the same button hold
            if (ADSRManager.Direction.None == Movement)
            {
                ADSR.ResetTimers();
                ADSR.SetPhase(ADSRManager.Phase.Attack);
                ADSR.SetInputDirection(Time.deltaTime);

                // Sets direction to know that player is moving.
                ADSR.SetDirection(ADSRManager.Direction.Horizontal);
            }
            ADSR = gameObject.GetComponent <ADSRManager>();

            if (ADSR.getInputDirection() <= -0.7f)
            {
                ADSR.SetInputDirection(0.3f);
            }
            ADSR.SetInputDirection(Time.deltaTime);
        }
コード例 #2
0
ファイル: MovePlayerLeft.cs プロジェクト: towoknee/RIP-1
        public void ButtonDown(GameObject gameObject)
        {
            ADSR = gameObject.GetComponent <ADSRManager>();
            var Movement = ADSR.GetDirection();

            if (ADSRManager.Direction.None == Movement)
            {
                ADSR.ResetTimers();
                ADSR.SetPhase(ADSRManager.Phase.Attack);
                ADSR.SetInputDirection(-Time.deltaTime);

                // Sets direction to know that player is moving.
                ADSR.SetDirection(ADSRManager.Direction.Horizontal);
            }

            gameObject.GetComponent <SpriteRenderer>().flipX = true;
        }