Esempio n. 1
0
    void FixedUpdate()
    {
        if (mControl != null)
        {
            if (CrossPlatformInputManager.GetButton("Left") || Input.GetKey(moveLeft))
            {
                mControl.MoveLeft();
            }
            else if (CrossPlatformInputManager.GetButton("Right") || Input.GetKey(moveRight))
            {
                mControl.MoveRight();
            }
            else
            {
                mControl.Idle();
            }

            if (CrossPlatformInputManager.GetButton("Jump") || Input.GetKey(jump))
            {
                mControl.Jump();
            }

            if (CrossPlatformInputManager.GetButton("Shoot") || Input.GetKey(shoot))
            {
                mControl.Shoot();
            }
        }
    }
Esempio n. 2
0
    private void CheckShooting()
    {
        if (mControl.currentPower != null)
        {
            if (Vector2.Distance(player.transform.position, transform.position) < shootingDistance)
            {
                int facingDirToPlayer = (int)player.transform.position.x - (int)transform.position.x;
                if (facingDirToPlayer < 0)
                {
                    facingDirToPlayer = -1;
                }
                else
                {
                    facingDirToPlayer = 1;
                }

                if (mControl.GetFacingDir() == facingDirToPlayer)
                {
                    mControl.Shoot();
                }
            }
        }
    }