Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!playerUnit)
        {
            return;
        }
        if (camera != null)
        {
            Vector3 v = camera.transform.position;
            v.x = playerUnit.transform.position.x;
            camera.transform.position = v;
        }

        if (Input.GetKey(KeyCode.Alpha1))
        {
            SelectWeapon(0);
        }
        else if (Input.GetKey(KeyCode.Alpha2))
        {
            SelectWeapon(1);
        }
        else if (Input.GetKey(KeyCode.Alpha3))
        {
            SelectWeapon(2);
        }
        else if (Input.GetKey(KeyCode.Alpha4))
        {
            SelectWeapon(3);
        }

        if (Input.GetKey(KeyCode.A))
        {
            playerUnit.Move(new Vector2(-2, 0));
            // playerUnit.ani.SetBool("isMoving", true);
        }
        else if (Input.GetKey(KeyCode.D))
        {
            playerUnit.Move(new Vector2(+2, 0));
            //playerUnit.ani.SetBool("isMoving", true);
        }
        else
        {
            playerUnit.Move(new Vector2(0, 0));
            //playerUnit.ani.SetBool("isMoving", false);
        }

        if (Input.GetMouseButton(0))
        {
            playerUnit.Shoot();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            playerUnit.Reload();
        }

        MagazineHUD_Change();
        playerUnit.Aiming(Camera.main.ScreenToWorldPoint(Input.mousePosition));
    }