public FightTeamInformations[] GetFightTeamInformations() { return(new FightTeamInformations[2] { RedTeam.GetFightTeamInformations(), BlueTeam.GetFightTeamInformations() }); }
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(); }
void OnCollisionEnter(Collision collision) { if (this.tag == "Snitch") { GameObject g = GameObject.FindWithTag("Game"); QGame game = g.GetComponent <QGame>(); Destroy(GameObject.FindWithTag("Snitch")); game.createSnitch(this); // Passing it into here so it can be removed from the Snitch Team game.UpdateScore(collision.collider.tag); // i.e. Red, Green } if (this.tag == "Red" && collision.collider.tag == "Green") { QPlayer r = this.GetComponent <QPlayer>(); RedTeam rt = (RedTeam)r.team; QPlayer g = collision.collider.GetComponent <QPlayer>(); GreenTeam gt = (GreenTeam)g.team; if (!rt.behaviour.TackleSuccess()) { r.PlayerCrash(); r.team.RemovePlayer(r); } if (!gt.behaviour.TackleSuccess()) { g.PlayerCrash(); g.team.RemovePlayer(g); } } }
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(); } }
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()] }); }
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 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 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(); } } }
/// <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; } }
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; }
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 void StartFighting() { Clients.ForEach(x => x.UpdateRegistrationStatus(false, PvpArenaStepEnum.ARENA_STEP_STARTING_FIGHT)); int arenaMapId = ArenaProvider.Instance.RandomArenaMap(); BlueTeam.ForEach(x => MapsHandler.SendCurrentMapMessage(x.WorldClient, arenaMapId)); RedTeam.ForEach(x => MapsHandler.SendCurrentMapMessage(x.WorldClient, arenaMapId)); var fight = FightProvider.Instance.CreateArenaFight(MapRecord.GetMap(arenaMapId), this); BlueTeam.ForEach(x => fight.BlueTeam.AddFighter(x.WorldClient.Character.CreateFighter(fight.BlueTeam))); RedTeam.ForEach(x => fight.RedTeam.AddFighter(x.WorldClient.Character.CreateFighter(fight.RedTeam))); fight.StartPlacement(); Clients.Clear(); ArenaProvider.Instance.m_arena_groups.Remove(this); }
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(); }
void OnTriggerEnter(Collider enteredCollider) { if (enteredCollider.CompareTag("KillZone")) { if (this.tag == "Red") { QPlayer r = this.GetComponent <QPlayer>(); RedTeam rt = (RedTeam)r.team; rt.AddPlayer(); } else if (this.tag == "Green") { QPlayer g = this.GetComponent <QPlayer>(); GreenTeam gt = (GreenTeam)g.team; gt.AddPlayer(); } Destroy(gameObject); } }
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)); }
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 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; }
void AcceptFight(WorldClient client) { TemporaryArenaClient arenaClient = GetClient(client); arenaClient.Ready = true; arenaClient.UpdateRegistrationStatus(false, PvpArenaStepEnum.ARENA_STEP_WAITING_FIGHT); arenaClient.UpdateFighterStatus(Clients); foreach (var aClient in Clients) { if (aClient.Ready && aClient != arenaClient) { aClient.UpdateFighterStatus(new List <TemporaryArenaClient>() { aClient }); } } if (RedTeam.All(x => x.Ready) && BlueTeam.All(x => x.Ready)) { StartFighting(); } }
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(); }