Ejemplo n.º 1
0
        private void Update()
        {
            // Stop Update on Game Wait
            if (StateController.Instance.currentState != States.GAME_UPDATE)
            {
                mainBody.velocity = Vector2.zero;
                if (animControl)
                {
                    animControl.ChangeState("Idle");
                }
                else
                {
                    print("NO ANIMATION CONTROL");
                }
                return;
            }


            // Input
            InputData currentInput = new InputData();

            // Actions
            DuelController(ref currentInput, playerNumber);
            InputGunFire(mainGun, currentInput.justPressedA);
            MoveCharacter(mainBody, currentInput, this.transform);
        }
Ejemplo n.º 2
0
        private void FlipWalkAnimation()
        {
            int currentAnimation = current % 2;

            string[] animStates = { "Walk_Left", "Walk_Right" };

            animControl.ChangeState(animStates[currentAnimation]);
        }
Ejemplo n.º 3
0
        // Start is called before the first frame update
        void Start()
        {
            // Auto-Get from the same GameObject
            rb2D        = GetComponent <Rigidbody2D>();
            pSnap       = GetComponent <PositionSnap>();
            animControl = GetComponent <AnimationControl2D>();

            // Set Start Animation
            animControl.ChangeState("WalkRight");
        }
Ejemplo n.º 4
0
        /**
         * Execute Run Movement
         **/
        private void RunMovement()
        {
            // Update position -> Auto Walk
            rb2D.position += runDirection * runSpeed * Time.deltaTime;

            // Update Animation
            if (runDirection == Vector2.up)
            {
                animControl.ChangeState("WalkUp");
            }
            else if (runDirection == Vector2.down)
            {
                animControl.ChangeState("WalkDown");
            }
            else if (runDirection == Vector2.left)
            {
                animControl.ChangeState("WalkLeft");
            }
            else if (runDirection == Vector2.right)
            {
                animControl.ChangeState("WalkRight");
            }
            else if (runDirection == Vector2.zero)
            {
                animControl.ChangeState("Idle");
            }
        }
Ejemplo n.º 5
0
        void Update()
        {
            // End Update If not In Update
            if (ChickenLevelManager.instance.currentState != GAME_STATE.UPDATE)
            {
                return;
            }


            //Update Timers
            if (!stuned)
            {
                eggTimer.Update();
            }
            if (stuned)
            {
                stunTimer.Update();
            }

            // Play Stunned Animation
            if (stuned)
            {
                animControl.ChangeState("Stun");
            }

            // Return if stunned
            if (stuned)
            {
                return;
            }

            // Drop Score
            if (minScore < currentPickScore)
            {
                UpdatePickScore();
            }

            // Check each Direction
            RaycastHit2D hitWall = Physics2D.Raycast(transform.position, runDirection, hitWallReach);

            if (hitWall)
            {
                if (hitWall.collider.GetComponent <Wall>())
                {
                    //Get new Direction // Invert Direction
                    ChangeRunDirection(-runDirection);
                }
            }

            // Execute Movement
            RunMovement();
        }