Example #1
0
    private void Update()
    {
        if (Input.GetKey(KeyCode.W))
        {
            tankMovement.Move(Vector2.up);
        }
        else if (Input.GetKey(KeyCode.A))
        {
            tankMovement.Move(Vector2.left);
        }
        else if (Input.GetKey(KeyCode.D))
        {
            tankMovement.Move(Vector2.right);
        }
        else if (Input.GetKey(KeyCode.S))
        {
            tankMovement.Move(Vector2.down);
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            tankPlayer.PreviousWeapon();
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            tankPlayer.NextWeapon();
        }

        if (Input.GetMouseButton(0))
        {
            Vector2 mousePoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            tankPlayer.RotataTowerTo(mousePoint);
            tankPlayer.Fire();
        }
    }