Exemplo n.º 1
0
        private static void InfectionUpdate()
        {
            int count = InfectionMode.GetInt(0);

            if (count < 0 || count > PhotonNetwork.playerList.Length)
            {
                count = 1;
            }
            infection.Clear();
            foreach (PhotonPlayer player in PhotonNetwork.playerList)
            {
                player.IsTitan = false;
            }
            int players = PhotonNetwork.playerList.Length;

            for (int i = 0; i < PhotonNetwork.playerList.Length; i++)
            {
                PhotonPlayer player = PhotonNetwork.playerList[i];
                if (UnityEngine.Random.Range(0f, 1f) <= (float)count / (float)players)
                {
                    player.IsTitan = true;
                    infection.Add(player.ID, 2);
                    if (--count == 0)
                    {
                        break;
                    }
                }
                players--;
            }
        }
Exemplo n.º 2
0
 public static void EndlessMode(int ID)
 {
     if (!EndlessRespawn.Enabled)
     {
         return;
     }
     FengGameManagerMKII.FGM.StartCoroutine(CheckEndless(ID, EndlessRespawn.GetInt(0)));
 }
Exemplo n.º 3
0
 public static bool CheckPVPWinner()
 {
     if (!BombMode.Enabled && !BladePVP.Enabled || FengGameManagerMKII.FGM.IsWinning)
     {
         return(false);
     }
     if (!TeamMode.Enabled)
     {
         if (!PointMode.Enabled)
         {
             List <PhotonPlayer> alives = new List <PhotonPlayer>();
             string winnerName          = "";
             foreach (PhotonPlayer player in PhotonNetwork.playerList)
             {
                 if (!player.Dead)
                 {
                     alives.Add(player);
                 }
             }
             if (alives.Count > 1)
             {
                 return(false);
             }
             winnerName = (alives.Count > 0) ? alives[0].UIName.ToHTMLFormat() : "Nobody";
             FengGameManagerMKII.FGM.GameWin();
             FengGameManagerMKII.FGM.BasePV.RPC("Chat", PhotonTargets.All, new object[]
             {
                 winnerName + " wins. 5 points added.",
                 ""
             });
             if (alives.Count > 0)
             {
                 alives[0].Kills += 5;
             }
         }
         else
         {
             foreach (PhotonPlayer player in PhotonNetwork.playerList)
             {
                 if (player.Kills > PointMode.GetInt(0))
                 {
                     FengGameManagerMKII.FGM.GameWin();
                     FengGameManagerMKII.FGM.BasePV.RPC("Chat", PhotonTargets.All, new object[]
                     {
                         player.UIName.ToHTMLFormat() + " wins. 5 points added.",
                         ""
                     });
                 }
             }
         }
         return(true);
     }
     else
     {
         bool teamCyanWin    = false;
         bool teamMagentaWin = false;
         if (PointMode.Enabled)
         {
             int cyanKills    = 0;
             int magentaKills = 0;
             foreach (PhotonPlayer player in PhotonNetwork.playerList)
             {
                 if (player.RCteam == 1)
                 {
                     cyanKills += player.Kills;
                 }
                 else if (player.RCteam == 2)
                 {
                     magentaKills += player.Kills;
                 }
             }
             if (cyanKills >= PointMode.GetInt(0))
             {
                 teamCyanWin = true;
             }
             else if (magentaKills >= PointMode.GetInt(0))
             {
                 teamMagentaWin = true;
             }
         }
         else
         {
             List <PhotonPlayer> cyan    = new List <PhotonPlayer>();
             List <PhotonPlayer> magenta = new List <PhotonPlayer>();
             foreach (PhotonPlayer player in PhotonNetwork.playerList)
             {
                 if (!player.Dead)
                 {
                     int rcteam = player.RCteam;
                     if (rcteam == 1)
                     {
                         cyan.Add(player);
                     }
                     else if (rcteam == 2)
                     {
                         magenta.Add(player);
                     }
                 }
             }
             if (cyan.Count < 1)
             {
                 teamCyanWin = true;
             }
             else if (magenta.Count < 1)
             {
                 teamMagentaWin = true;
             }
         }
         if (teamMagentaWin ^ teamCyanWin)
         {
             FengGameManagerMKII.FGM.GameWin();
             FengGameManagerMKII.FGM.BasePV.RPC("Chat", PhotonTargets.All, new object[]
             {
                 $"Team <color={(teamCyanWin ? "cyan>cyan" : "magenta>magenta")}</color> wins.",
                 ""
             });
             return(true);
         }
         else if (teamMagentaWin && teamCyanWin)
         {
             FengGameManagerMKII.FGM.GameWin();
             FengGameManagerMKII.FGM.BasePV.RPC("Chat", PhotonTargets.All, new object[]
             {
                 $"Nobody wins.",
                 ""
             });
             return(true);
         }
         return(false);
     }
 }
Exemplo n.º 4
0
        private static bool CheckPvpWinner()
        {
            if ((!BombMode.Enabled && !BladePvp.Enabled && !TeamMode.Enabled && !PointMode.Enabled) || FengGameManagerMKII.FGM.IsWinning)
            {
                return(false);
            }
            if (!TeamMode.Enabled)
            {
                if (!PointMode.Enabled)
                {
                    List <PhotonPlayer> alives = PhotonNetwork.playerList.Where(player => !player.Dead).ToList();
                    if (alives.Count > 1)
                    {
                        return(false);
                    }
                    FengGameManagerMKII.FGM.GameWin();
                    if (alives.Count > 0)
                    {
                        Chat.SendLocalizedTextAll("GameModes", "playerWin", new[] { alives[0].UIName.ToHTMLFormat() });
                    }
                    else
                    {
                        Chat.SendLocalizedTextAll("GameModes", "nobodyWin", new string[0]);
                    }
                    if (alives.Count > 0)
                    {
                        alives[0].Kills += 5;
                    }
                }
                else
                {
                    if (FengGameManagerMKII.IsPlayerAllDead() && !EndlessRespawn.Enabled)
                    {
                        FengGameManagerMKII.FGM.GameLose();
                        return(true);
                    }
                    foreach (PhotonPlayer player in PhotonNetwork.playerList)
                    {
                        if (player.Kills >= PointMode.GetInt(0))
                        {
                            FengGameManagerMKII.FGM.GameWin();
                            Chat.SendLocalizedTextAll("GameModes", "playerWin", new[] { player.UIName.ToHTMLFormat() });
                            break;
                        }
                    }
                }
                return(true);
            }
            bool teamCyanWin    = false;
            bool teamMagentaWin = false;

            if (PointMode.Enabled)
            {
                int cyanKills    = 0;
                int magentaKills = 0;
                foreach (PhotonPlayer player in PhotonNetwork.playerList)
                {
                    switch (player.RCteam)
                    {
                    case 1:
                        cyanKills += player.Kills;
                        break;

                    case 2:
                        magentaKills += player.Kills;
                        break;
                    }
                }
                if (cyanKills >= PointMode.GetInt(0))
                {
                    teamCyanWin = true;
                }
                if (magentaKills >= PointMode.GetInt(0))
                {
                    teamMagentaWin = true;
                }
                if (FengGameManagerMKII.IsPlayerAllDead() && !EndlessRespawn.Enabled)
                {
                    FengGameManagerMKII.FGM.GameLose();
                    return(true);
                }
            }
            else
            {
                List <PhotonPlayer> cyan    = new List <PhotonPlayer>();
                List <PhotonPlayer> magenta = new List <PhotonPlayer>();
                foreach (PhotonPlayer player in PhotonNetwork.playerList)
                {
                    if (player.Dead)
                    {
                        continue;
                    }
                    int rcteam = player.RCteam;
                    switch (rcteam)
                    {
                    case 1:
                        cyan.Add(player);
                        break;

                    case 2:
                        magenta.Add(player);
                        break;
                    }
                }
                if (BladePvp.Enabled || BombMode.Enabled)
                {
                    if (magenta.Count < 1)
                    {
                        teamCyanWin = true;
                    }
                    else if (cyan.Count < 1)
                    {
                        teamMagentaWin = true;
                    }
                }
            }
            if (teamMagentaWin ^ teamCyanWin)
            {
                FengGameManagerMKII.FGM.GameWin();
                Chat.SendLocalizedTextAll("GameModes", (teamCyanWin ? "cyan" : "magenta") + "Win", new string[0]);
                return(true);
            }

            if (teamMagentaWin && teamCyanWin)
            {
                FengGameManagerMKII.FGM.GameWin();
                Chat.SendLocalizedTextAll("GameModes", "nobodyWin", new string[0]);
                return(true);
            }
            return(false);
        }