private void GameControls()
    {
        if (Input.GetButton(GetButton(Button.left)))
        {
            controls.Charge(NavControl.Cannons.left);
        }
        if (Input.GetButton(GetButton(Button.right)))
        {
            controls.Charge(NavControl.Cannons.right);
        }
        if (Input.GetButtonUp(GetButton(Button.left)))
        {
            controls.Shot(NavControl.Cannons.left);
        }
        if (Input.GetButtonUp(GetButton(Button.right)))
        {
            controls.Shot(NavControl.Cannons.right);
        }

        // Androd touch controls
        if (Input.touches.Length >= 1)
        {
            for (int i = 0; i < Input.touches.Length; i++)
            {
                Touch t = Input.touches[i];

                if (t.phase == TouchPhase.Stationary || t.phase == TouchPhase.Moved)
                {
                    if (TouchButton(player, Button.left, t.position))
                    {
                        controls.Charge(NavControl.Cannons.left);
                    }
                    if (TouchButton(player, Button.right, t.position))
                    {
                        controls.Charge(NavControl.Cannons.right);
                    }
                }
                if (t.phase == TouchPhase.Ended)
                {
                    if (TouchButton(player, Button.left, t.position))
                    {
                        controls.Shot(NavControl.Cannons.left);
                    }
                    if (TouchButton(player, Button.right, t.position))
                    {
                        controls.Shot(NavControl.Cannons.right);
                    }
                }
            }
        }
    }
Beispiel #2
0
    private void ButtonDown(Button bt)
    {
        switch (bt)
        {
        case Button.right:
            controls.Charge(NavControl.Cannons.right);
            Buttons["Right"][0] -= Time.deltaTime;
            break;

        case Button.left:
            controls.Charge(NavControl.Cannons.left);
            Buttons["Left"][0] -= Time.deltaTime;
            break;
        }
    }