예제 #1
0
 /// <summary>
 /// コンストラクタ(非公開)
 /// </summary>
 /// <param name="gameContext"></param>
 internal PlayerContext(IGamePlayer player, BaseGameContext gameContext)
 {
     Ranking      = PlayerRank.HEIMIN;
     _gameContext = gameContext;
     //this.func = func;
     _gameContext.AddPlayer(player, () => new BasePlayerInfo()
     {
         GetName          = () => player.Name,
         GetHavingCard    = () => _deck,
         GetRanking       = () => Ranking,
         GetOrderOfFinish = () => OrderOfFinish,
         //GetLastIsPass = () => LastIsPass,
     });
 }
예제 #2
0
 /// <summary>
 /// コンストラクタ(非公開)
 /// </summary>
 /// <param name="gameContext"></param>
 internal BaseMonitorContext(BaseGameContext gameContext, Func <IEnumerable <IEnumerable <Card> > > getAllDeckFunc)
 {
     _gameContext = gameContext;
     _func        = getAllDeckFunc;
 }
예제 #3
0
        public override bool TakeDamage(Vector2 force, Vector2 source, int damage, int from, Weapon weapon)
        {
            Core.Velocity += force;

            if (GameContext.GameController.IsFriendlyFire(Player.ClientId, from))
            {
                return(false);
            }

            if (from == Player.ClientId)
            {
                damage = Math.Max(1, damage / 2);
            }

            var prevHealth = Health;
            var prevArmor  = Armor;

            if (damage > 0)
            {
                if (Armor > 0)
                {
                    if (damage > 1)
                    {
                        Health--;
                        damage--;
                    }

                    if (damage > Armor)
                    {
                        damage -= Armor;
                        Armor   = 0;
                    }
                    else
                    {
                        Armor -= damage;
                        damage = 0;
                    }
                }

                Health -= damage;
            }

            GameContext.CreateDamageIndicator(Position, source, Player.ClientId,
                                              prevHealth - Health,
                                              prevArmor - Armor, from == Player.ClientId);

            bool AttackerExist() => from >= 0 && from != Player.ClientId && GameContext.Players[from] != null;

            if (AttackerExist())
            {
                var mask = BaseGameContext.MaskOne(from);
                for (var i = 0; i < GameContext.Players.Length; i++)
                {
                    if (GameContext.Players[i] != null && (
                            GameContext.Players[i].Team == Team.Spectators ||
                            GameContext.Players[i].DeadSpectatorMode) &&
                        GameContext.Players[i].SpectatorId == from)
                    {
                        mask |= BaseGameContext.MaskOne(i);
                    }
                }

                GameContext.CreateSound(GameContext.Players[from].ViewPos, Sound.Hit, mask);
            }

            if (Health <= 0)
            {
                Die(from, weapon);

                if (AttackerExist())
                {
                    GameContext.Players[from]
                    .GetCharacter()?
                    .SetEmote(Emote.Happy, Server.Tick + Server.TickSpeed);
                }

                return(false);
            }

            GameContext.CreateSound(Position, damage > 2
                ? Sound.PlayerPainLong
                : Sound.PlayerPainShort);

            SetEmote(Emote.Pain, Server.Tick + Server.TickSpeed / 2);
            return(true);
        }