/// <summary> /// again, descriptive name /// Ensures that AllPlayers variable contains the same number of players as parser.Players does /// </summary> private void ensureParserState() { //Add missing players to AllPlayers foreach (var curItem in parser.Players) { if (!AllPlayers.Select(p => p.AssociatedPlayer).Contains(curItem)) { if (DamageParser.IsBlacklistedUsername(curItem.Name)) { continue; } AllPlayers.Add(new AllPlayersTabPlayerVM(parent, curItem)); } } if (parent.IsZanverseSplit) { if (zanversePlayerVM == null && parser.ZanversePlayer != null) //can be null if zanverse is hidden { zanversePlayerVM = new AllPlayersTabPlayerVM(parent, parser.ZanversePlayer); AllPlayers.Add(zanversePlayerVM); } } else if (zanversePlayerVM != null) { if (AllPlayers.Contains(zanversePlayerVM)) { AllPlayers.Remove(zanversePlayerVM); } zanversePlayerVM = null; } }
private void Start() { state = CurrentState.None; for (int i = 0; i < Match_Details.instance.Players.Count; i++) { AllPlayers.Add(Match_Details.instance.Players[i]); PlayersList.Add(Match_Details.instance.Players[i]); PlayersScore.Add(new PlayerUsers(Match_Details.instance.Players[i], 0)); } GameObject[] go = GameObject.FindGameObjectsWithTag("Player"); for (int i = 0; i < go.Length; i++) { if (go[i].GetComponent <playerid>().IsMine) { My_Profile = go[i].GetComponent <playerid>(); } else { //ERROR } } paintChoose = GameObject.FindObjectOfType <PaintChoose>(); foreach (var player in PlayersScore) { Debug.Log(player.score + " " + player.name); } Played_Time = (int)PhotonNetwork.Time; BrushPanel_GO.SetActive(false); waitingtimeforpaintindex = waitingtimeforpaint; }
/// <summary> /// Diese Methode wird benötigt, um die Spieler eines Turniers zu erstellen. Anhand der eingegebenen Namen der Spieler /// werden Player-Objekte erzeugt und in die Liste AllPlayers geschrieben. Es müssen mindestens zwei Spieler angelegt werden. /// </summary> private void CreateAllPlayers() { Console.WriteLine($"Enter player names or STOP if all players has been entered. You have to enter at least {MINIMUM_PLAYERS_COUNT} players!"); Console.WriteLine("Enter help or game for Tournament Suggestion."); var name = Console.ReadLine(); int idCounter = 1; while (!String.Equals(name, "STOP", StringComparison.OrdinalIgnoreCase)) { if (ValidateInputOfPlayerName(name)) { var player = new Player(new Name(name), new Identification(idCounter)); AllPlayers.Add(player); idCounter++; } name = Console.ReadLine(); // Spieler hinzufügen bis genügend da sind und Stop eingegeben wurde while (AmountOfPlayers < MINIMUM_PLAYERS_COUNT && String.Equals(name, "STOP", StringComparison.OrdinalIgnoreCase)) { Console.WriteLine($"You have to enter at least {MINIMUM_PLAYERS_COUNT} players!"); name = Console.ReadLine(); } } if (!CheckIfAmountOfPlayersIsPowerOfTwo(AmountOfPlayers)) { CreateWildCards(); } Console.Clear(); Console.WriteLine("All Players created!"); }
public void JoinLobby(string nickName) { if (!AllPlayers.ContainsKey(nickName)) { AllPlayers.Add(nickName, new ConnectedPlayer(ClientCallback, nickName)); } }
public void Add_ShouldAddPlayersToPlayersList() { // Given var allPlayers = new AllPlayers(); var player1 = new Player("Player1"); var player2 = new Player("Player2"); // When allPlayers.Add(player1); allPlayers.Add(player2); // Then var players = allPlayers.GetAll(); Assert.That(players, Has.Exactly(1).EqualTo(player1)); Assert.That(players, Has.Exactly(1).EqualTo(player2)); Assert.That(players.Count, Is.EqualTo(2)); }
/// <summary> /// Adds all active and npc player to a combined Array. /// </summary> public void SetAllPlayerCollection() { foreach (PlayerViewModel item in ActivePlayer) { AllPlayers.Add(item); } foreach (PlayerViewModel item in NPCPlayer) { AllPlayers.Add(item); } }
private void OnEntityReceived(MEntity entity, bool wasNatural) { if (entity.IsPlayer()) { // A player entity has been received! // Register behaviour to control transformation in to props! var player = (FFAPlayerBehaviour)entity.RegisterBehaviour(parent, typeof(FFAPlayerBehaviour).FullName); // player.parent.SetServerTeam(FFATeam); AllPlayers.Add(player); } }
public void SetPlayersWithoutHandicaps() { AllPlayers.Clear(); foreach (var dataViewPlayer in DataView.Players) { AllPlayers.Add(dataViewPlayer); } if (AllPlayers.Count > 0) { SelectedPlayer = AllPlayers[0]; OnPropertyChanged(nameof(SelectedPlayer)); } }
/// <summary> /// Updates <see cref="AllPlayers"/> with any new players that have been added to the scene /// </summary> public void UpdateAllClients() { if (AllPlayers == null) { AllPlayers = new Dictionary <Player, PlayerState>(); } else { AllPlayers.Clear(); } PlayerState[] playersInScene = FindObjectsOfType <PlayerState>(); foreach (PlayerState np in playersInScene) { Player p = np.PhotonView.Owner; AllPlayers.Add(p, np); //Player previousMaster = MasterPlayer; if (p.IsMasterClient) { MasterPlayer = p; } if (p.IsLocal) { LocalPlayer = p; } //if(previousMaster == p && MasterPlayer != p) //{ // //We are no longer master! // Debug.LogWarning($"Local is no longer {nameof(MasterPlayer)}. {MasterPlayer} is the new {nameof(MasterPlayer)}", this); // //TODO potentially need to surrender observables. //} //if(p.IsMasterClient && p.IsLocal) //{ // //We are now the master! // //TOOD Add enemies to observables. //} } UpdatePlayerReferences(playersInScene); }
private void CreateWildCards() { Console.WriteLine("You can not create an instant Tournament tree because " + AmountOfPlayers + " is not a Power of Two"); Console.WriteLine("Do you wish to Fill up with Wildcards? (Open Spots which you always win against) Y/N"); Console.WriteLine("Warning! You can not play a Group Phase with Wildcards!"); if (Console.ReadKey().Key == ConsoleKey.Y) { WithWildCards = true; int checkAllPowerOfTwo = 4; int temp = AmountOfPlayers - checkAllPowerOfTwo; while (temp > 0) { checkAllPowerOfTwo *= 2; temp = AmountOfPlayers - checkAllPowerOfTwo; } int amountOfWildcards = Math.Abs(temp); for (int i = 0; i < amountOfWildcards; i++) { Player wildCard = new Player(true); AllPlayers.Add(wildCard); } } }
private void SwitchSelect(object obj) { IEnumerable args = obj as IEnumerable; List <PlayerCollectionItem> switchPlayers = new List <PlayerCollectionItem>(args.OfType <PlayerCollectionItem>()); if (!switchPlayers.Any()) { return; } if (PlayersInAlias.Contains(switchPlayers[0])) { int index = PlayersInAlias.IndexOf(switchPlayers[0]); switchPlayers.ForEach(player => { PlayersInAlias.Remove(player); AllPlayers.Add(player); player.LinkedAliases.Add(newAlias); }); SelectedPlayersSelectdIndex = index + 1 > PlayersInAlias.Count ? 0 : index; } else { int index = AllPlayers.IndexOf(switchPlayers[0]); switchPlayers.ForEach(player => { PlayersInAlias.Add(player); AllPlayers.Remove(player); player.LinkedAliases.Remove(newAlias); }); AllPlayersSelectdIndex = index + 1 > AllPlayers.Count ? 0 : index; } }
public virtual void Execute(Player player) { _allPlayers.Add(player); _playerAddedListener.OnPlayerAdded(player); Debug.Log("Player added: " + player.Name); }
public static void GenerateFrags(DemoParser parser) { Dictionary <string, Player> AllPlayers = new Dictionary <string, Player>(); List <Death> deaths = new List <Death>(); var outputStream = new StreamWriter("round.txt"); float timeBeginningRound = 0f; parser.ParseHeader(); string mapName = parser.Map; Map_JSON map = new Map_JSON(); // Get information from the assoiated JSON file. try { map = JsonConvert.DeserializeObject <Map_JSON>(File.ReadAllText("Maps_json/" + mapName + ".json")); } catch (FileNotFoundException) { Console.WriteLine("File was not found {0}", mapName); System.Environment.Exit(1); } int numberCT = 5; int numberT = 5; outputStream.WriteLine(parser.Map); // Make a print on round-start so you can see the actual frags per round. parser.RoundStart += (sender, e) => { timeBeginningRound = parser.CurrentTime; outputStream.WriteLine("Round {0}", parser.CTScore + parser.TScore); // Console.WriteLine("New Round, Current Score: T {0} : {1} CT", parser.TScore, parser.CTScore); numberCT = 5; numberT = 5; AllPlayers = new Dictionary <string, Player>(); deaths = new List <Death>(); //foreach (var player in parser.PlayingParticipants) { // AllPlayers.Add(player.Name, new Player(player.Name, player.Position, player.Position, // player.ActiveWeapon.AmmoInMagazine, player.ActiveWeapon.Weapon)); //} }; parser.PlayerKilled += (sender, e) => { if (e.Killer == null) { // The player has murdered himself (falling / own nade / ...) Console.WriteLine("<World><0><None>"); } else { Console.Write("<{0}><{1}> killed ", e.Killer.Name, ShortTeam(e.Killer.Team)); } if (e.Assister == null) { // nothing } else { Console.Write(" + <{0}><{1}> assist ", e.Assister.Name, ShortTeam(e.Assister.Team)); } Console.Write(" [{0}]", e.Weapon.Weapon); if (e.Headshot) { Console.Write("[HS]"); } if (e.PenetratedObjects > 0) { Console.Write("[Wall]"); } Console.Write(" "); Console.Write(" <{0}><{1}>", e.Victim.Name, ShortTeam(e.Victim.Team)); Console.Write(" Weapon {0} Ammo in Magazine {1} {2}", e.Victim.ActiveWeapon.Weapon, e.Victim.ActiveWeapon.AmmoInMagazine.ToString(), e.Victim.ActiveWeapon.AmmoInMagazine == WeaponInfo.WeaponAmmoMagazine(e.Victim.ActiveWeapon.Weapon) ? "Ammo Max" : ""); if (BackStabbing(e)) { Console.Write(" Not Looking player"); } else { Console.Write(" LookingPlayer"); } if (e.Victim.Team == Team.CounterTerrorist) { numberCT--; } else { numberT--; } Console.WriteLine(); WriteToFileDeadPlayers(outputStream, AllPlayers[e.Victim.Name]); deaths.Add(new Death(GetPositionMiniMap(e.Victim.Position, map.pos_x, map.pos_y, map.scale), e.Victim.Team)); }; parser.RoundEnd += (sender, e) => { Console.WriteLine("NumberCT alive " + numberCT.ToString() + " Number T alive " + numberT.ToString()); Console.WriteLine(); GenerateHeatMaps.GenerateMap(deaths, parser.CTScore + parser.TScore); }; parser.TickDone += (sender, e) => { float currentTime = parser.CurrentTime - timeBeginningRound; // Updated every frame foreach (var player in parser.PlayingParticipants) { // We multiply it by the time of one tick // Since the velocity is given in // ingame-units per second // Console.WriteLine("{0} {1}", player.Name, player.Position); if (AllPlayers.ContainsKey(player.Name)) { Player current = AllPlayers[player.Name]; //if (player.IsAlive) { // current.Update(player.Position, player.ActiveWeapon.AmmoInMagazine); //} } else { AllPlayers.Add(player.Name, new Player(player.Name, player.Position, player.Position, player.ActiveWeapon.AmmoInMagazine, player.ActiveWeapon.Weapon, player.Team, (player.Team == Team.CounterTerrorist) ? parser.CTClanName : parser.TClanName)); } } }; parser.ParseToEnd(); outputStream.Close(); }
// The main play function, which assumes there are enough players to play (work in progress!!!) public async Task PlayGame(CommandContext ctx, DiscordChannel voice) { CurrentCurePosition++; // CurrentCurePosition is now 0 Round++; // round is now 1 VoiceChannel = voice; // Add the users in the current voice channel foreach (DiscordMember m in VoiceChannel.Users) { AllPlayers.Add(m, -1); } GenerateTeam(); GenerateCure(true); string T1 = "**Team1:** "; string T2 = "**Team2:** "; foreach (DiscordMember m in Team1) { T1 += $"{m.DisplayName} "; } T1.TrimEnd(' '); foreach (DiscordMember m in Team2) { T2 += $"{m.DisplayName} "; } T2.TrimEnd(' '); // Send an embedded message describing the teams await ctx.Channel.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"<Welcome to Pandemic Panic!>", Description = $"As a deadly disease ravages the globe, you and your team of scientists must work together to find The Cure.\n" + $"You will be split into two teams, each with an even number of people. During each round, one person from each team " + $"will be chosen as the Head Scientist, who must coordinate their team to find a word that represents the next part of The Cure.\n" + $"Guess the word before the other team and you win the round! The first to guess three words wins!\n" + $"__**Be sure to check your DMs for rules of each round**__ (click the discord icon on the top left and look in your messages).\n" + $"If you have a guess and are on the answering side, submit your answer with\n**!c ANSWER** in the chat. All words are singular.", Color = DiscordColor.Aquamarine }.Build()); // Send an embedded message describing the teams await ctx.Channel.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"<TEAM FORMATIONS>", Description = $"{T1}\n{T2}", Color = DiscordColor.Aquamarine }.Build()); // Starts pre-game timer (for players to get their bearings ~30 seconds) Console.WriteLine("Pre-game timer started."); StartGenericTimer(ctx, " before game starts.", "The game is now starting.", 30); GenericTimerActive = true; while (GenericTimerActive) { } // Blocks until Intermission ends Console.WriteLine("Pre-game period ended."); // Stop when either team has a score of MaxRounds (default: 3-1 = 2) while (Team1Score < (MaxRounds - 1) && Team2Score < (MaxRounds - 1)) { PickMinigame(); // Choose the head scientists PickHeadScientists(); // comment this if you're testing with only one person PickRoundColor(); // Move everyone into seperate channels DiscordChannel T1Channel = await ctx.Guild.CreateChannelAsync("TEAM 1", DSharpPlus.ChannelType.Voice, VoiceChannel.Parent); DiscordChannel T2Channel = await ctx.Guild.CreateChannelAsync("TEAM 2", DSharpPlus.ChannelType.Voice, VoiceChannel.Parent); foreach (DiscordMember m in VoiceChannel.Users) { int ChannelNum = AllPlayers[m]; Console.WriteLine($"Moving member: {m.DisplayName} to Team channel {ChannelNum}"); if (AllPlayers[m] == 1) { await T1Channel.PlaceMemberAsync(m); } else if (AllPlayers[m] == 2) { await T2Channel.PlaceMemberAsync(m); } } Console.WriteLine("Distributing info"); // Send an embedded message describing the minigame and the round await ctx.Channel.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"<Round: {Round} | Category: {NounClass.TypeOfWord(Cure[CurrentCurePosition].Item2)}>", Description = $"__Gamemode: {CurrentMinigame.Name}__\n" + $"**Team 1's head scientist:** {Team1Lead.Mention}\n" + //comment the following if testing with only one person $"**Team 2's head scientist:** {Team2Lead.Mention}\n" + //comment the following if testing with only one person CurrentMinigame.Description, Color = LastColorUsed }.Build()); // Distribute infomation and instructions for each player foreach (DiscordMember m in AllPlayers.Keys) { // Determine who recieves what information with CurrentMinigame.WhoHasInfo and CurrentMinigame.TypeOfInfo if (m == Team1Lead) { // Team1 Head scientist if (CurrentMinigame.WhoHasInfo == InfoShare.HeadScientist) { // Team1 Head scientist have information if (CurrentMinigame.TypeOfInfo == InfoType.Chat) { // Team1 Head scientist have information (chat) await m.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"You are Team1's head scientist. Your word is '{Cure[CurrentCurePosition].Item1}'", Description = CurrentMinigame.InformedInstructions, Color = LastColorUsed }.Build()); } else if (CurrentMinigame.TypeOfInfo == InfoType.Image) { // Team1 Head scientist have information (image) await m.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"You are Team1's head scientist. Your word ({NounClass.TypeOfWord(Cure[CurrentCurePosition].Item2)}) is" + " associated with the image below", Description = CurrentMinigame.InformedInstructions, Color = LastColorUsed }.Build()); await m.SendFileAsync(NounClass.FetchImagePath(Cure[CurrentCurePosition].Item1)); } } else if (CurrentMinigame.WhoHasInfo == InfoShare.RegularScientists) { // Team1 Head scientist don't have information await m.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"You are Team1's head scientist.", Description = CurrentMinigame.UninformedInstructions, Color = LastColorUsed }.Build()); } } else if (m == Team2Lead) { // Team2 Head scientist if (CurrentMinigame.WhoHasInfo == InfoShare.HeadScientist) { // Team2 Head scientist have information if (CurrentMinigame.TypeOfInfo == InfoType.Chat) { // Team2 Head scientist have information (chat) await m.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"You are Team2's head scientist. Your word is '{Cure[CurrentCurePosition].Item1}'", Description = CurrentMinigame.InformedInstructions, Color = LastColorUsed }.Build()); } else if (CurrentMinigame.TypeOfInfo == InfoType.Image) { // Team2 Head scientist have information (image) await m.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"You are Team2's head scientist. Your word ({NounClass.TypeOfWord(Cure[CurrentCurePosition].Item2)}) is" + " associated with the image below", Description = CurrentMinigame.InformedInstructions, Color = LastColorUsed }.Build()); await m.SendFileAsync(NounClass.FetchImagePath(Cure[CurrentCurePosition].Item1)); } } else if (CurrentMinigame.WhoHasInfo == InfoShare.RegularScientists) { // Team2 Head scientist doesn't have information await m.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"You are Team2's head scientist.", Description = CurrentMinigame.UninformedInstructions, Color = LastColorUsed }.Build()); } } else { // Regular scientist if (CurrentMinigame.WhoHasInfo == InfoShare.HeadScientist) { // Regular scientist doesn't have info await m.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"You are a regular scientist on Team {AllPlayers[m]}.", Description = CurrentMinigame.UninformedInstructions, Color = LastColorUsed }.Build()); } else if (CurrentMinigame.WhoHasInfo == InfoShare.RegularScientists) { if (AllPlayers[m] == 1 && m != Team1Lead) { // Regular scientist in team 1 have info if (CurrentMinigame.TypeOfInfo == InfoType.Chat) { // Regular scientist in team 1 have info (chat) await m.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"You are one of Team1's many scientists. Your word is '{Cure[CurrentCurePosition].Item1}'", Description = CurrentMinigame.InformedInstructions, Color = LastColorUsed }.Build()); } else if (CurrentMinigame.TypeOfInfo == InfoType.Image) { // Regular scientist in team 1 have info (image) await m.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"You are one of Team1's many scientists. Your word ({NounClass.TypeOfWord(Cure[CurrentCurePosition].Item2)}) is" + " associated with the image below", Description = CurrentMinigame.InformedInstructions, Color = LastColorUsed }.Build()); await m.SendFileAsync(NounClass.FetchImagePath(Cure[CurrentCurePosition].Item1)); } } else if (AllPlayers[m] == 2 && m != Team2Lead) { // Regular scientist in team 2 have info if (CurrentMinigame.TypeOfInfo == InfoType.Chat) { // Regular scientist in team 2 have info (chat) await m.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"You are one of Team2's many scientists. Your word is '{Cure[CurrentCurePosition].Item1}'", Description = CurrentMinigame.InformedInstructions, Color = LastColorUsed }.Build()); } else if (CurrentMinigame.TypeOfInfo == InfoType.Image) { // Regular scientist in team 2 have info (image) await m.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = $"You are one of Team2's many scientists. Your word ({NounClass.TypeOfWord(Cure[CurrentCurePosition].Item2)}) is" + " associated with the image below", Description = CurrentMinigame.InformedInstructions, Color = LastColorUsed }.Build()); await m.SendFileAsync(NounClass.FetchImagePath(Cure[CurrentCurePosition].Item1)); } } } } } Console.WriteLine("Finished distributing info"); // Starts Instruction timer (for players to get their bearings ... ~60 seconds) Console.WriteLine("Instruction timer started."); StartGenericTimer(ctx, "seconds remaining to read your instructions.", "The round is now starting.", 60); GenericTimerActive = true; while (GenericTimerActive) { } // Blocks until Intermission ends Console.WriteLine("Instruction period ended."); // Starts Round timer Console.WriteLine("Round timer started."); StartRoundTimer(ctx); RoundResult = 0; RoundInProgress = true; while (RoundInProgress) { } // Blocks until round ends if (RoundResult == 0) { // We resetted the game, just return here. Console.WriteLine("Finishing one game abruptly."); return; } else if (RoundResult == -1) { // Tie round Console.WriteLine("Round ended with a tie.\nGenerating new but similar cures for the next round."); NextRoundTIE(); } else if (RoundResult != 0) { // Update the values, then print a message if (RoundResult == 1) { await NextRoundWIN(ctx, true); } else { await NextRoundWIN(ctx, false); } } // Move everyone back into the same voice channel foreach (DiscordMember m in T1Channel.Users) { Console.WriteLine($"Moving member: {m.DisplayName} to back to main voice channel"); await VoiceChannel.PlaceMemberAsync(m); } foreach (DiscordMember m in T2Channel.Users) { Console.WriteLine($"Moving member: {m.DisplayName} to back to main voice channel"); await VoiceChannel.PlaceMemberAsync(m); } // Delete the old voice channels foreach (DiscordChannel d in ctx.Guild.Channels.Values) { // If the channel's parent belong to the voice channel if (d.Parent != null && d.Parent.Name == "Voice Channels") { if (d.Name.StartsWith("TEAM")) { await d.DeleteAsync("Deleting TEAM channel."); } } } // Starts Intermission timer Console.WriteLine("Intermission timer started."); StartGenericTimer(ctx, "seconds remaining for this intermission.", "Intermission is over.", 20); // debug was 15 GenericTimerActive = true; while (GenericTimerActive) { } // Blocks until Intermission ends Console.WriteLine("Intermission ended."); } string TitleMessage; if (Team1Score >= (MaxRounds - 1)) { TitleMessage = "GAMEOVER. Team 1 wins!"; } else { TitleMessage = "GAMEOVER. Team 2 wins!"; } await ctx.Channel.SendMessageAsync(embed : new DiscordEmbedBuilder { Title = TitleMessage, Description = $"__Current scores:__ **Team1: {Team1Score} | Team2: {Team2Score}**\n" + $"__The cure was:__ {GetCure()}", Color = LastColorUsed }.Build()); await ctx.Channel.SendMessageAsync("The game is now over, type !sg while in a voice channel with at least 4 players to start a new game!"); StopGame(); }