コード例 #1
0
ファイル: GameLevel.cs プロジェクト: OhBlihv/SkyCore-MiNET
        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));
        }