Example #1
0
        //Update is called once per frame
        void Update()
        {
            if (player == null)
            {
                player = GameControl.GetPlayer();
                if (player == null)
                {
                    return;
                }
            }

            if (player.IsDestroyed())
            {
                return;
            }

            if (joystickMove.GetMagnitude() > 0)
            {
                player.Move(joystickMove.GetValue());
            }
            if (joystickAim.GetMagnitude() > 0)
            {
                player.AimTurretDPad(joystickAim.GetValue());
                player.FireWeapon();
            }
        }
Example #2
0
        void Update()
        {
            if (!enableMouseNKeyInput)
            {
                return;
            }

            if (Input.GetButtonDown("Cancel") || Input.GetKeyDown(KeyCode.Escape) && !GameControl.IsGameOver())
            {
                _TogglePause();
            }
            //if(Input.GetKeyDown(KeyCode.C) && !GameControl.IsGameOver()) ToggleLevelPerkMenu();

            /*
             * if(Input.GetKeyDown(KeyCode.Q)){
             *      Debug.Log("Paused for screen shot. Fire from UIMainControl");
             *      if(Time.timeScale==1) Time.timeScale=0;
             *      else Time.timeScale=1;
             * }
             */

            if (GameControl.IsGamePlaying())
            {
                UnitPlayer player = GameControl.GetPlayer();
                if (player != null && !player.IsDestroyed() && Input.touchCount == 0)
                {
                    //Debug.Log("Fire!!  "+Time.time);

                    //movement
                    if (Input.GetButton("Horizontal") || Input.GetButton("Vertical"))
                    {
                        player.Move(new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")), Input.GetKey(KeyCode.LeftShift));
                    }

                    //brake
                    if (Input.GetKey(KeyCode.Space))
                    {
                        player.Brake();
                    }

                    //switch weapon
                    if (Input.GetAxisRaw("Mouse ScrollWheel") != 0 && scrollCD <= 0)
                    {
                        player.ScrollWeapon(Input.GetAxis("Mouse ScrollWheel") > 0 ? 1 : -1);
                        scrollCD = 0.15f;
                    }
                    scrollCD -= Time.deltaTime;

                    string[] names       = Input.GetJoystickNames();
                    bool     hasJoystick = names.Length > 0 ? true : false;

                    //turret facing
                    //player.AimTurretMouse(Input.mousePosition);
                    //player.AimTurretDPad(Input.mousePosition-new Vector3(Screen.width/2, Screen.height/2));
                    if (Input.GetButton("RightThumbStick_X") || Input.GetButton("RightThumbStick_Y"))
                    {
                        player.AimTurretDPad(new Vector2(Input.GetAxisRaw("RightThumbStick_X"), Input.GetAxisRaw("RightThumbStick_Y")));
                    }
                    else if (!hasJoystick)
                    {
                        player.AimTurretMouse(Input.mousePosition);
                    }

                    //fire
                    bool continousFire = player.ContinousFire() & (Input.GetMouseButton(0) || Input.GetButton("Fire1"));
                    if (Input.GetMouseButtonDown(0) || Input.GetButtonDown("Fire1") || continousFire)
                    {
                        player.FireWeapon();
                    }

                    //alt fire, could fire weapon alt-mode to launch selected ability
                    if (Input.GetMouseButtonDown(1) || Input.GetButtonDown("Fire2"))
                    {
                        player.FireAbility();
                    }

                    //launch ability
                    if (Input.GetMouseButtonDown(2) || Input.GetButtonDown("Fire3"))
                    {
                        player.FireAbilityAlt();
                    }

                    //reload
                    if (Input.GetKeyDown(KeyCode.R) || Input.GetButtonDown("Jump"))
                    {
                        player.Reload();
                    }

                    //bring up the chracter & perk menu
                    if (UILevelPerkMenu.Enabled() && Input.GetKeyDown(KeyCode.C))
                    {
                        ToggleLevelPerkMenu();
                    }
                }
            }
        }