public FightTeamInformations[] GetFightTeamInformations() { return(new FightTeamInformations[2] { RedTeam.GetFightTeamInformations(), BlueTeam.GetFightTeamInformations() }); }
private void ReadyCommandChat(BasePlayer player, string command, string[] args) { if (GameStarted) { return; } if (RedTeam.Contains(player.userID) && !RedReady.Contains(player.userID)) { RedReady.Add(player.userID); BasePlayer.activePlayerList.ForEach(x => SendChatMessage(x, CurrentReady, player.displayName)); } else if (BlueTeam.Contains(player.userID) && !BlueReady.Contains(player.userID)) { BlueReady.Add(player.userID); BasePlayer.activePlayerList.ForEach(x => SendChatMessage(x, CurrentReady, player.displayName)); } else if (!RedTeam.Contains(player.userID) && !BlueReady.Contains(player.userID)) { SendChatMessage(player, CurrentChoose); } if (RedReady.Count == TeamSize && BlueReady.Count == TeamSize) { BeginGame(); } }
private void OnEntityDeath(BaseCombatEntity entity, HitInfo info) { if (GameStarted) { if (info == null || entity == null) { return; } if (entity is BaseNpc) { return; } BasePlayer victim = entity.ToPlayer(); if (info?.Initiator?.ToPlayer() == null) { return; } BasePlayer killer = info.Initiator.ToPlayer(); if (victim == null || killer == null) { return; } if (BlueTeam.Contains(killer.userID)) { BasePlayer.activePlayerList.ForEach(x => SendChatMessage(x, CurrentKill, String.Format(CurrentBlue, killer.displayName), String.Format(CurrentRed, victim.displayName))); } else if (RedTeam.Contains(killer.userID)) { BasePlayer.activePlayerList.ForEach(x => SendChatMessage(x, CurrentKill, String.Format(CurrentRed, killer.displayName), String.Format(CurrentBlue, victim.displayName))); } } }
public object Summary() { var redTeam = new { Name = RedTeam.GetNameOrDefault(), FirstPlayer = RedTeam.FirstPlayer.Name, SecondPlayer = RedTeam.SecondPlayer != null ? RedTeam.SecondPlayer.Name : "", Color = Table.SideOneColor.ToString() }; var blueTeam = new { Name = BlueTeam.GetNameOrDefault(), FirstPlayer = BlueTeam.FirstPlayer.Name, SecondPlayer = BlueTeam.SecondPlayer != null ? BlueTeam.SecondPlayer.Name : "", Color = Table.SideTwoColor.ToString() }; return(new { Teams = new { RedTeam = redTeam, BlueTeam = blueTeam }, Score = new { RedGoals = Goals.Count(g => g.Side == TableSide.Red), BlueGoals = Goals.Count(g => g.Side == TableSide.Blue) }, VanityString = _tauntTexts[CurrentTaunt()] }); }
public void StartFighting() { ForEach(x => x.Character.PreviousRoleplayMapId = x.Character.Record.MapId); ForEach(x => x.UpdateStep(false, PvpArenaStepEnum.ARENA_STEP_STARTING_FIGHT)); MapRecord map = ArenaMapRecord.GetArenaMap(); foreach (var member in BlueTeam.GetMembers()) { member.Character.Teleport(map.Id, null, true); CheckIntegrity(member); } foreach (var member in RedTeam.GetMembers()) { member.Character.Teleport(map.Id, null, true); CheckIntegrity(member); } FightArena fight = FightProvider.Instance.CreateFightArena(map); foreach (var member in BlueTeam.GetMembers()) { fight.BlueTeam.AddFighter(member.Character.CreateFighter(fight.BlueTeam)); } foreach (var member in RedTeam.GetMembers()) { fight.RedTeam.AddFighter(member.Character.CreateFighter(fight.RedTeam)); } fight.StartPlacement(); this.Dispose(); }
public List <Fighter> GetAllFightersWithLeavers() { var fighters = GetAllFighters(false); fighters.AddRange(RedTeam.GetLeavers()); fighters.AddRange(BlueTeam.GetLeavers()); return(fighters); }
public List <Fighter> GetAllFighters(bool aliveOnly = true) { List <Fighter> fighters = new List <Fighter>(); fighters.AddRange(RedTeam.GetFighters(aliveOnly)); fighters.AddRange(BlueTeam.GetFighters(aliveOnly)); return(fighters); }
public void UpdateTeams() { if (!Started) { BlueTeam.Update(); RedTeam.Update(); } }
private void OnEntitySpawned(BaseEntity entity, UnityEngine.GameObject gameObject) { if (entity.ShortPrefabName.Contains("cupboard.tool")) { BasePlayer player = BasePlayer.FindByID(entity.OwnerID); if (player == null) { return; } if (!GameStarted) { entity.KillMessage(); var itemtogive = ItemManager.CreateByItemID(-97956382, 1); if (itemtogive != null) { player.inventory.GiveItem(itemtogive); } SendChatMessage(player, CurrentStartCup); return; } if (RedTeam.Contains(player.userID) && CupBoardRed) { entity.KillMessage(); var itemtogive = ItemManager.CreateByItemID(-97956382, 1); if (itemtogive != null) { player.inventory.GiveItem(itemtogive); } SendChatMessage(player, CurrentCupLimit); return; } if (BlueTeam.Contains(player.userID) && CupBoardBlue) { entity.KillMessage(); var itemtogive = ItemManager.CreateByItemID(-97956382, 1); if (itemtogive != null) { player.inventory.GiveItem(itemtogive); } SendChatMessage(player, CurrentCupLimit); return; } if (RedTeam.Contains(player.userID)) { CupBoardRed = true; CupBoardRedString = entity.ToString(); SendChatMessage(player, CurrentCupPlaced); return; } if (BlueTeam.Contains(player.userID)) { CupBoardBlue = true; CupBoardBlueString = entity.ToString(); SendChatMessage(player, CurrentCupPlaced); return; } } }
public void Update(GameFightPlacementPossiblePositionsMessage msg) { if (msg == null) { throw new ArgumentException("msg"); } RedTeam.Update(msg); BlueTeam.Update(msg); }
public List<Fighter> GetAllFighters(bool deaths = false) { List<Fighter> result = new List<Fighter>(); if (BlueTeam != null && RedTeam != null) { result.AddRange(BlueTeam.GetFighters(deaths)); result.AddRange(RedTeam.GetFighters(deaths)); } return result; }
public void ForEach(Action <ArenaMember> action) { foreach (var member in BlueTeam.GetMembers()) { action(member); } foreach (var member in RedTeam.GetMembers()) { action(member); } }
internal void JoinRed(TSPlayer player) { if (!allPlayers.Contains(player.Index)) { allPlayers.Add(player.Index); } RedTeam.RemoveAll(p => p.Index == player.Index); BlueTeam.RemoveAll(p => p.Index == player.Index); RedTeam.Add(player); Main.player[player.Index].team = 1; player.SendInfoMessage("You have joined Red team for Class Wars."); }
public void AssignTeam(TankSetup player) { TeamColor team; if (BlueTeam.Count() == RedTeam.Count()) { team = (TeamColor)UnityEngine.Random.Range(1, Enum.GetValues(typeof(TeamColor)).Length); } else { team = BlueTeam.Count > RedTeam.Count ? TeamColor.Red : TeamColor.Blue; } player.m_TeamID = team; }
private void ClearGame() { PreparationUp = DefaultPreparationUp; GameStarted = DefaultGameStarted; CupBoardRed = DefaultCupBoardRed; CupBoardBlue = DefaultCupBoardBlue; CupBoardRedString = DefaultCupBoardRedString; CupBoardBlueString = DefaultCupBoardBlueString; RedTeam.Clear(); BlueTeam.Clear(); RedReady.Clear(); BlueReady.Clear(); RefreshServerName(); }
public override FightCommonInformations GetFightCommonInformations() { List <FightTeamInformations> teams = new List <FightTeamInformations>(); teams.Add(BlueTeam.GetFightTeamInformations()); teams.Add(RedTeam.GetFightTeamInformations()); List <ushort> positions = new List <ushort>(); positions.Add((ushort)FightCellId); positions.Add((ushort)Map.CloseCell(FightCellId)); return(new FightCommonInformations(Id, (sbyte)FightType, teams, positions, new List <FightOptionsInformations>() { BlueTeam.TeamOptions, RedTeam.TeamOptions })); }
public short GetPlacementCell(TeamColorEnum team) { List<short> usedplacement; switch (team) { case TeamColorEnum.BLUE_TEAM: usedplacement = BlueTeam.GetFighters().ConvertAll<short>(x => x.CellId); return Map.BlueCells.Find(x => !usedplacement.Contains(x)); case TeamColorEnum.RED_TEAM: usedplacement = RedTeam.GetFighters().ConvertAll<short>(x => x.CellId); return Map.RedCells.Find(x => !usedplacement.Contains(x)); } return 0; }
private void OnPlayerInit(BasePlayer player) { if (GameStarted && !player.IsAdmin) { if (!BlueTeam.Contains(player.userID) || !RedTeam.Contains(player.userID)) { player.Kick("Game started. Please connect when the servername is updated."); } } NotifyPlayerConnection(true, player.displayName); RefreshServerName(); if (UnlockedBP) { UnlockBP(player); } }
private void SurrendCommandChat(BasePlayer player, string command, string[] args) { if (!GameStarted) { if (RedTeam.Contains(player.userID)) { BasePlayer.activePlayerList.ForEach(x => SendChatMessage(x, CurrentSurrend, CurrentRedUpper, CurrentBlueUpper)); ClearGame(); } else if (BlueTeam.Contains(player.userID)) { BasePlayer.activePlayerList.ForEach(x => SendChatMessage(x, CurrentSurrend, CurrentBlueUpper, CurrentRedUpper)); ClearGame(); } } }
public bool CheckFightEnd() { if (Ended) return true; if (BlueTeam.GetFighters().Alives().Count == 0 || RedTeam.GetFighters().Alives().Count == 0) { if (Started) Synchronizer.Start(EndFight); else EndFight(); Ended = true; return true; } return false; }
public bool IsPlacementCellFree(TeamColorEnum team) { List<short> usedplacement; switch (team) { case TeamColorEnum.BLUE_TEAM: { usedplacement = BlueTeam.GetFighters().ConvertAll<short>(x => x.CellId); return Map.BlueCells.FindAll(x => !usedplacement.Contains(x)).Count != 0; } case TeamColorEnum.RED_TEAM: usedplacement = RedTeam.GetFighters().ConvertAll<short>(x => x.CellId); return Map.RedCells.FindAll(x => !usedplacement.Contains(x)).Count != 0; } return false; }
/// <summary> undo's the winnings, if the team had one a game /// </summary> private void undoCompletion() { if (State == MatchState.VictorFound) { if (Winner == RedTeam) { RedTeam.undoWin(); BlueTeam.undoLoss(); } else { BlueTeam.undoWin(); RedTeam.undoLoss(); } Winner = null; } }
private void StartCommandChat(BasePlayer player, string command, string[] args) { if (!player.IsAdmin) { SendChatMessage(player, CurrentNoPermission); return; } if (GameStarted) { SendChatMessage(player, CurrentStarted); return; } if (!RedTeam.Any() && !BlueTeam.Any()) { SendChatMessage(player, CurrentEmptyTeam); return; } BeginGame(); }
public override void TryJoin(WorldClient client, int mainfighterid) { var mainFighter = GetAllFighters().Find(x => x.ContextualId == mainfighterid); if (mainFighter != null) { if (mainFighter.Team.TeamColor == TeamColorEnum.RED_TEAM) { return; } } if (CanJoin(client, BlueTeam, mainFighter)) { var newFighter = client.Character.CreateFighter(BlueTeam); BlueTeam.AddFighter(newFighter); GetAllFighters().ForEach(x => x.ShowFighter(client)); Map.Instance.OnFighterAdded(Id, BlueTeam.Id, newFighter.GetFightMemberInformations()); } }
private void JoinBlue(BasePlayer player) { if (BlueTeam.Count == TeamSize) { SendChatMessage(player, CurrentTeamFull); return; } if (RedTeam.Contains(player.userID)) { RedTeam.Remove(player.userID); RedReady.Remove(player.userID); RedParty.RemovePlayer(player.userID); } if (!BlueTeam.Contains(player.userID)) { BlueTeam.Add(player.userID); BlueParty.AddPlayer(player); } BasePlayer.activePlayerList.ForEach(x => SendChatMessage(x, CurrentNow, player.displayName, CurrentBlueLower)); }
private void OnPlayerRespawned(BasePlayer player) { if (RedTeam.Contains(player.userID)) { var i = ItemManager.CreateByItemID(1751045826, 1, (ulong)RedHoodie); if (i != null) { player.inventory.GiveItem(i, player.inventory.containerWear); } return; } if (BlueTeam.Contains(player.userID)) { var i = ItemManager.CreateByItemID(1751045826, 1, (ulong)BlueHoodie); if (i != null) { player.inventory.GiveItem(i, player.inventory.containerWear); } return; } return; }
public TeamColorEnum GetWinner() { List<CharacterFighter> bluePlayers = BlueTeam.GetCharacterFighters(true); if (bluePlayers.Count > 0 && bluePlayers.All(x => x.HasLeft)) return TeamColorEnum.RED_TEAM; List<CharacterFighter> redPlayers = RedTeam.GetCharacterFighters(true); if (redPlayers.Count > 0 && redPlayers.All(x => x.HasLeft)) return TeamColorEnum.BLUE_TEAM; if (BlueTeam.GetFighters().Alives().Count == 0) { return TeamColorEnum.RED_TEAM; } else if (RedTeam.GetFighters().Alives().Count == 0) { return TeamColorEnum.BLUE_TEAM; } Logger.Error("Try to define winner but fight is running..."); return 0; }
private void JoinRed(BasePlayer player) { if (RedTeam.Count == TeamSize) { SendChatMessage(player, CurrentTeamFull); return; } if (BlueTeam.Contains(player.userID)) { BlueTeam.Remove(player.userID); BlueReady.Remove(player.userID); BlueParty.RemovePlayer(player.userID); } if (!RedTeam.Contains(player.userID)) { RedTeam.Add(player.userID); RedParty.AddPlayer(player); } foreach (BasePlayer x in BasePlayer.activePlayerList) { SendChatMessage(x, CurrentNow, player.displayName, CurrentRedLower); } }
/// <summary> /// Resests the match, reverting any actions taken during the match back to the begining state. /// </summary> public void resetMatch() { //sets flag that signal system that object has been modified recently recentlyModified = true; switch (State) { case MatchState.ByeRound: //Get the winner by default, does not affect their win/loss record Winner = (RedTeam == null) ? BlueTeam : RedTeam; State = MatchState.ByeRound; break; case MatchState.VictorFound: //First we must fix the team's records if (Winner == RedTeam) { RedTeam.undoWin(); BlueTeam.undoLoss(); } else { BlueTeam.undoWin(); RedTeam.undoLoss(); } //Clear the winner Winner = null; //set the state back to no victor found State = MatchState.NoVictor; break; case MatchState.NoVictor: case MatchState.Empty: break; } redrawComponents(); }
/// <summary> /// Le joueur a t-il le niveau pour rejoindre ce groupe /// </summary> /// <param name="character"></param> /// <returns></returns> public bool CanChallenge(Character character) { if (Empty) // Si le groupe est vide, ... il a forcement le niveau { return(true); } double mediumLevel = 1; double med = Extensions.Med(Array.ConvertAll(BlueTeam.GetMembers(), x => x.Character.Level)); // niveau moyen de l'équipe bleue double med2 = Extensions.Med(Array.ConvertAll(RedTeam.GetMembers(), x => x.Character.Level)); // niveau moyen de l'équipe rouge if (med2 == 0) // si il n'y a aucun membre dans l'équipe rouge { mediumLevel = med; } else if (med == 0) // si il n'y a aucun membre dans l'équipe bleue { mediumLevel = med2; } else { mediumLevel = Extensions.Med(new double[] { med, med2 }); // on calcule la moyenne de niveau entre les deux groupes } return(character.Level > mediumLevel - LEVEL_SHIFT && character.Level < mediumLevel + LEVEL_SHIFT); // mediumLevel - shift < x < mediumLevel + shift }