Beispiel #1
0
        private void Update()
        {
            if (FengGameManagerMKII.inputManager != null)
            {
                if (FengGameManagerMKII.inputManager.menuOn)
                {
                    return;
                }
            }
            else
            {
                return;
            }

            //Restarts and clears all stats.
            if (Restart.IsDown())
            {
                if (IN_GAME_MAIN_CAMERA.gametype != GAMETYPE.SINGLE)
                {
                    if (PhotonNetwork.isMasterClient)
                    {
                        foreach (var player in PhotonNetwork.playerList)
                        {
                            var stats = new Hashtable {
                                { PhotonPlayerProperty.kills, 0 }, { PhotonPlayerProperty.deaths, 0 }, { PhotonPlayerProperty.max_dmg, 0 }, { PhotonPlayerProperty.total_dmg, 0 }
                            };
                            player.SetCustomProperties(stats);
                        }

                        FengGameManagerMKII.FGM.restartRC();
                        string[] msg = { "MasterClient ", "has restarted the game." };
                        InRoomChat.SystemMessageGlobal(msg, false);
                    }
                    else
                    {
                        InRoomChat.SystemMessageLocal(InRoomChat.Error(0));
                        return;
                    }
                }
                else
                {
                    FengGameManagerMKII.FGM.restartGameSingle();
                }
            }

            //Captures a screenshot
            if (Screenshot.IsDown())
            {
                var path = Application.dataPath + "/Screenshots";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                Application.CaptureScreenshot(Application.dataPath + "/Screenshots/Screenshot_" + DateTime.Now.ToString("yyyy:mm:dd:hh:mm:ss").Replace(":", "-") + ".png");
            }

            //Is your mod non-abusive? WELL YES BUT ACTUALLY NO.
            if (Infinites.IsDown())
            {
                Settings.InfiniteBulletsSetting.Value = !Settings.InfiniteBulletsSetting;
                Settings.InfiniteGasSetting.Value     = !Settings.InfiniteGasSetting;
                Settings.InfiniteBladesSetting.Value  = !Settings.InfiniteBladesSetting;
            }

            //Pause
            if (Pause.IsDown())
            {
                switch (IN_GAME_MAIN_CAMERA.gametype)
                {
                case GAMETYPE.MULTIPLAYER:
                    FengGameManagerMKII.FGM.SetPause(Time.timeScale == 1);
                    break;

                case GAMETYPE.SINGLE:
                    if (Time.timeScale == 1f)
                    {
                        IN_GAME_MAIN_CAMERA.LockCamera(true);
                        Time.timeScale = 0f;
                    }
                    else
                    {
                        Time.timeScale = 1f;
                        IN_GAME_MAIN_CAMERA.LockCamera(false);
                    }
                    break;
                }
            }

            //CannonSpawn
            if (CannonSpawn.IsDown())
            {
                if (PhotonNetwork.isMasterClient)
                {
                    RaycastHit hitInfo;
                    if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, 9999999f, Layer.GroundEnemy.value))
                    {
                        var vector     = hitInfo.point;
                        var objToSpawn = Settings.CannonTypeSetting == 0 ? "RCAsset/CannonGroundProp" : "RCAsset/CannonWallProp";
                        var obj        = PhotonNetwork.Instantiate(objToSpawn, vector, new Quaternion(0, 0, 0, 0), 0);
                        if (objToSpawn == "RCAsset/CannonWallProp")
                        {
                            var      cpr   = obj.GetComponent <CannonPropRegion>();
                            string[] array = new string[7];
                            array[0] = " photon,CannonWall,default,1,1,1,0,1,1,1,1.0,1.0,";
                            string[] array2 = array;
                            int      num    = 1;
                            array2[num] = vector.x.ToString();
                            array[2]    = ",";
                            string[] array3 = array;
                            int      num2   = 3;
                            array3[num2] = vector.y.ToString();
                            array[4]     = ",";
                            string[] array4 = array;
                            int      num3   = 5;
                            array4[num3] = vector.z.ToString();
                            array[6]     = ",0,0,0,0";
                            cpr.settings = string.Concat(array);
                        }
                        else if (objToSpawn == "RCAsset/CannonGroundProp")
                        {
                            var      cpr   = obj.GetComponent <CannonPropRegion>();
                            string[] array = new string[7];
                            array[0] = " photon,CannonGround,default,1,1,1,0,1,1,1,1.0,1.0,";
                            string[] array2 = array;
                            int      num    = 1;
                            array2[num] = vector.x.ToString();
                            array[2]    = ",";
                            string[] array3 = array;
                            int      num2   = 3;
                            array3[num2] = vector.y.ToString();
                            array[4]     = ",";
                            string[] array4 = array;
                            int      num3   = 5;
                            array4[num3] = vector.z.ToString();
                            array[6]     = ",0,0,0,0";
                            cpr.settings = string.Concat(array);
                        }
                    }
                }
            }
        }
Beispiel #2
0
    public void Update()
    {
        if (!photonView.isMine)
        {
            transform.position = Vector3.Lerp(transform.position, correctPlayerPos, Time.deltaTime * SmoothingDelay);
            transform.rotation = Quaternion.Lerp(transform.rotation, correctPlayerRot, Time.deltaTime * SmoothingDelay);
            barrel.rotation    = Quaternion.Lerp(barrel.rotation, correctBarrelRot, Time.deltaTime * SmoothingDelay);
        }
        else
        {
            var vector   = new Vector3(0f, -30f, 0f);
            var position = ballPoint.position;
            var vector3  = ballPoint.forward * 300f;
            var num      = 40f / vector3.magnitude;
            myCannonLine.SetWidth(0.5f, 40f);
            myCannonLine.SetVertexCount(100);
            for (var i = 0; i < 100; i++)
            {
                myCannonLine.SetPosition(i, position);
                position += vector3 * num + 0.5f * vector * num * num;
                vector3  += vector * num;
            }

            var num3 = 30f;
            if (FengGameManagerMKII.inputRC.isInputCannon(InputCodeRC.cannonSlow))
            {
                num3 = 5f;
            }

            if (isCannonGround)
            {
                if (FengGameManagerMKII.inputRC.isInputCannon(InputCodeRC.cannonForward))
                {
                    if (currentRot <= 32f)
                    {
                        currentRot += Time.deltaTime * num3;
                        barrel.Rotate(new Vector3(0f, 0f, Time.deltaTime * num3));
                    }
                }
                else if (FengGameManagerMKII.inputRC.isInputCannon(InputCodeRC.cannonBack) && currentRot >= -18f)
                {
                    currentRot += Time.deltaTime * -num3;
                    barrel.Rotate(new Vector3(0f, 0f, Time.deltaTime * -num3));
                }

                if (FengGameManagerMKII.inputRC.isInputCannon(InputCodeRC.cannonLeft))
                {
                    transform.Rotate(new Vector3(0f, Time.deltaTime * -num3, 0f));
                }
                else if (FengGameManagerMKII.inputRC.isInputCannon(InputCodeRC.cannonRight))
                {
                    transform.Rotate(new Vector3(0f, Time.deltaTime * num3, 0f));
                }
            }
            else
            {
                if (FengGameManagerMKII.inputRC.isInputCannon(InputCodeRC.cannonForward))
                {
                    if (currentRot >= -50f)
                    {
                        currentRot += Time.deltaTime * -num3;
                        barrel.Rotate(new Vector3(Time.deltaTime * -num3, 0f, 0f));
                    }
                }
                else if (FengGameManagerMKII.inputRC.isInputCannon(InputCodeRC.cannonBack) && currentRot <= 40f)
                {
                    currentRot += Time.deltaTime * num3;
                    barrel.Rotate(new Vector3(Time.deltaTime * num3, 0f, 0f));
                }

                if (FengGameManagerMKII.inputRC.isInputCannon(InputCodeRC.cannonLeft))
                {
                    transform.Rotate(new Vector3(0f, Time.deltaTime * -num3, 0f));
                }
                else if (FengGameManagerMKII.inputRC.isInputCannon(InputCodeRC.cannonRight))
                {
                    transform.Rotate(new Vector3(0f, Time.deltaTime * num3, 0f));
                }
            }
            if (HotKeys.CannonForward.IsPressed())
            {
                base.transform.Translate(Vector3.forward * Settings.CannonMovementSpeedSetting * Time.deltaTime);
            }
            if (HotKeys.CannonBackward.IsPressed())
            {
                base.transform.Translate(-Vector3.forward * Settings.CannonMovementSpeedSetting * Time.deltaTime);
            }
            if (HotKeys.CannonTurnLeft.IsPressed())
            {
                base.transform.Rotate(-Vector3.up * Settings.CannonMovementSpeedSetting * Time.deltaTime);
            }
            if (HotKeys.CannonTurnRight.IsPressed())
            {
                base.transform.Rotate(Vector3.up * Settings.CannonMovementSpeedSetting * Time.deltaTime);
            }
            if (HotKeys.CannonUp.IsPressed())
            {
                base.transform.Translate(Vector3.up * Settings.CannonMovementSpeedSetting * Time.deltaTime);
            }
            if (HotKeys.CannonDown.IsPressed())
            {
                base.transform.Translate(-Vector3.up * Settings.CannonMovementSpeedSetting * Time.deltaTime);
            }
            if (HotKeys.CannonTurnUp.IsPressed())
            {
                base.transform.Rotate(Vector3.left * Settings.CannonRotateSpeedSetting * Time.deltaTime);
            }
            if (HotKeys.CannonTurnDown.IsPressed())
            {
                base.transform.Rotate(-Vector3.left * Settings.CannonRotateSpeedSetting * Time.deltaTime);
            }

            if (FengGameManagerMKII.inputRC.isInputCannon(InputCodeRC.cannonFire))
            {
                Fire();
            }
            else if (FengGameManagerMKII.inputRC.isInputCannonDown(InputCodeRC.cannonMount))
            {
                if (myHero != null)
                {
                    myHero.isCannon       = false;
                    myHero.myCannonRegion = null;
                    Camera.main.GetComponent <IN_GAME_MAIN_CAMERA>().setMainObject(myHero.gameObject);
                    myHero.baseRigidBody.velocity = Vector3.zero;
                    myHero.photonView.RPC("ReturnFromCannon", PhotonTargets.Others);
                    myHero.skillCDLast     = myHero.skillCDLastCannon;
                    myHero.skillCDDuration = myHero.skillCDLast;
                    IN_GAME_MAIN_CAMERA.LockCamera(false);
                }

                PhotonNetwork.Destroy(gameObject);
            }
        }
    }