Exemple #1
0
        public override void Execute(InRoomChat irc, string[] args)
        {
            if (args.Length < 1 || !int.TryParse(args[0], out int id))
            {
                return;
            }

            PhotonPlayer player = PhotonPlayer.Find(id);

            if (player == null)
            {
                return;
            }

            if (player.IsTitan)
            {
                TITAN titan = player.GetTitan();
                if (titan == null || titan.hasDie)
                {
                    return;
                }

                titan.photonView.RPC("titanGetHit", player, titan.photonView.viewID, RCSettings.MinimumDamage > 0 ? RCSettings.MinimumDamage : 10);
            }
            else
            {
                HERO hero = player.GetHero();
                if (hero == null || hero.HasDied())
                {
                    return;
                }

                hero.photonView.RPC("netDie", PhotonTargets.All, hero.transform.position, false, -1, "[FF0000]Server", true);
            }
        }
Exemple #2
0
        public override void Execute(InRoomChat irc, string[] args)
        {
            if (args.Length > 0)
            {
                if (!int.TryParse(args[0], out int id))
                {
                    return;
                }

                PhotonPlayer player = PhotonPlayer.Find(id);
                if (player == null || player.IsDead)
                {
                    return;
                }

                if (player.IsTitan)
                {
                    Camera.main.GetComponent <IN_GAME_MAIN_CAMERA>().SetMainObjectTitan(player.GetTitan().gameObject);
                }
                else
                {
                    Camera.main.GetComponent <IN_GAME_MAIN_CAMERA>().SetMainObject(player.GetHero().gameObject);
                }

                Camera.main.GetComponent <IN_GAME_MAIN_CAMERA>().SetSpectorMode(false);
                irc.AddLine($"Now spectating #{id}.".AsColor("FFCC00"));
            }
            else
            {
                if (((int)FengGameManagerMKII.Settings[0xf5]) == 0)
                {
                    FengGameManagerMKII.Settings[0xf5] = 1;
                    FengGameManagerMKII.Instance.EnterSpecMode(true);
                    irc.AddLine("You entered spectator mode.".AsColor("FFCC00"));
                }
                else
                {
                    FengGameManagerMKII.Settings[0xf5] = 0;
                    FengGameManagerMKII.Instance.EnterSpecMode(false);
                    irc.AddLine("You left spectator mode.".AsColor("FFCC00"));
                }
            }
        }
Exemple #3
0
        public override void OnUpdate()
        {
            if (RoundStartTime == -1 || GameHelper.CurrentTimeMillis() - RoundStartTime < 5000)
            {
                return;
            }

            RoundStartTime = -1;

            PlayerOne = PhotonNetwork.playerList[MathHelper.RandomInt(0, PhotonNetwork.playerList.Length)];
            do
            {
                PlayerTwo = PhotonNetwork.playerList[MathHelper.RandomInt(0, PhotonNetwork.playerList.Length)];
            } while (PlayerOne == PlayerTwo);

            HERO playerOneHero = PlayerOne.GetHero();
            HERO playerTwoHero = PlayerTwo.GetHero();

            if (playerOneHero != null && playerTwoHero != null)
            {
                float spawnXL = (LeftMinX.Value + LeftMaxX.Value) / 2f;
                float spawnZL = (LeftMinZ.Value + LeftMaxZ.Value) / 2f;
                playerOneHero.photonView.RPC("moveToRPC", PlayerOne, spawnXL, (float)GroundLevel.Value, spawnZL);

                float spawnXR = (RightMinX.Value + RightMaxX.Value) / 2f;
                float spawnZR = (RightMinZ.Value + RightMaxZ.Value) / 2f;
                playerTwoHero.photonView.RPC("moveToRPC", PlayerTwo, spawnXR, (float)GroundLevel.Value, spawnZR);
            }
            else
            {
                InRoomChat.Instance.AddLine("One or more players are not spawned in! Trying again in 5 seconds...");
                RoundStartTime = GameHelper.CurrentTimeMillis();
            }

            foreach (TITAN titan in FengGameManagerMKII.Instance.Titans)
            {
                PhotonNetwork.Destroy(titan.gameObject);
            }

            SpawnTitan(0);
            SpawnTitan(1);
        }
Exemple #4
0
        public override void Execute(InRoomChat irc, string[] args)
        {
            if (FengGameManagerMKII.Level.Mode == GameMode.Racing)
            {
                irc.AddLine("Teleport can NOT be used while in Racing.".AsColor("FF0000"));
                return;
            }

            if (args.Length > 3) // Player(s) -> Coordinate
            {
                if (!float.TryParse(args[1], out float x) || !float.TryParse(args[2], out float y) || !float.TryParse(args[3], out float z))
                {
                    return;
                }

                if (args[0].Equals("all", StringComparison.OrdinalIgnoreCase))
                {
                    foreach (PhotonPlayer player in PhotonNetwork.playerList)
                    {
                        Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero();
                        if (mb == null)
                        {
                            continue;
                        }

                        mb.photonView.RPC("moveToRPC", player, x, y, z);
                    }

                    GameHelper.Broadcast($"Teleported everyone to {x:F3} / {y:F3} / {z:F3}");
                }
                else if (int.TryParse(args[0], out int id))
                {
                    PhotonPlayer player = PhotonPlayer.Find(id);
                    if (player == null)
                    {
                        return;
                    }

                    Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero();
                    if (mb == null)
                    {
                        return;
                    }

                    mb.photonView.RPC("moveToRPC", player, x, y, z);
                    FengGameManagerMKII.Instance.photonView.RPC("Chat", player, $"Teleported you to {x:F3} {y:F3} {z:F3}", string.Empty);
                }
            }
            else if (args.Length > 2) // You -> Coordinate
            {
                if (!float.TryParse(args[0], out float x) || !float.TryParse(args[1], out float y) || !float.TryParse(args[2], out float z))
                {
                    return;
                }

                Photon.MonoBehaviour mb = PhotonNetwork.player.IsTitan ? (Photon.MonoBehaviour)PhotonNetwork.player.GetTitan() : (Photon.MonoBehaviour)PhotonNetwork.player.GetHero();
                if (mb == null)
                {
                    return;
                }

                mb.transform.position = new UnityEngine.Vector3(x, y, z);
                irc.AddLine($"Teleported you to {x:F3} {y:F3} {z:F3}");
            }
            else if (args.Length > 1) // Player(s) -> Target
            {
                if (!int.TryParse(args[1], out int targetId))
                {
                    return;
                }

                PhotonPlayer target = PhotonPlayer.Find(targetId);
                if (target == null)
                {
                    return;
                }

                Photon.MonoBehaviour targetMb = target.IsTitan ? (Photon.MonoBehaviour)target.GetTitan() : (Photon.MonoBehaviour)target.GetHero();
                if (targetMb == null)
                {
                    return;
                }

                if (args[0].Equals("all", StringComparison.OrdinalIgnoreCase))
                {
                    foreach (PhotonPlayer player in PhotonNetwork.playerList)
                    {
                        Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero();
                        if (mb == null)
                        {
                            continue;
                        }

                        mb.photonView.RPC("moveToRPC", player, targetMb.transform.position.x, targetMb.transform.position.y, targetMb.transform.position.z);
                    }

                    GameHelper.Broadcast($"Teleported everyone to #{targetId}");
                }
                else if (int.TryParse(args[0], out int id))
                {
                    PhotonPlayer player = PhotonPlayer.Find(id);
                    if (player == null)
                    {
                        return;
                    }

                    Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero();
                    if (mb == null)
                    {
                        return;
                    }

                    mb.photonView.RPC("moveToRPC", player, targetMb.transform.position.x, targetMb.transform.position.y, targetMb.transform.position.z);
                    FengGameManagerMKII.Instance.photonView.RPC("Chat", player, $"Teleported you to #{targetId}", string.Empty);
                }
            }
            else if (args.Length > 0)// All -> You or You -> Target
            {
                Photon.MonoBehaviour myMb = PhotonNetwork.player.IsTitan ? (Photon.MonoBehaviour)PhotonNetwork.player.GetTitan() : (Photon.MonoBehaviour)PhotonNetwork.player.GetHero();
                if (myMb == null)
                {
                    return;
                }

                if (args[0].Equals("all", StringComparison.OrdinalIgnoreCase))
                {
                    foreach (PhotonPlayer player in PhotonNetwork.playerList)
                    {
                        Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero();
                        if (mb == null)
                        {
                            continue;
                        }

                        mb.photonView.RPC("moveToRPC", player, myMb.transform.position.x, myMb.transform.position.y, myMb.transform.position.z);
                    }

                    GameHelper.Broadcast("Teleported everyone to MasterClient!");
                }
                else if (int.TryParse(args[0], out int id))
                {
                    PhotonPlayer player = PhotonPlayer.Find(id);
                    if (player == null)
                    {
                        return;
                    }

                    Photon.MonoBehaviour mb = player.IsTitan ? (Photon.MonoBehaviour)player.GetTitan() : (Photon.MonoBehaviour)player.GetHero();
                    if (mb == null)
                    {
                        return;
                    }

                    myMb.transform.position = mb.transform.position;
                    irc.AddLine($"Teleported you to #{id}");
                }
            }
        }
Exemple #5
0
        public override void OnUpdate()
        {
            if (GameHelper.CurrentTimeMillis() - LastPollTime < 1000)
            {
                return;
            }

            Dictionary <int, int> newTimes = new Dictionary <int, int>(LifeTimes);

            LastPollTime = GameHelper.CurrentTimeMillis();

            foreach (KeyValuePair <int, int> entry in LifeTimes)
            {
                PhotonPlayer player = PhotonPlayer.Find(entry.Key);
                if (player == null)
                {
                    continue;
                }

                HERO hero = player.GetHero();
                if (hero == null)
                {
                    continue;
                }

                int timeLeft = entry.Value;
                if (entry.Value >= 0)
                {
                    timeLeft--;

                    player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable
                    {
                        { PhotonPlayerProperty.TotalDamage, timeLeft }
                    });
                }

                if (timeLeft <= 0)
                {
                    PhotonNetwork.Instantiate("FX/Thunder", hero.transform.position, hero.transform.rotation, 0);
                    hero.MarkDead();
                    hero.photonView.RPC("netDie2", player, -1, "[FF4444]Time's Up!");

                    GameHelper.Broadcast($"{GExtensions.AsString(player.customProperties[PhotonPlayerProperty.Name]).NGUIToUnity().AsColor("FFFFFF")} ran out of time!"
                                         .AsColor("FF0000"));

                    LifeTimes[hero.photonView.owner.Id] = StartTime.Value;
                }
                else if (timeLeft == 15)
                {
                    FengGameManagerMKII.Instance.photonView.RPC("Chat", player, $"15 seconds left...".AsColor("FF0000"), string.Empty);
                }
                else if (timeLeft < 6)
                {
                    FengGameManagerMKII.Instance.photonView.RPC("Chat", player, $"{timeLeft}...".AsColor("FF0000"), string.Empty);
                }

                newTimes[entry.Key] = timeLeft;
            }

            LifeTimes = newTimes;
        }