Esempio n. 1
0
    void Update()
    {
        if (UnitZ.playerManager.PlayingCharacter != null)
        {
            SetVisible(true);
            FPSController fpsControl = UnitZ.playerManager.PlayingCharacter.GetComponent <FPSController>();
            if (fpsControl)
            {
                MouseLock.IsMobileControl = true;
                fpsControl.MoveCommand(new Vector3(CnInputManager.GetAxis("Horizontal"), 0, CnInputManager.GetAxis("Vertical")), CnInputManager.GetButton("Jump"));
                fpsControl.Aim(new Vector2(CnInputManager.GetAxis("Touch X") * AimSensitivity, CnInputManager.GetAxis("Touch Y") * AimSensitivity));
                fpsControl.Trigger1(CnInputManager.GetButton("Touch Fire1"));

                /*fpsControl.Trigger2(CnInputManager.GetButtonDown("Fire2"));
                 *
                 * if (CnInputManager.GetButtonDown("Fire3"))
                 * {
                 *  fpsControl.OutVehicle();
                 *  fpsControl.Interactive();
                 * }
                 *
                 * if (CnInputManager.GetButtonDown("Submit"))
                 * {
                 *  fpsControl.Reload();
                 * }*/

                fpsControl.Checking();
            }
        }
        else
        {
            SetVisible(false);
        }
    }
Esempio n. 2
0
    void Update()
    {
        FPSmotor.Aim(new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")));
        FPSmotor.Move(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")));
        FPSmotor.Jump(Input.GetButton("Jump"));

        if (Input.GetKey(KeyCode.LeftShift))
        {
            FPSmotor.Boost(1.7f);
        }

        FPSmotor.Holdbreath(1);
        if (Input.GetKey(KeyCode.LeftShift))
        {
            FPSmotor.Holdbreath(0);
        }

        if (Input.GetButton("Fire1"))
        {
            gunHanddle.Shoot();
        }
        if (Input.GetButtonDown("Fire2"))
        {
            gunHanddle.Zoom();
        }
        if (Input.GetAxis("Mouse ScrollWheel") < 0)
        {
            gunHanddle.ZoomAdjust(-1);
        }
        if (Input.GetAxis("Mouse ScrollWheel") > 0)
        {
            gunHanddle.ZoomAdjust(1);
        }
        if (Input.GetKeyDown(KeyCode.R))
        {
            gunHanddle.Reload();
        }
        if (Input.GetKeyDown(KeyCode.Q))
        {
            gunHanddle.SwitchGun();
        }
        if (Input.GetKeyDown(KeyCode.Z))
        {
            gunHanddle.OffsetAdjust(new Vector2(0, -1));
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            gunHanddle.OffsetAdjust(new Vector2(0, 1));
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            gunHanddle.OffsetAdjust(new Vector2(-1, 0));
        }
        if (Input.GetKeyDown(KeyCode.V))
        {
            gunHanddle.OffsetAdjust(new Vector2(1, 0));
        }
    }
    void Update()
    {
        Vector2 aimdir = touchAim.OnDragDirection(true);

        FPSmotor.Aim(new Vector2(aimdir.x, -aimdir.y) * TouchSensMult);
        Vector2 touchdir = touchMove.OnTouchDirection(false);

        FPSmotor.Move(new Vector3(touchdir.x, 0, touchdir.y));

        FPSmotor.Jump(Input.GetButton("Jump"));

        if (touchShoot.OnTouchPress())
        {
            gunHanddle.Shoot();
        }
        if (touchZoom.OnTouchRelease())
        {
            gunHanddle.ZoomToggle();
        }
    }
Esempio n. 4
0
    void Update()
    {
        if (FPSmotor == null || FPSmotor.character == null || !MouseLock.MouseLocked)
        {
            return;
        }

        // move input
        FPSmotor.Move(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")));
        // jump input
        //FPSmotor.Jump (Input.GetButton ("Jump"));

        // sprint input
        if (Input.GetKey(KeyCode.LeftShift))
        {
            FPSmotor.Boost(1.4f);
        }

        if (MouseLock.MouseLocked)
        {
            // aim input work only when mouse is locked
            FPSmotor.Aim(new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")));
        }
    }
Esempio n. 5
0
    void Update()
    {
        if (UnitZ.IsMobile)
        {
            return;
        }
        // *** You can change your controller here

        if (UnitZ.gameManager.IsPlaying)
        {
            // only in playing mode
            // open in game main menu
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                UnitZ.Hud.TogglePanelByName("InGameMenu");
            }
            // open score board
            if (Input.GetKeyDown(KeyCode.N))
            {
                UnitZ.Hud.TogglePanelByName("Scoreboard");
            }
        }

        if (UnitZ.playerManager != null && UnitZ.playerManager.PlayingCharacter != null)
        {
            // get fps controller from current player
            FPSController fpsControl = UnitZ.playerManager.PlayingCharacter.GetComponent <FPSController>();

            if (UnitZ.playerManager.PlayingCharacter.isLocalPlayer && fpsControl != null)
            {
                // move
                fpsControl.MoveCommand(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")), Input.GetButton("Jump"));

                // change stand sit / prone / stand
                if (Input.GetKeyDown(KeyCode.C))
                {
                    fpsControl.Sit();
                }
                // interact to vihicle
                if (Input.GetKeyDown(KeyCode.F))
                {
                    fpsControl.OutVehicle();
                }
                // sprint
                fpsControl.Sprint(Input.GetKey(KeyCode.LeftShift));
                // aiming control
                if (MouseLock.MouseLocked)
                {
                    fpsControl.Aim(new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")));
                    fpsControl.Trigger1(Input.GetButton("Fire1"));
                    fpsControl.Trigger2(Input.GetButtonDown("Fire2"));
                }
                // interact to thing
                if (Input.GetKeyDown(KeyCode.F))
                {
                    fpsControl.Interactive();
                }
                // change view
                if (Input.GetKeyDown(KeyCode.V))
                {
                    fpsControl.SwithView();
                }
                // change view side
                if (Input.GetKeyDown(KeyCode.B))
                {
                    fpsControl.SwithSideView();
                }
                // reload gun
                if (Input.GetKeyDown(KeyCode.R))
                {
                    fpsControl.Reload();
                }
                // open inventory
                if (Input.GetKeyDown(KeyCode.Tab))
                {
                    UnitZ.Hud.TogglePanelByName("Inventory");
                }
                if (Input.GetKeyDown(KeyCode.E))
                {
                    UnitZ.Hud.TogglePanelByName("Craft");
                }
                // open map
                if (Input.GetKeyDown(KeyCode.M))
                {
                    UnitZ.Hud.TogglePanelByName("Map");
                }

                // always check all interactive thing
                fpsControl.Checking();
            }
        }
    }
Esempio n. 6
0
    void Update()
    {
        if (UnitZ.IsMobile)
        {
            return;
        }
        //在此改变控制器

        if (UnitZ.gameManager.IsPlaying)
        {
            //只在游戏模式
            //游戏主菜单打开
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                UnitZ.Hud.TogglePanelByName("InGameMenu");
            }
            //打开第二面板
            if (Input.GetKeyDown(KeyCode.N))
            {
                UnitZ.Hud.TogglePanelByName("Scoreboard");
            }
        }

        if (UnitZ.playerManager != null && UnitZ.playerManager.PlayingCharacter != null)
        {
            //从当前玩家处取得控制器
            FPSController fpsControl = UnitZ.playerManager.PlayingCharacter.GetComponent <FPSController>();

            if (UnitZ.playerManager.PlayingCharacter.isLocalPlayer && fpsControl != null)
            {
                //移动
                fpsControl.MoveCommand(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")), Input.GetButton("Jump"));

                //改变状态-站立/蹲下/趴下
                if (Input.GetKeyDown(KeyCode.C))
                {
                    fpsControl.Sit();
                }
                //与车辆互相作用
                if (Input.GetKeyDown(KeyCode.F))
                {
                    fpsControl.OutVehicle();
                }
                //加速跑
                fpsControl.Sprint(Input.GetKey(KeyCode.LeftShift));
                //瞄准控制
                if (MouseLock.MouseLocked)
                {
                    fpsControl.Aim(new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")));
                    fpsControl.Trigger1(Input.GetButton("Fire1"));
                    fpsControl.Trigger2(Input.GetButtonDown("Fire2"));
                }
                //与物体作用
                if (Input.GetKeyDown(KeyCode.F))
                {
                    fpsControl.Interactive();
                }
                //改变视角
                if (Input.GetKeyDown(KeyCode.V))
                {
                    fpsControl.SwithView();
                }
                //改变视角
                if (Input.GetKeyDown(KeyCode.B))
                {
                    fpsControl.SwithSideView();
                }
                //换子弹
                if (Input.GetKeyDown(KeyCode.R))
                {
                    fpsControl.Reload();
                }
                //打开背包
                if (Input.GetKeyDown(KeyCode.Tab))
                {
                    UnitZ.Hud.TogglePanelByName("Inventory");
                }
                //打开地图
                if (Input.GetKeyDown(KeyCode.M))
                {
                    UnitZ.Hud.TogglePanelByName("Map");
                }

                //总是检查所有互动物品
                fpsControl.Checking();
            }
        }
    }
Esempio n. 7
0
    void Update()
    {
        if (FPSmotor == null || FPSmotor.character == null)
        {
            return;
        }
//		Debug.Log("FPSmotor "+FPSmotor);
        //FPSItemEquipment FPSitem = null;

        FPSmotor.Move(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")));
        // jump input
        FPSmotor.Jump(Input.GetButton("Jump"));

        // sprint input
        if (Input.GetKey(KeyCode.LeftShift))
        {
            FPSmotor.Boost(1.4f);
//			Debug.Log ("Boost ");
        }

        ItemEquipment actionItem = GetComponentInChildren <ItemEquipment>();

        if (Cursor.lockState == CursorLockMode.Locked)
        {
            // aim input work only when mouse is locked
            FPSmotor.Aim(new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")));

            // fire input
            if (Input.GetButton("Fire1"))
            {
                // press trigger to fire
                //	Debug.Log("Fire1 ");
                actionItem.Trigger();
            }
            else
            {
                // relesed trigger.
                actionItem.OnTriggerRelease();
            }
            // fire 2 input e.g. Zoom
            if (Input.GetButtonDown("Fire2"))
            {
                // press trigger 2
                //				Debug.Log("Fire2 ");
                actionItem.Trigger2();
            }
            else
            {
                // release trigger 2
                actionItem.OnTrigger2Release();
            }
        }

        // interactive input e.g. pickup item
        if (Input.GetKeyDown(KeyCode.F))
        {
        }
        // reload input
        if (Input.GetKeyDown(KeyCode.R))
        {
            actionItem.Reload();
        }
    }