Ejemplo n.º 1
0
    public void Update(PlayerInput.InputType inputType)
    {
        playerInput.CheckUI();

        bool updateMouse = true;

        switch (inputType)
        {
        case PlayerInput.InputType.MouseKeyboard:

            if (Input.GetButtonDown("Perspective1"))
            {
                updateMouse          = false;
                weapon.localRotation = Quaternion.identity;
                shootInput.ToggleActive();
                playerInput.PrepareMechPerspec();
            }
            for (int i = 0; i < otherSlots.Count; i++)
            {
                if (Input.GetButtonDown(otherSlotInputs[i]))
                {
                    updateMouse          = false;
                    weapon.localRotation = originalRotation;
                    playerInput.PrepareSlotPerspec(otherSlots[i]);
                    shootInput.ToggleActive();
                }
            }

            if (Input.GetButtonDown("Forward"))
            {
                driver.Accelerate();
            }
            if (Input.GetButtonDown("Backward"))
            {
                driver.Decelerate();
            }
            if (Input.GetButton("Left"))
            {
                driver.TurnLeft();
            }
            if (Input.GetButton("Right"))
            {
                driver.TurnRight();
            }
            if (Input.GetButton("ResetRotation"))
            {
                driver.ResetRotation();
            }
            if (Input.GetButtonDown("Jump"))
            {
                driver.jump();
            }

            if (Input.GetButtonDown("Shield"))
            {
                driver.shield();
            }

            break;

        case PlayerInput.InputType.Controller:

            if (Input.GetButtonDown("Cancel"))
            {
                updateMouse          = false;
                weapon.localRotation = Quaternion.identity;
                shootInput.ToggleActive();
                playerInput.PrepareMechPerspec();
            }
            for (int i = 0; i < otherSlots.Count; i++)
            {
                if (Input.GetButtonDown(otherSlotInputs[i]))
                {
                    updateMouse          = false;
                    weapon.localRotation = originalRotation;
                    playerInput.PrepareSlotPerspec(otherSlots[i]);
                    shootInput.ToggleActive();
                }
            }

            float xPad = Input.GetAxis("Plus Pad X");
            float yPad = Input.GetAxis("Plus Pad Y");

            int select = -1;

            if (yPad > 0)       // front mod
            {
                select = 0;
            }
            else if (xPad < 0)         // left mod
            {
                select = 1;
            }
            else if (xPad > 0)         // right mod
            // select = 2;
            {
            }
            else if (yPad < 0)         // back mod
            // select = 3;
            {
            }

            if (select >= 0 && select != lastKeyIndex)
            {
                updateMouse          = false;
                weapon.localRotation = originalRotation;
                playerInput.PrepareSlotPerspec(playerInput.slots[select]);
                shootInput.ToggleActive();
            }

            break;
        }

        if (Input.GetButton("Fire1"))
        {
            shootInput.Shoot();
        }

        if (updateMouse)
        {
            mouseInput.Update(inputType);
        }
    }
Ejemplo n.º 2
0
    public void Update(PlayerInput.InputType inputType)
    {
        playerInput.CheckUI();

        switch (inputType)
        {
        case PlayerInput.InputType.MouseKeyboard:

            if (Input.GetButtonDown("Perspective1"))
            {
                playerInput.PrepareMechPerspec();
            }
            for (int i = 0; i < otherSlots.Count; i++)
            {
                if (Input.GetButtonDown(otherSlotInputs[i]))
                {
                    playerInput.PrepareSlotPerspec(otherSlots[i]);
                }
            }

            if (Input.GetButtonDown("RightClick"))
            {
                Ray        ray = playerInput.CreateRayFromMouseClick();
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, 50f))
                {
                    if (hit.collider.gameObject.tag == "Mech")
                    {
                        GameObject hitEffect = hitEffectPool.GetObject();
                        hitEffect.transform.position = hit.point;
                        hitEffect.transform.rotation = Quaternion.identity;
                        hitEffect.SetActive(true);

                        hit.collider.gameObject.GetComponent <DamageOverNetwork>().HealPlayer(1, hit.collider.gameObject.name, playerInput.transform.GetComponent <NetworkIdentity>());
                    }
                }
            }

            if (Input.GetButtonDown("Left Click"))
            {
                playerInput.SetDragOrigin();
            }

            if (Input.GetButton("Left Click"))
            {
                playerInput.DragCamera();
            }

            if (Input.GetButtonDown("Forward"))
            {
                driver.Accelerate();
            }
            if (Input.GetButtonDown("Backward"))
            {
                driver.Decelerate();
            }
            if (Input.GetButton("Left"))
            {
                driver.TurnLeft();
            }
            if (Input.GetButton("Right"))
            {
                driver.TurnRight();
            }
            if (Input.GetButton("ResetRotation"))
            {
                driver.ResetRotation();
            }
            if (Input.GetButtonDown("Jump"))
            {
                driver.jump();
            }

            if (Input.GetButtonDown("Shield"))
            {
                driver.shield();
            }

            break;

        case PlayerInput.InputType.Controller:

            if (Input.GetButtonDown("Cancel"))
            {
                playerInput.PrepareMechPerspec();
            }
            for (int i = 0; i < otherSlots.Count; i++)
            {
                if (Input.GetButtonDown(otherSlotInputs[i]))
                {
                    playerInput.PrepareSlotPerspec(otherSlots[i]);
                }
            }

            float xPad = Input.GetAxis("Plus Pad X");
            float yPad = Input.GetAxis("Plus Pad Y");

            int select = -1;

            if (yPad > 0)
            {     // front mod
                select = 0;
            }
            else if (xPad < 0)
            {     // left mod
                select = 1;
            }
            else if (xPad > 0)
            {     // right mod
                  // select = 2;
            }
            else if (yPad < 0)
            {     // back mod
                  // select = 3;
            }

            if (select >= 0 && select != lastKeyIndex)
            {
                playerInput.PrepareSlotPerspec(playerInput.slots[select]);
            }

            break;
        }
    }
Ejemplo n.º 3
0
    public void Update(PlayerInput.InputType inputType)
    {
        if (Input.GetButtonDown("Escape"))
        {
            //playerInput.ToggleMenu();
        }

        switch (inputType)
        {
        case PlayerInput.InputType.MouseKeyboard:

            if (Input.GetButtonDown("Perspective1"))
            {
                playerInput.PrepareMechPerspec();
            }
            for (int i = 0; i < otherSlots.Count; i++)
            {
                if (Input.GetButtonDown(otherSlotInputs[i]))
                {
                    playerInput.PrepareSlotPerspec(otherSlots[i]);
                }
            }

            if (Input.GetButtonDown("Forward"))
            {
                driver.Accelerate();
            }
            if (Input.GetButtonDown("Backward"))
            {
                driver.Decelerate();
            }
            if (Input.GetButton("Left"))
            {
                driver.TurnLeft();
            }
            if (Input.GetButton("Right"))
            {
                driver.TurnRight();
            }
            if (Input.GetButton("ResetRotation"))
            {
                driver.ResetRotation();
            }
            if (Input.GetButtonDown("Jump"))
            {
                driver.jump();
            }

            if (Input.GetButtonDown("Shield"))
            {
                driver.shield();
            }

            break;

        case PlayerInput.InputType.Controller:

            if (Input.GetButtonDown("Cancel"))
            {
                playerInput.PrepareMechPerspec();
            }
            for (int i = 0; i < otherSlots.Count; i++)
            {
                if (Input.GetButtonDown(otherSlotInputs[i]))
                {
                    playerInput.PrepareSlotPerspec(otherSlots[i]);
                }
            }

            float xPad = Input.GetAxis("Plus Pad X");
            float yPad = Input.GetAxis("Plus Pad Y");

            int select = -1;

            if (yPad > 0)
            {     // front mod
                select = 0;
            }
            else if (xPad < 0)
            {     // left mod
                select = 1;
            }
            else if (xPad > 0)
            {     // right mod
                  // select = 2;
            }
            else if (yPad < 0)
            {     // back mod
                  // select = 3;
            }

            if (select >= 0 && select != lastKeyIndex)
            {
                playerInput.PrepareSlotPerspec(playerInput.slots[select]);
            }

            break;
        }

        if (Input.GetButton("Fire1"))
        {
            mineDeployer.DeployMine();
        }
    }
Ejemplo n.º 4
0
    public void Update(PlayerInput.InputType inputType)
    {
        playerInput.CheckUI();

        switch (inputType)
        {
        case PlayerInput.InputType.MouseKeyboard:

            for (int i = 0; i < slots.Count; i++)
            {
                if (Input.GetButtonDown(slotInputs[i]))
                {
                    playerInput.PrepareSlotPerspec(slots[i]);
                }
            }

            if (Input.GetButtonDown("Forward"))
            {
                driver.Accelerate();
            }
            if (Input.GetButtonDown("Backward"))
            {
                driver.Decelerate();
            }
            if (Input.GetButton("Left"))
            {
                driver.TurnLeft();
            }
            if (Input.GetButton("Right"))
            {
                driver.TurnRight();
            }

            if (Input.GetButton("ResetRotation"))
            {
                driver.ResetRotation();
            }

            if (Input.GetButtonDown("Jump"))
            {
                driver.jump();
            }

            if (Input.GetButtonDown("Shield"))
            {
                driver.shield();
            }

            if (Input.GetButtonDown("Left Click"))
            {
                playerInput.SetDragOrigin();
            }

            if (Input.GetButton("Left Click"))
            {
                playerInput.DragCamera();
            }

            if (Input.GetButtonUp("Left Click"))
            {
                playerInput.UnDragCamera();
            }

            break;

        case PlayerInput.InputType.Controller:

            float xPad = Input.GetAxis("Plus Pad X");
            float yPad = Input.GetAxis("Plus Pad Y");

            if (yPad > 0)
            {     // front mod
                playerInput.PrepareSlotPerspec(slots[0]);
            }
            else if (xPad < 0)
            {     // left mod
                playerInput.PrepareSlotPerspec(slots[1]);
            }
            else if (xPad > 0)
            {     // right mod
                  //playerInput.PrepareWeaponPerspec(weapons[2]);
            }
            else if (yPad < 0)
            {     // back mod
                  //playerInput.PrepareWeaponPerspec(weapons[3]);
            }

            float xAxis = Input.GetAxis("Left Stick X");
            float yAxis = Input.GetAxis("Left Stick Y");

            if (ignoreStick)
            {
                if (yAxis > -0.1f && yAxis < 0.1f)
                {
                    ignoreStick = false;
                }
            }
            else
            {
                if (yAxis > 0)
                {
                    driver.Accelerate();
                    ignoreStick = true;
                }
                if (yAxis < 0)
                {
                    driver.Decelerate();
                    ignoreStick = true;
                }
            }

            if (xAxis < 0)
            {
                driver.TurnLeft();
            }
            if (xAxis > 0)
            {
                driver.TurnRight();
            }

            float xLook = Input.GetAxis("Right Stick X");
            if (xLook != 0.0f)
            {
                playerInput.RotateCamera(xLook);
            }

            break;
        }
    }