public override void AddSpectator(SkyPlayer player) { player.IsGameSpectator = true; //Set an invisibily effect on top of the scale to completely 'remove' the player player.SetEffect(new Invisibility { Duration = int.MaxValue, Particles = false }); player.SetNameTagVisibility(false); McpeSetEntityData mcpeSetEntityData = McpeSetEntityData.CreateObject(); mcpeSetEntityData.runtimeEntityId = player.EntityId; mcpeSetEntityData.metadata = player.GetMetadata(); mcpeSetEntityData.metadata[(int)Entity.MetadataFlags.Scale] = new MetadataFloat(0.5f); // Scale //Avoid changing the local player's scale foreach (SkyPlayer gamePlayer in GetAllPlayers()) { if (gamePlayer == player) { continue; } gamePlayer.SendPackage(mcpeSetEntityData); } //Update slot held for other players player.Inventory.SetHeldItemSlot(player.Inventory.InHandSlot, false); }
public virtual void AddSpectator(SkyPlayer player) { if (player.IsGameSpectator) { return; //Avoid double-adding spectators } player.IsGameSpectator = true; List <MiNET.Player> gamePlayers = new List <MiNET.Player>(); DoForAllPlayers(gamePlayer => { if (gamePlayer != null && !gamePlayer.IsGameSpectator) { gamePlayers.Add(gamePlayer); } }); player.DespawnFromPlayers(gamePlayers.ToArray()); player.SetEffect(new Invisibility { Duration = int.MaxValue, Particles = false }); player.SetEffect(new Blindness { Duration = 100, Particles = false }); player.SetAllowFly(true); player.IsFlying = true; //Bump the player up into the air to signify death player.Knockback(new Vector3(0f, 0.5f, 0f)); }
public override void SetPlayerTeam(SkyPlayer player, GameTeam oldTeam, GameTeam team) { base.SetPlayerTeam(player, oldTeam, team); if (oldTeam == team) { return; } if (team == MurderTeam.Murderer) { Murderer = player; } else if (team == MurderTeam.Detective) { Detective = player; } //Handle Death else if ((team == null || team == MurderTeam.Spectator) && oldTeam != null) { if (oldTeam == MurderTeam.Innocent || oldTeam == MurderTeam.Detective) { //Check remaining players to see if the game should 'end' if (GetPlayersInTeam(MurderTeam.Innocent, MurderTeam.Detective).Count == 0) { //TODO: End Game UpdateGameState(new MurderEndState()); } else { player.SetEffect(new Blindness { Duration = 60, Particles = false }); //Should be 3 seconds? } } else if (oldTeam == MurderTeam.Murderer) { //TODO: Remove this second check, since if the murderer is changing teams the game must be won? //Check remaining players to see if the game should 'end' if (GetPlayersInTeam(MurderTeam.Murderer).Count == 0) { //TODO: End Game UpdateGameState(new MurderEndState()); } } } }
public override void InitializePlayer(GameLevel gameLevel, SkyPlayer player) { if (!player.Effects.ContainsKey(EffectType.NightVision)) { NightVision nightVision = new NightVision { Duration = int.MaxValue, Level = 0, Particles = false }; player.SetEffect(nightVision); } if (!(player.Inventory.Slots[4] is ItemNavigationCompass)) { player.Inventory.SetInventorySlot(4, new ItemNavigationCompass()); //Wait until the compass has appeared to change held slots RunnableTask.RunTaskLater(() => { player.Inventory.SetHeldItemSlot(4); }, 500); } /*try * { * ISet<long> mapIds = MapUtil.GetLevelMapIds(gameLevel); * if (mapIds == null) * { * SkyUtil.log( * $"Attempted to respawn missing maps for {player.Username}, but no maps were registered for {gameLevel.GameId}"); * } * else * { * RunnableTask.RunTaskLater(() => * { * //Murder one as example * Block block = gameLevel.GetBlock(new BlockCoordinates(260, 77, 270)); * * var message = McpeUpdateBlock.CreateObject(); * message.blockId = block.Id; * message.coordinates = block.Coordinates; * message.blockMetaAndPriority = (byte)(0xb << 4 | (block.Metadata & 0xf)); * player.SendPackage(message); * * /*MapUtil.SpawnMapImage(@"C:\Users\Administrator\Desktop\dl\map-images\comingsoonmapimage.png", 1, 1, this, * new BlockCoordinates(249, 77, 268), MapUtil.MapDirection.West); * MapUtil.SpawnMapImage(@"C:\Users\Administrator\Desktop\dl\map-images\buildbattlemapimage.png", 1, 1, this, * new BlockCoordinates(252, 77, 270), MapUtil.MapDirection.West); * MapUtil.SpawnMapImage(@"C:\Users\Administrator\Desktop\dl\map-images\murdermapimage.png", 1, 1, this, * new BlockCoordinates(260, 77, 270), MapUtil.MapDirection.West); * MapUtil.SpawnMapImage(@"C:\Users\Administrator\Desktop\dl\map-images\comingsoonmapimage.png", 1, 1, this, * new BlockCoordinates(263, 77, 268), MapUtil.MapDirection.West);#1# * * /*foreach (long mapEntityId in mapIds) * { * if (gameLevel.GetEntity(mapEntityId) is MapEntity mapEntity) * { * player.SendPackage(((MapImageProvider)mapEntity.ImageProvider).Batch); * } * }#1# * }, 1000); * } * } * catch (Exception e) * { * Console.WriteLine(e); * }*/ }