private void RefreshPlayers() { allSuccess = true; for (int i = 0; i < playerInfoSlots.Length; i++) { PlayerLobbyGUI plg = playerInfoSlots[i].GetComponent <PlayerLobbyGUI>(); plg.usernameLabel.text = ""; plg.rankLabel.text = ""; plg.transform.parent = transform; } if (Topan.Network.isConnected) { for (int p = 0; p < Topan.Network.connectedPlayers.Length; p++) { Topan.NetworkPlayer player = Topan.Network.connectedPlayers[p]; byte team = (byte)player.GetPlayerData("team", (byte)0); AddPlayerToList(team, player, null); } if (GeneralVariables.gameModeHasTeams) { BotPlayer[] redBots = NetworkingGeneral.GetBotParticipants(0); for (int i = 0; i < redBots.Length; i++) { AddPlayerToList(0, null, redBots[i]); } BotPlayer[] blueBots = NetworkingGeneral.GetBotParticipants(1); for (int i = 0; i < blueBots.Length; i++) { AddPlayerToList(0, null, blueBots[i]); } } else if (BotManager.allBotPlayers != null) { for (int i = 0; i < BotManager.allBotPlayers.Length && i < GeneralVariables.Networking.botCount; i++) { AddPlayerToList(2, null, BotManager.allBotPlayers[i]); } } } for (int i = 0; i < playerInfoSlots.Length; i++) { PlayerLobbyGUI plg = playerInfoSlots[i].GetComponent <PlayerLobbyGUI>(); if (plg.usernameLabel.text == "") { plg.rankIcon.enabled = false; } } }
void Awake() { if (Topan.Network.isServer) { Topan.Network.AddNetworkEventListener(this); topanNetworkView.observedComponents.Add(this); spawnBots = true; } else { Destroy(this); return; } nGeneral = GetComponent <NetworkingGeneral>(); }
public static BotPlayer[] GetBotParticipants(int team) { int redCount = NetworkingGeneral.GetTeamPlayers(0).Length; int blueCount = NetworkingGeneral.GetTeamPlayers(1).Length; List <BotPlayer> toReturn = new List <BotPlayer>(); int targetBots = Mathf.Clamp(Topan.Network.MaxPlayers - (redCount + blueCount), 0, GeneralVariables.Networking.botCount); if (!GeneralVariables.gameModeHasTeams) { for (int i = 0; i < targetBots; i++) { toReturn.Add(BotManager.allBotPlayers[i]); } return(toReturn.ToArray()); } int rBotIndex = 0; int bBotIndex = 0; while (rBotIndex + bBotIndex < targetBots) { if (redCount <= blueCount && redCount < 8) { if (team == 0) { toReturn.Add(BotManager.redBotPlayers[rBotIndex]); } rBotIndex++; redCount++; } else if (blueCount < redCount && blueCount < 8) { if (team == 1) { toReturn.Add(BotManager.blueBotPlayers[bBotIndex]); } bBotIndex++; blueCount++; } } return(toReturn.ToArray()); }
public void ConnectIP() { if (Topan.Network.isConnected) { return; } NetworkingGeneral.CreateInstance(cachedNetworking); Topan.Network.AddNetworkEventListener(this); TopanData initData = new TopanData(); initData.Add("dat", NetworkingGeneral.ConvertToCombatant(AccountManager.profileData)); PlayerPrefs.SetString("SavedIPConnect", DarkRef.RemoveSpaces(IPInput.value)); PlayerPrefs.SetString("SavedPortConnect", portInput.value); Topan.Network.Connect(DarkRef.RemoveSpaces(IPInput.value), int.Parse(portInput.value), initData); GeneralVariables.lobbyManager.joiningLobby = true; }
void Awake() { countToNextRound = 10; vignetting.intensity = 0f; blackStuff.alpha = 0f; Screen.lockCursor = false; UICamera.selectedObject = null; sortedPlayers = new List <NetPlayerInfo>(); for (int i = 0; i < Topan.Network.connectedPlayers.Length; i++) { Topan.NetworkPlayer curPlayer = Topan.Network.connectedPlayers[i]; NetPlayerInfo npi = new NetPlayerInfo(); npi.realPlayer = curPlayer; npi.myKills = (int)((UInt16)curPlayer.GetPlayerData("k", (UInt16)0)); npi.myDeaths = (int)((UInt16)curPlayer.GetPlayerData("d", (UInt16)0)); npi.myHeads = (int)((UInt16)curPlayer.GetPlayerData("h", (UInt16)0)); npi.myScore = (int)curPlayer.GetPlayerData("sc", 0); sortedPlayers.Add(npi); } if (GeneralVariables.gameModeHasTeams) { teamBasedRoot.SetActive(true); Destroy(individualBasedRoot); int redIndex = 0; int blueIndex = 0; sortedPlayers = new List <NetPlayerInfo>(); for (int i = 0; i < Topan.Network.connectedPlayers.Length; i++) { Topan.NetworkPlayer curPlayer = Topan.Network.connectedPlayers[i]; NetPlayerInfo npi = new NetPlayerInfo(); npi.realPlayer = curPlayer; npi.myKills = (int)((UInt16)curPlayer.GetPlayerData("k", (UInt16)0)); npi.myDeaths = (int)((UInt16)curPlayer.GetPlayerData("d", (UInt16)0)); npi.myHeads = (int)((UInt16)curPlayer.GetPlayerData("h", (UInt16)0)); npi.myScore = (int)curPlayer.GetPlayerData("sc", 0); sortedPlayers.Add(npi); } BotPlayer[] redBots = NetworkingGeneral.GetBotParticipants(0); for (int i = 0; i < redBots.Length; i++) { BotStats hisStats = BotManager.GetBotStats(redBots[i].index); NetPlayerInfo npi = new NetPlayerInfo(); npi.botPlayer = redBots[i]; npi.myKills = hisStats.kills; npi.myDeaths = hisStats.deaths; npi.myHeads = hisStats.headshots; npi.myScore = hisStats.score; sortedPlayers.Add(npi); } BotPlayer[] blueBots = NetworkingGeneral.GetBotParticipants(1); for (int i = 0; i < blueBots.Length; i++) { BotStats hisStats = BotManager.GetBotStats(blueBots[i].index); NetPlayerInfo npi = new NetPlayerInfo(); npi.botPlayer = blueBots[i]; npi.myKills = hisStats.kills; npi.myDeaths = hisStats.deaths; npi.myHeads = hisStats.headshots; npi.myScore = hisStats.score; sortedPlayers.Add(npi); } if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Kills) { sortedPlayers.Sort((p1, p2) => p2.myKills.CompareTo(p1.myKills)); } else if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Score) { sortedPlayers.Sort((p1, p2) => p2.myScore.CompareTo(p1.myScore)); } for (int i = 0; i < sortedPlayers.Count; i++) { NetPlayerInfo current = sortedPlayers[i]; if (current.botPlayer == null && current.realPlayer == null) { continue; } if (current.myInfo == null) { continue; } int kills = current.myKills; int deaths = current.myDeaths; int score = current.myScore; float kd = (deaths > 0) ? ((float)kills / (float)deaths) : kills; UserStatsGUI usg = null; if (current.myTeam == 0) { UserStatsGUI instance = (UserStatsGUI)Instantiate(scoreboardPrefab); instance.transform.parent = redStart; instance.transform.localPosition = Vector3.down * (redIndex * statsSpacing); instance.transform.localScale = Vector3.one; usg = instance; redIndex++; } else { UserStatsGUI instance = (UserStatsGUI)Instantiate(scoreboardPrefab); instance.transform.parent = blueStart; instance.transform.localPosition = Vector3.down * (blueIndex * statsSpacing); instance.transform.localScale = Vector3.one; usg = instance; blueIndex++; } int thisListIndex = (current.myTeam == 0) ? redIndex : blueIndex; string clanNameFinal = (current.myInfo.clan != "") ? ((current.thisPlayerIsBot) ? DarkRef.ClanColor(true) + "(" + current.myInfo.clan + ")[-] " : DarkRef.ClanColor(false) + "[" + current.myInfo.clan + "][-] ") : ""; usg.SetInfo(((current.myInfo != null) ? current.myInfo.rank : 1).ToString(), clanNameFinal + current.myInfo.username, kills.ToString(), deaths.ToString(), kd.ToString("F2"), current.myHeads.ToString(), score.ToString(), ((current.thisPlayerIsBot) ? Topan.Network.server.GetPlayerData("ping", 0).ToString() : current.realPlayer.GetPlayerData("ping", 0)).ToString(), (!current.thisPlayerIsBot && current.realPlayer == Topan.Network.player), (thisListIndex % 2 == 0)); } } else { Destroy(teamBasedRoot); individualBasedRoot.SetActive(true); int currentIndex = 0; for (int i = 0; i < BotManager.allBotPlayers.Length && i < GeneralVariables.Networking.botCount; i++) { BotStats hisStats = BotManager.GetBotStats(i); NetPlayerInfo npi = new NetPlayerInfo(); npi.botPlayer = BotManager.allBotPlayers[i]; npi.myKills = hisStats.kills; npi.myDeaths = hisStats.deaths; npi.myHeads = hisStats.headshots; npi.myScore = hisStats.score; sortedPlayers.Add(npi); } if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Kills) { sortedPlayers.Sort((p1, p2) => p2.myKills.CompareTo(p1.myKills)); } else if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Score) { sortedPlayers.Sort((p1, p2) => p2.myScore.CompareTo(p1.myScore)); } for (int i = 0; i < sortedPlayers.Count; i++) { NetPlayerInfo current = sortedPlayers[i]; if (current.botPlayer == null && current.realPlayer == null) { continue; } if (current.myInfo == null) { continue; } int kills = current.myKills; int deaths = current.myDeaths; int score = current.myScore; float kd = (deaths > 0) ? ((float)kills / (float)deaths) : kills; if (currentIndex >= 16) { continue; } UserStatsGUI instance = (UserStatsGUI)Instantiate(scoreboardPrefab); instance.transform.parent = individualStart; instance.transform.localPosition = Vector3.down * (currentIndex * statsSpacing); instance.transform.localScale = Vector3.one; currentIndex++; string clanNameFinal = (current.myInfo.clan != "") ? ((current.thisPlayerIsBot) ? DarkRef.ClanColor(true) + "(" + current.myInfo.clan + ")[-] " : DarkRef.ClanColor(false) + "[" + current.myInfo.clan + "][-] ") : ""; instance.SetInfo(((current.myInfo != null) ? current.myInfo.rank : 1).ToString(), clanNameFinal + current.myInfo.username, kills.ToString(), deaths.ToString(), kd.ToString("F2"), current.myHeads.ToString(), score.ToString(), ((current.thisPlayerIsBot) ? Topan.Network.server.GetPlayerData("ping", 0).ToString() : current.realPlayer.GetPlayerData("ping", 0)).ToString(), (!current.thisPlayerIsBot && current.realPlayer == Topan.Network.player), (currentIndex % 2 == 0)); } } if (GeneralVariables.gameModeHasTeams) { roundLabel.cachedTrans.localPosition = new Vector3(0f, 245f, -7f); spectatorList.cachedTrans.localPosition = new Vector3(-395f, -316f, 0f); panelRoot.localPosition = Vector3.zero; statsBackground.SetDimensions(270, 530); statsOutline.SetDimensions(278, 540); } else { roundLabel.cachedTrans.localPosition = new Vector3(0f, 225f, -7f); spectatorList.cachedTrans.localPosition = new Vector3(-395f, -261f, 0f); panelRoot.localPosition = Vector3.up * -20f; statsBackground.SetDimensions(270, 440); statsOutline.SetDimensions(278, 450); } int roundScore = (int)Topan.Network.player.GetPlayerData("sc", 0); int targetExp = AccountManager.GetTargetExperienceForRank(AccountManager.profileData.rank); startExp = AccountManager.profileData.curXP; currentExpValue = startExp; earnedExp = roundScore; earnedCurrency = Mathf.RoundToInt(roundScore * UnityEngine.Random.Range(0.95f, 1.05f) * 0.237f); expBaseAnimationTime = Mathf.Max(0.01f, expBaseAnimationTime); animationSpeed = (float)earnedExp / expBaseAnimationTime; expSlowdownTime = Mathf.Clamp(expSlowdownTime, 0f, 0.99f); expAccumulateSound.volume = 0f; expProgressBar.value = (float)startExp / (float)targetExp; xpLabel.text = startExp.ToString() + " XP / " + targetExp.ToString() + " XP"; xpLeftLabel.text = (targetExp - startExp).ToString() + " XP REMAINING"; currencyLabel.alpha = 0f; currencyLabel.text = "+0 CREDITS"; rankLabel.text = "[u]" + AccountManager.profileData.username + "[/u]" + "\n" + "RANK " + AccountManager.profileData.rank.ToString() + " [ROOKIE]"; nextRankLabel.text = "RANK " + (AccountManager.profileData.rank + 1).ToString() + " [ROOKIE]"; StartCoroutine(ProcessData()); }
public void OnJoin(int number) { if (joining) { return; } if (onlineList) { if (Topan.MasterServer.hosts == null) { return; } else if (Topan.MasterServer.hosts.Count <= 0) { return; } if (Topan.MasterServer.hosts[number].playerCount >= Topan.MasterServer.hosts[number].maxPlayers) { return; } } else { if (Topan.Network.foundLocalGames == null) { return; } else if (Topan.Network.foundLocalGames.Count <= 0) { return; } /* Local version of max player limit restriction. Dunno? * if(Topan.MasterServer.hosts[number].playerCount == Topan.MasterServer.hosts[number].maxPlayers) { * return; * } */ } lobbyChat.chatOutput.ClearChatList(); NetworkingGeneral.CreateInstance(cachedNetworking); joiningLobby = true; TopanData initData = new TopanData(); initData.Add("dat", NetworkingGeneral.ConvertToCombatant(AccountManager.profileData)); UICamera.selectedObject = null; if (onlineList) { joinHostInfo = serverList.displayHostedServers[number]; Topan.Network.Connect(joinHostInfo, initData); } else { Topan.FoundGame toConnectLocal = Topan.Network.foundLocalGames[number]; Topan.Network.Connect(toConnectLocal.serverEndpoint, initData); } }
private IEnumerator StartServerCoroutine() { Topan.Network.AddNetworkEventListener(this); TopanData init = new TopanData(); init.Add("dat", NetworkingGeneral.ConvertToCombatant(AccountManager.profileData)); int port = 7100; //As default. if (portForwardCheckbox.value) { port = int.Parse(hostPortInput.value); } PlayerPrefs.SetInt("SavedMaxPlayers", (int)maxPlayerSlider.currentValue); PlayerPrefs.SetInt("PortForward", (portForwardCheckbox.value) ? 1 : 0); PlayerPrefs.SetInt("LocalServer", (hostLocalCheckbox.value) ? 1 : 0); PlayerPrefs.SetString("SavedPingLimit", pingLimitInput.value); PlayerPrefs.SetInt("SavedMapIndex", selectedMap); PlayerPrefs.SetInt("SavedGameMode", mSettingControl.gameModePopup.selectionIndex); Topan.Network.InitializeServer((int)(maxPlayerSlider.currentValue), port, !portForwardCheckbox.value, init); Topan.Network.GameName = gameNameInput.value; NetworkingGeneral.CreateInstance(cachedNetworking); if (!hostLocalCheckbox.value && !portForwardCheckbox.value) { int mapIndx = selectedMap; Topan.MasterServer.RegisterMasterServer(gameNameInput.value, true, AccountManager.profileData.username, mapIndx, gameTypeIndexes[mSettingControl.gameTypeName]); } GeneralVariables.server.InstantiateServer(); yield return(null); yield return(null); UICamera.selectedObject = null; Topan.Network.SetServerInfo("s", UnityEngine.Random.seed); Topan.Network.SetServerInfo("dur", (byte)gameDurationSlider.currentDuration); Topan.Network.SetServerInfo("rc", (byte)roundCountSlider.currentRoundAmount); StartCoroutine(SelectMapRoutine(selectedMap)); GeneralVariables.server.amountOfRounds = roundCountSlider.currentRoundAmount; GeneralVariables.lobbyManager.ResetButtons(); moveCam.TargetPos(new Vector3(3840f, -800f, -700f)); Topan.Network.SetServerInfo("sm", false); Topan.Network.SetServerInfo("rTK", (UInt16)0); Topan.Network.SetServerInfo("bTK", (UInt16)0); Topan.Network.SetServerInfo("rTD", (UInt16)0); Topan.Network.SetServerInfo("bTD", (UInt16)0); Topan.Network.SetServerInfo("rVic", (byte)0); Topan.Network.SetServerInfo("bVic", (byte)0); Topan.Network.SetServerInfo("gm", NetworkingGeneral.currentGameType.typeName); foreach (GM_SettingsControl.SettingInfo sInfo in mSettingControl.settingsList) { Topan.Network.SetServerInfo(sInfo.settingName, NetworkingGeneral.currentGameType.customSettings[sInfo.settingName].currentValue); } int setPingLimit = Mathf.Clamp(int.Parse(pingLimitInput.value), 100, 9999); GeneralVariables.server.pingLimit = setPingLimit; Topan.Network.SetServerInfo("plim", setPingLimit); Topan.Network.SetServerInfo("it", (byte)(idleTimeSlider.currentIdleTime / 5)); yield return(null); Topan.Network.SetServerInfo("bC", (byte)bsMenu.amountSlider.currentValue); BotPlayer[] newBots = new BotPlayer[16]; //16 = maximum limit of players in a server List <string> prevNames = new List <string>(); for (int i = 0; i < newBots.Length; i++) { CombatantInfo newInfo = new CombatantInfo(); string randomName = DarkRef.RandomBotName(); int trials = 0; while (prevNames.Contains(randomName) && trials < 10) { randomName = DarkRef.RandomBotName(); trials++; } newInfo.username = randomName; prevNames.Add(randomName); newInfo.clan = "BOT"; newInfo.rank = UnityEngine.Random.Range(1, 11); newBots[i] = new BotPlayer(); newBots[i].botInfo = newInfo; newBots[i].botStats = new BotStats(); newBots[i].team = (byte)(i % 2); newBots[i].botStats.kills = 0; newBots[i].botStats.deaths = 0; newBots[i].botStats.headshots = 0; newBots[i].botStats.score = 0; Topan.Network.SetServerInfo("bS" + i.ToString(), BotManager.ParseToBotFormat(newBots[i].botStats)); } prevNames = null; BotManager._sBots = newBots; Topan.Network.SetServerInfo("bots", newBots); }
public void Refresh() { if (!Topan.Network.isConnected) { return; } sortedPlayers = new List <NetPlayerInfo>(); for (int i = 0; i < Topan.Network.connectedPlayers.Length; i++) { Topan.NetworkPlayer curPlayer = Topan.Network.connectedPlayers[i]; NetPlayerInfo npi = new NetPlayerInfo(); npi.realPlayer = curPlayer; npi.myKills = (int)((UInt16)curPlayer.GetPlayerData("k", (UInt16)0)); npi.myDeaths = (int)((UInt16)curPlayer.GetPlayerData("d", (UInt16)0)); npi.myHeads = (int)((UInt16)curPlayer.GetPlayerData("h", (UInt16)0)); npi.myScore = (int)curPlayer.GetPlayerData("sc", 0); sortedPlayers.Add(npi); if (curPlayer.id == Topan.Network.player.id) { yourPlayer = npi; } } if (GeneralVariables.gameModeHasTeams) { int redIndex = 0; int blueIndex = 0; int redTotalScore = 0; int blueTotalScore = 0; waitingForRed = true; waitingForBlue = true; BotPlayer[] redBots = NetworkingGeneral.GetBotParticipants(0); for (int i = 0; i < redBots.Length; i++) { BotStats hisStats = BotManager.GetBotStats(redBots[i].index); NetPlayerInfo npi = new NetPlayerInfo(); npi.botPlayer = redBots[i]; npi.myKills = hisStats.kills; npi.myDeaths = hisStats.deaths; npi.myHeads = hisStats.headshots; npi.myScore = hisStats.score; sortedPlayers.Add(npi); } BotPlayer[] blueBots = NetworkingGeneral.GetBotParticipants(1); for (int i = 0; i < blueBots.Length; i++) { BotStats hisStats = BotManager.GetBotStats(blueBots[i].index); NetPlayerInfo npi = new NetPlayerInfo(); npi.botPlayer = blueBots[i]; npi.myKills = hisStats.kills; npi.myDeaths = hisStats.deaths; npi.myHeads = hisStats.headshots; npi.myScore = hisStats.score; sortedPlayers.Add(npi); } if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Kills) { sortedPlayers.Sort((p1, p2) => p2.myKills.CompareTo(p1.myKills)); } else if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Score) { sortedPlayers.Sort((p1, p2) => p2.myScore.CompareTo(p1.myScore)); } tdmSubheader.text = NetworkingGeneral.currentGameType.typeName + " [" + Topan.Network.GameName + "]"; for (int i = 0; i < sortedPlayers.Count; i++) { NetPlayerInfo current = sortedPlayers[i]; if (current.botPlayer == null && current.realPlayer == null) { continue; } if (current.myInfo == null) { continue; } int kills = current.myKills; int deaths = current.myDeaths; int score = current.myScore; float kd = (deaths > 0) ? ((float)kills / (float)deaths) : kills; UserStatsGUI usg = null; if (current.myTeam == 0) { if (redIndex >= 8) { continue; } waitingForRed = false; usg = redTeam[redIndex]; usg.gameObject.SetActive(true); redTotalScore += score; redIndex++; } else if (current.myTeam == 1) { if (blueIndex >= 8) { continue; } waitingForBlue = false; usg = blueTeam[blueIndex]; usg.gameObject.SetActive(true); blueTotalScore += score; blueIndex++; } int thisListIndex = (current.myTeam == 0) ? redIndex : blueIndex; string clanNameFinal = (current.myInfo.clan != "") ? ((current.thisPlayerIsBot) ? DarkRef.ClanColor(true) + "(" + current.myInfo.clan + ")[-] " : DarkRef.ClanColor(false) + "[" + current.myInfo.clan + "][-] ") : ""; usg.SetInfo(current.myInfo.rank.ToString(), clanNameFinal + current.myInfo.username, kills.ToString(), deaths.ToString(), kd.ToString("F2"), current.myHeads.ToString(), score.ToString(), ((current.thisPlayerIsBot) ? Topan.Network.server.GetPlayerData("ping", 0).ToString() : current.realPlayer.GetPlayerData("ping", 0)).ToString(), (!current.thisPlayerIsBot && current.realPlayer == Topan.Network.player), (thisListIndex % 2 == 0)); } if (redIndex < 7) { for (int i = redIndex; i < 8; i++) { redTeam[i].gameObject.SetActive(false); } } if (blueIndex < 7) { for (int i = blueIndex; i < 8; i++) { blueTeam[i].gameObject.SetActive(false); } } try { tkRed = (UInt16)Topan.Network.GetServerInfo("rTK"); tkBlue = (UInt16)Topan.Network.GetServerInfo("bTK"); tdRed = (UInt16)Topan.Network.GetServerInfo("rTD"); tdBlue = (UInt16)Topan.Network.GetServerInfo("bTD"); } catch { tkRed = 0; tkBlue = 0; tdRed = 0; tdBlue = 0; } string redTotal = "Total Kills: " + tkRed; redTotal += "\n" + "Total Deaths: " + tdRed; float redKD = (tdRed > 0) ? ((float)tkRed / (float)tdRed) : tkRed; redTotal += "\n" + "Total K/D: " + redKD.ToString("F2"); redTotal += "\n" + "Team Score: " + redTotalScore.ToString(); redTotal += "\n----------------"; redTotal += "\n" + "Team Captures: 0"; //Placeholder, captures if capture the flag, defuses if demolition. string blueTotal = "Total Kills: " + tkBlue; blueTotal += "\n" + "Total Deaths: " + tdBlue; float blueKD = (tdBlue > 0) ? ((float)tkBlue / (float)tdBlue) : tkBlue; blueTotal += "\n" + "Total K/D: " + blueKD.ToString("F2"); blueTotal += "\n" + "Team Score: " + blueTotalScore.ToString(); blueTotal += "\n----------------"; blueTotal += "\n" + "Team Captures: 0"; //Placeholder, captures if capture the flag, defuses if demolition. totalStatsRed.text = redTotal; totalStatsBlue.text = blueTotal; roundVictoryStats.text = "[CE1C1C](RED)[-] " + (byte)Topan.Network.GetServerInfo("rVic") + " [A0A0A0]|[-] " + (byte)Topan.Network.GetServerInfo("bVic") + " [2546A5](BLUE)[-]"; } else { int currentIndex = 0; int yourIndex = 1; for (int i = 0; i < BotManager.allBotPlayers.Length && i < GeneralVariables.Networking.botCount; i++) { BotStats hisStats = BotManager.GetBotStats(i); NetPlayerInfo npi = new NetPlayerInfo(); npi.botPlayer = BotManager.allBotPlayers[i]; npi.myKills = hisStats.kills; npi.myDeaths = hisStats.deaths; npi.myHeads = hisStats.headshots; npi.myScore = hisStats.score; sortedPlayers.Add(npi); } if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Kills) { sortedPlayers.Sort((p1, p2) => p2.myKills.CompareTo(p1.myKills)); } else if (NetworkingGeneral.currentGameType.sortPlayersBy == SortPlayersBy.Score) { sortedPlayers.Sort((p1, p2) => p2.myScore.CompareTo(p1.myScore)); } dmSubheader.text = NetworkingGeneral.currentGameType.typeName + " [" + Topan.Network.GameName + "]"; for (int i = 0; i < sortedPlayers.Count; i++) { NetPlayerInfo current = sortedPlayers[i]; if (current.botPlayer == null && current.realPlayer == null) { continue; } if (current.myInfo == null) { continue; } int kills = current.myKills; int deaths = current.myDeaths; int score = current.myScore; float kd = (deaths > 0) ? ((float)kills / (float)deaths) : kills; UserStatsGUI usg = null; if (currentIndex >= 16) { continue; } usg = individuals[currentIndex]; usg.gameObject.SetActive(true); currentIndex++; if (!current.thisPlayerIsBot && current.realPlayer == Topan.Network.player) { yourIndex = i; } string clanNameFinal = (current.myInfo.clan != "") ? ((current.thisPlayerIsBot) ? DarkRef.ClanColor(true) + "(" + current.myInfo.clan + ")[-] " : DarkRef.ClanColor(false) + "[" + current.myInfo.clan + "][-] ") : ""; usg.SetInfo(current.myInfo.rank.ToString(), clanNameFinal + current.myInfo.username, kills.ToString(), deaths.ToString(), kd.ToString("F2"), current.myHeads.ToString(), score.ToString(), ((current.thisPlayerIsBot) ? Topan.Network.server.GetPlayerData("ping", 0).ToString() : current.realPlayer.GetPlayerData("ping", 0)).ToString(), (!current.thisPlayerIsBot && current.realPlayer == Topan.Network.player), (currentIndex % 2 == 0)); } if (currentIndex < 15) { for (int i = currentIndex; i < 16; i++) { individuals[i].gameObject.SetActive(false); } } tkRed = 0; tkBlue = 0; tdRed = 0; tdBlue = 0; yourPlace.text = "You're in " + DarkRef.OrdinalIndicatorFormat(yourIndex + 1) + " place"; } refreshTimer += refreshTime; }
void Start() { nGen = GeneralVariables.Networking; teamMarkers = new List <TeammateMarker>(); }
void Update() { if (!Topan.Network.isConnected) { return; } //Bot Management if (!inLobby && BotManager.allBotPlayers != null) { oldBots = BotManager.allBotPlayers; if (GeneralVariables.gameModeHasTeams) { for (int i = 0; i < BotManager.allBotPlayers.Length; i++) { BotManager.allBotPlayers[i].isParticipating = false; } redParticipantBots = NetworkingGeneral.GetBotParticipants(0); for (int i = 0; i < redParticipantBots.Length; i++) { redParticipantBots[i].isParticipating = true; } blueParticipantBots = NetworkingGeneral.GetBotParticipants(1); for (int i = 0; i < blueParticipantBots.Length; i++) { blueParticipantBots[i].isParticipating = true; } } else { for (int i = 0; i < BotManager.allBotPlayers.Length; i++) { BotManager.allBotPlayers[i].isParticipating = (i < GeneralVariables.Networking.botCount); } } /* Experimental stuff... * for(int i = 0; i < BotManager.allBotPlayers.Length; i++) { * if(!BotManager.allBotPlayers[i].isParticipating) { * if(GeneralVariables.Networking.botInstances[i] != null) { * GeneralVariables.Networking.botInstances[i].gameObject.GetComponent<Topan.NetworkView>().Deallocate(); * Debug.Log("Destroying instance of bot"); * } * } * } * * for(int i = 0; i < BotManager.allBotPlayers.Length; i++) { * if(BotManager.allBotPlayers[i].isParticipating != oldBots[i].isParticipating) { * if(BotManager.allBotPlayers[i].isParticipating) { * botRespawnQueue.Add(i); * Debug.Log("Re-participating bot, respawning!: " + BotManager.allBotPlayers[i].botInfo.username); * } * } * } */ } if (Topan.Network.HasServerInfo("pl") && (byte)Topan.Network.GetServerInfo("pl") <= 0) { StartMatch(); } if (!Topan.Network.HasServerInfo("sm") || startedMatch != setCheck) { Topan.Network.SetServerInfo("sm", startedMatch); setCheck = startedMatch; } if (nGeneral.countingDown && spawnBots) { StartCoroutine(SpawnAllBots()); spawnBots = false; } if (startedMatch && !nGeneral.finishedGame) { countTimer += Time.deltaTime; if (countTimer >= 1f) { CounterReduce(); countTimer -= 1f; } } else if (nGeneral.countingDown) { if (Input.GetKey(KeyCode.X) && Input.GetKeyDown(KeyCode.V)) { countdown = 0; } } for (int i = 0; i < botRespawnQueue.Count; i++) { if (!BotManager.allBotPlayers[botRespawnQueue[i]].isParticipating) { botRespawnQueue.RemoveAt(i); continue; } StartCoroutine(RespawnBot(botRespawnQueue[i], 5f + UnityEngine.Random.value)); botRespawnQueue.RemoveAt(i); } if (!inLobby) { pingCheckTimer += Time.unscaledDeltaTime; if (pingCheckTimer >= 1f) { CheckPing(); pingCheckTimer -= 1f; } } }