void CreateGhosts() { var ghostPlaceList = CurrentStage.GetGhostStartPlace(); for (int i = 0; i < ghostPlaceList.Count; i++) { Ghost ghost; switch (i % 4) { case 1: ghost = Instantiate(prefPinky).GetComponent <Pinky>(); break; case 2: ghost = Instantiate(prefInky).GetComponent <Inky>(); break; case 3: ghost = Instantiate(prefClyde).GetComponent <Clyde>(); break; default: ghost = Instantiate(prefBlinky).GetComponent <Blinky>(); break; } ghost.Init(ghostPlaceList[i], CurrentStage.Min, CurrentStage.Max); GhostList.Add(ghost); } }
public void PlayerDead(Player player) { //When a player dies, we have to rewind time if the player has more lives. if (player.Lives > 0) { player.Lives--; player.Movement.Velocity = Vector2.Zero; State = GameState.Rewind; PlayerDeathSounds.PlayRandomSound(); var newGhost = SpawnGhost(player); GameObj.GetComponentsDeep <ScreenFlash>().FirstOrDefault()?.Flash(); RewindOperation newRewind = new RewindOperation(PlayerList, GhostList, () => { newGhost.Transform.Pos = player.GameObj.Transform.Pos; GhostList.Add(newGhost.GetComponent <Ghost>()); Scene.Current.AddObject(newGhost); State = GameState.Play; }); } else { State = GameState.GameOver; GameSetup.Instance.SwitchToGameEnd(PlayerList.Where(x => x != player).Select(x => x.Definition).First()); } }
public void OnIntercomSpeaking(IntercomSpeakingEventArgs ev) { if (Instance.Config.GhostInteract || !GhostList.Contains(ev.Player)) { return; } ev.IsAllowed = false; }
public virtual void Start() { m_ghostButtonTimer = new Timer(); m_ghostButtonTimer.m_time = 0.75f; m_pause = false; m_player = GetComponent <PlayerStateMachine>(); m_player.Initialize(); m_ghostList = GetComponent <GhostList>(); m_currentGhost = null; }
internal void OnHurting(HurtingEventArgs ev) { if (GhostList.Contains(ev.Target) && Instance.Config.GhostGod) { ev.Amount = 0; } if (!GhostList.Contains(ev.Attacker) || Instance.Config.AllowDamage) { return; } Log.Debug($"Prevented {ev.Attacker.Nickname} from doing harm as ghost spectator."); ev.Amount = 0; }
public override void Initialize() { base.Initialize(); m_ghostList = gameObject.AddComponent <GhostList>(); m_ghostList.m_ghostTemplate = m_data.m_ghost; m_states2D[0] = gameObject.AddComponent <OnGround>(); m_states2D[1] = gameObject.AddComponent <InAIr>(); m_states2D[3] = gameObject.AddComponent <ClimbingLadder>(); m_states2D[4] = gameObject.AddComponent <KO>(); m_states2D[0].Initialize(m_rigb, m_data); m_states2D[1].Initialize(m_rigb, m_data); m_states2D[3].Initialize(m_rigb, m_data); m_states2D[4].Initialize(m_rigb, m_data); m_states3D[0] = gameObject.AddComponent <OnGround3D>(); m_states3D[1] = gameObject.AddComponent <InAir3D>(); m_states3D[3] = m_states2D[3]; m_states3D[4] = m_states2D[4]; m_states3D[0].Initialize(m_rigb, m_data); m_states3D[1].Initialize(m_rigb, m_data); m_saveData = GetComponent <SaveData>(); m_saveData.Initialize(); if (m_saveData.m_upgradeArray[(int)E_UPGRADES.MOVE_CRATE]) { if (!m_states2D[2]) { m_states2D[2] = gameObject.AddComponent <MoveingBox>(); m_states2D[2].Initialize(m_rigb, m_data); m_states3D[2] = m_states2D[2]; } } if (m_saveData.m_upgradeArray[(int)E_UPGRADES.GHOST_1]) { m_ghostList.createGhost(); } if (m_saveData.m_upgradeArray[(int)E_UPGRADES.GHOST_2]) { m_ghostList.createGhost(); } }
public void CreateStage(GameObject stagePref) { GhostList.Clear(); FoodList.Clear(); WarpGateList.Clear(); CurrentStage = Instantiate(stagePref).GetComponent <Stage>(); SetGameState(EState.Prepare); CreatePlayer(); CreateGhosts(); CameraManager.Instance.SetMainCamera(Player); CameraManager.Instance.SetMinimapCamera(CurrentStage); }
public void OnConsoleCommand(SendingConsoleCommandEventArgs ev) { Plugin.Log.Debug($"{ev.Player.Nickname} used the command: '{ev.Name}'"); if (ev.Name.ToLower() == "specmode") { if (!Plugin.GhostSettings.ContainsKey(ev.Player.UserId)) { Plugin.GhostSettings.Add(ev.Player.UserId, new GhostSettings()); } if (RateLimited.Contains(ev.Player)) { ev.Player.ClearBroadcasts(); ev.Player.Broadcast(1, Translation.Translation.GetText().RateLimited); ev.ReturnMessage = Translation.Translation.GetText().RateLimited; ev.Color = "red"; return; } RateLimited.Add(ev.Player); Timing.CallDelayed(Instance.Config.RateLimitTime, () => RateLimited.Remove(ev.Player)); switch (Plugin.GhostSettings[ev.Player.UserId].Specmode) { case GhostSettings.Specmodes.Normal: Plugin.GhostSettings[ev.Player.UserId].Specmode = GhostSettings.Specmodes.Ghost; if (Plugin.GhostSettings.ContainsKey(ev.Player.UserId) && Plugin.GhostSettings[ev.Player.UserId].Specmode == GhostSettings.Specmodes.Ghost && ev.Player.Role == RoleType.Spectator) { Plugin.Log.Debug($"{ev.Player.Nickname} added to list of ghost spectators."); GhostList.Add(ev.Player); Timing.RunCoroutine(SpawnGhost(ev.Player, 0.1f)); } ev.ReturnMessage = Translation.Translation.GetText().SpecmodeGhost; ev.Color = "blue"; ev.IsAllowed = false; break; case GhostSettings.Specmodes.Ghost: Plugin.GhostSettings[ev.Player.UserId].Specmode = GhostSettings.Specmodes.Normal; if (GhostList.Contains(ev.Player)) { Plugin.Log.Debug($"{ev.Player.Nickname} removed from list of ghost spectators."); GhostList.Remove(ev.Player); ev.Player.SetGhostMode(false); ev.Player.ClearInventory(); ev.Player.Role = RoleType.Spectator; } ev.ReturnMessage = Translation.Translation.GetText().SpecmodeNormal; ev.Color = "blue"; ev.IsAllowed = false; break; default: Plugin.GhostSettings[ev.Player.UserId].Specmode = GhostSettings.Specmodes.Normal; if (GhostList.Contains(ev.Player)) { Plugin.Log.Debug($"{ev.Player.Nickname} removed from list of ghost spectators."); GhostList.Remove(ev.Player); ev.Player.SetGhostMode(false); ev.Player.ClearInventory(); ev.Player.Role = RoleType.Spectator; } ev.ReturnMessage = Translation.Translation.GetText().SpecmodeNormal; ev.Color = "blue"; ev.IsAllowed = false; break; } } else if (ev.Name.ToLower() == "specboard") { if (!Plugin.GhostSettings.ContainsKey(ev.Player.UserId)) { Plugin.GhostSettings.Add(ev.Player.UserId, new GhostSettings()); } Plugin.GhostSettings[ev.Player.UserId].Specboard = !Plugin.GhostSettings[ev.Player.UserId].Specboard; ev.ReturnMessage = "You have " + (Plugin.GhostSettings[ev.Player.UserId].Specboard ? "enabled" : "disabled") + " specboard mode."; ev.Color = "Magenta"; ev.IsAllowed = false; } }
public static bool UseGhostItem(this Player ply, ItemType item) { if (!GhostList.Contains(ply) || (item != ItemType.Ammo762 && item != ItemType.Ammo556 && item != ItemType.Ammo9mm && item != ItemType.Flashlight)) { return(true); } Plugin.Log.Debug($"{ply.Nickname} attempting ghost spectator teleport."); List <Player> players = Player.List.Where(p => !GhostList.Contains(p) && p.Role != RoleType.None && p.Role != RoleType.Spectator && p.Role != RoleType.Tutorial).ToList(); switch (item) { case ItemType.Ammo762: { if (players.Count <= 0) { ply.ClearBroadcasts(); ply.Broadcast(3, Translation.Translation.GetText().TeleportNone); return(false); } if (!Plugin.GhostSettings.ContainsKey(ply.UserId)) { Plugin.GhostSettings.Add(ply.UserId, new GhostSettings()); } foreach (var player in players.OrderBy(p => p.Id)) { if (player.Id > Plugin.GhostSettings[ply.UserId].Pos) { ply.Position = player.Position; Plugin.GhostSettings[ply.UserId].Pos = player.Id; Plugin.Log.Debug($"Teleporting {ply.Nickname} to {player.Nickname}."); ply.ClearBroadcasts(); ply.Broadcast(3, string.Format(Translation.Translation.GetText().TeleportTo, string.IsNullOrEmpty(player.DisplayNickname) ? player.Nickname : player.DisplayNickname)); return(false); } } ply.Position = players[0].Position; Plugin.GhostSettings[ply.UserId].Pos = players[0].Id; Plugin.Log.Debug($"Teleporting {ply.Nickname} to {players[0].Nickname}."); ply.ClearBroadcasts(); ply.Broadcast(3, string.Format(Translation.Translation.GetText().TeleportTo, string.IsNullOrEmpty(players[0].DisplayNickname) ? players[0].Nickname : players[0].DisplayNickname)); break; } case ItemType.Ammo556: { if (players.Count <= 0) { ply.ClearBroadcasts(); ply.Broadcast(3, Translation.Translation.GetText().TeleportNone); return(false); } if (!Plugin.GhostSettings.ContainsKey(ply.UserId)) { Plugin.GhostSettings.Add(ply.UserId, new GhostSettings()); } foreach (var player in players.OrderByDescending(p => p.Id)) { if (player.Id < Plugin.GhostSettings[ply.UserId].Pos) { ply.Position = player.Position; Plugin.GhostSettings[ply.UserId].Pos = player.Id; Plugin.Log.Debug($"Teleporting {ply.Nickname} to {player.Nickname}."); ply.ClearBroadcasts(); ply.Broadcast(3, string.Format(Translation.Translation.GetText().TeleportTo, string.IsNullOrEmpty(player.DisplayNickname) ? player.Nickname : player.DisplayNickname)); return(false); } } ply.Position = players[players.Count - 1].Position; Plugin.GhostSettings[ply.UserId].Pos = players[players.Count - 1].Id; Plugin.Log.Debug($"Teleporting {ply.Nickname} to {players[players.Count - 1].Nickname}."); ply.ClearBroadcasts(); ply.Broadcast(3, string.Format(Translation.Translation.GetText().TeleportTo, string.IsNullOrEmpty(players[players.Count - 1].DisplayNickname) ? players[players.Count - 1].Nickname : players[players.Count - 1].DisplayNickname)); break; } case ItemType.Ammo9mm: { ply.ClearBroadcasts(); ply.Broadcast(3, Translation.Translation.GetText().NotImplementedYet); break; } } return(false); }
public static void SetGhostMode(this Player ply, bool enabled = true) { switch (enabled) { case true: if (Instance.Config.GhostGod) { ply.IsGodModeEnabled = true; } if (Instance.Config.GhostNoclip) { GameCore.Console.singleton.TypeCommand($"/NOCLIP {ply.Id}. ENABLE"); } foreach (Player player in Player.List) { player.TargetGhosts.Clear(); if (GhostList.Contains(player)) { continue; } player.TargetGhosts.AddRange(GhostList.Select(p => p.Id)); } if (!Plugin.GhostSettings.ContainsKey(ply.UserId)) { Plugin.GhostSettings.Add(ply.UserId, new GhostSettings()); } if (Plugin.GhostSettings[ply.UserId].Specboard) { ply.Scale = new Vector3(0.6f, 0.6f, 0.6f); } else { ply.Scale = new Vector3(1f, 1f, 1f); } break; default: if (Instance.Config.GhostGod) { ply.IsGodModeEnabled = false; } if (Instance.Config.GhostNoclip) { GameCore.Console.singleton.TypeCommand($"/NOCLIP {ply.Id}. DISABLE"); } foreach (Player player in Player.List) { player.TargetGhosts.Clear(); if (GhostList.Contains(player)) { continue; } player.TargetGhosts.AddRange(GhostList.Select(p => p.Id)); } ply.Scale = new Vector3(1, 1, 1); SetPlayerScale(ply.GameObject, 1f, 1f, 1f); break; } }