Example #1
0
    //TODO
    //instead of the current style of menu do this
    //-

    void Awake()
    {
        p1Plane    = Player.PlaneType.GRIFFON;
        p2Plane    = Player.PlaneType.WASP;
        p1Input    = PlayerInput.InputType.KEYBOARD;
        p2Input    = PlayerInput.InputType.GAMEPAD1;
        difficulty = GameDifficulty.DifficultyLevel.NORMAL;
        stage      = LevelLoader.Stage.DEBUG;
        SetVariablesToTextFields();
        planes       = GetPlanes();
        inputs       = GetInputs();
        stages       = GetStages();
        difficulties = GetDifficulties();
    }
Example #2
0
    void InstantiateAndInitializePlayer(int playerNumber, out Player player)
    {
        GameObject playerObject = Instantiate(playerPrefab) as GameObject;
        char       numberChar   = playerNumber.ToString().ToCharArray()[0];
        string     inputKey     = "game_p#_input".Replace('#', numberChar);
        string     planeKey     = "game_p#_plane".Replace('#', numberChar);

        PlayerInput.InputType input = PlayerInput.ParseInputType(PlayerPrefManager.GetString(inputKey));
        Player.PlaneType      plane = Player.ParsePlaneType(PlayerPrefManager.GetString(planeKey));
        playerObject.name = "Player " + playerNumber + " (" + plane.ToString() + ", " + input.ToString() + ")";
        player            = playerObject.GetComponent <Player>();
        player.Initialize(input, plane);
        player.SetFurtherInitData(playerNumber, this, gui.ActivateAndGetPlayerGUI(playerNumber), playArea, levelTrackFollower);
        player.transform.parent = playArea.transform;
    }
Example #3
0
    public void Initialize(PlayerInput.InputType inputType, PlaneType planeType)
    {
        playerInput = PlayerInput.Get(inputType);
        playerMovementSystem.playerInput = playerInput;
        playerWeaponSystem.playerInput   = playerInput;
        GameObject modelObject;
        GameObject SPWObject;

        switch (planeType)
        {
        case PlaneType.SPECTRE:
            modelObject = InstantiatePrefabAsChild(spectrePlanePrefab);
            SPWObject   = InstantiatePrefabAsChild(spectreSPWPrefab);
            break;

        case PlaneType.WASP:
            modelObject = InstantiatePrefabAsChild(waspPlanePrefab);
            SPWObject   = InstantiatePrefabAsChild(waspSPWPrefab);
            break;

        case PlaneType.GRIFFON:
            modelObject = InstantiatePrefabAsChild(griffonPlanePrefab);
            SPWObject   = InstantiatePrefabAsChild(griffonSPWPrefab);
            break;

        case PlaneType.RAZORBACK:
            modelObject = InstantiatePrefabAsChild(razorbackPlanePrefab);
            SPWObject   = InstantiatePrefabAsChild(razorbackSPWPrefab);
            break;

        default:
            throw new UnityException("unknown plane type");
        }
        this.planeType = planeType;
        playerModel    = modelObject.GetComponent <PlayerModel>();
        playerMovementSystem.playerModel = playerModel;
        playerWeaponSystem.playerModel   = playerModel;
        playerHealthSystem.playerModel   = playerModel;
        playerDeathSystem.playerModel    = playerModel;
        PlayerSpecialWeapon playerSPW = SPWObject.GetComponent <PlayerSpecialWeapon>();

        playerWeaponSystem.specialWeapon = playerSPW;
    }
Example #4
0
 public void Update(PlayerInput.InputType input)
 {
 }
Example #5
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);
        }
    }
Example #6
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();
        }
    }
Example #7
0
 public void CycleCPP2Input()
 {
     p2Input = NextFromArray <PlayerInput.InputType>(p2Input, inputs);
     coopP2InputText.text = p2Input.ToString();
     UpdateGameReadiness();
 }
Example #8
0
    public void Update(PlayerInput.InputType inputType)
    {
        if (axes == RotationAxes.MouseXAndY)
        {
            rotAverageY = 0f;
            rotAverageX = 0f;

            if (inputType == PlayerInput.InputType.Controller)
            {
                rotationY += Input.GetAxis("Right Stick Y") * stickSensitivityY;
                rotationX += Input.GetAxis("Right Stick X") * stickSensitivityX;
            }
            else
            {
                rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
                rotationX += Input.GetAxis("Mouse X") * sensitivityX;
            }

            rotArrayY.Add(rotationY);
            rotArrayX.Add(rotationX);

            if (rotArrayY.Count >= frameCounter)
            {
                rotArrayY.RemoveAt(0);
            }
            if (rotArrayX.Count >= frameCounter)
            {
                rotArrayX.RemoveAt(0);
            }

            for (int j = 0; j < rotArrayY.Count; j++)
            {
                rotAverageY += rotArrayY[j];
            }
            for (int i = 0; i < rotArrayX.Count; i++)
            {
                rotAverageX += rotArrayX[i];
            }

            rotAverageY /= rotArrayY.Count;
            rotAverageX /= rotArrayX.Count;

            rotAverageY = ClampAngle(rotAverageY, minimumY, maximumY);
            rotAverageX = ClampAngle(rotAverageX, minimumX, maximumX);

            Quaternion yQuaternion = Quaternion.AngleAxis(rotAverageY, Vector3.left);
            Quaternion xQuaternion = Quaternion.AngleAxis(rotAverageX, Vector3.up);

            weapon.localRotation = originalRotation * xQuaternion * yQuaternion;
        }
        else if (axes == RotationAxes.MouseX)
        {
            rotAverageX = 0f;

            if (inputType == PlayerInput.InputType.Controller)
            {
                rotationX += Input.GetAxis("Right Stick X") * stickSensitivityX;
            }
            else
            {
                rotationX += Input.GetAxis("Mouse X") * sensitivityX;
            }

            rotArrayX.Add(rotationX);

            if (rotArrayX.Count >= frameCounter)
            {
                rotArrayX.RemoveAt(0);
            }
            for (int i = 0; i < rotArrayX.Count; i++)
            {
                rotAverageX += rotArrayX[i];
            }
            rotAverageX /= rotArrayX.Count;

            rotAverageX = ClampAngle(rotAverageX, minimumX, maximumX);

            Quaternion xQuaternion = Quaternion.AngleAxis(rotAverageX, Vector3.up);
            weapon.localRotation = originalRotation * xQuaternion;
        }
        else
        {
            rotAverageY = 0f;

            if (inputType == PlayerInput.InputType.Controller)
            {
                rotationY += Input.GetAxis("Right Stick Y") * stickSensitivityY;
            }
            else
            {
                rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
            }

            rotArrayY.Add(rotationY);

            if (rotArrayY.Count >= frameCounter)
            {
                rotArrayY.RemoveAt(0);
            }
            for (int j = 0; j < rotArrayY.Count; j++)
            {
                rotAverageY += rotArrayY[j];
            }
            rotAverageY /= rotArrayY.Count;

            rotAverageY = ClampAngle(rotAverageY, minimumY, maximumY);

            Quaternion yQuaternion = Quaternion.AngleAxis(rotAverageY, Vector3.left);
            weapon.localRotation = originalRotation * yQuaternion;
        }
    }
Example #9
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;
        }
    }
Example #10
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;
        }
    }