Exemple #1
0
        private void HaveAttacked(SolidBody attacked, Vec2 position, float angle, IBullet bullet)
        {
            PointF locationObject = attacked.Shape.Location;
            ulong  idParent       = (Parent as Weapon).Owner.ID;

            float newDistance = VectorMethod.DefineDistance(position, new Vec2(locationObject.X, locationObject.Y));

            Parent.Model.AddOutgoingMessage(new MakedShot(idParent, angle, newDistance));

            if (attacked == null)
            {
                return;
            }

            var damageMsg = new GotDamage(idParent, bullet.Damage);

            attacked.Parent.Update(damageMsg);

            //определяем убили ли мы противника
            Healthy healthyAttacked = attacked.Parent.Components.GetComponent <Healthy>();

            if (healthyAttacked == null)
            {
                return;
            }
            //если убили засчитываем фраг
            if (healthyAttacked.HP < bullet.Damage)
            {
                (Parent as Weapon).Owner.Update(new MakedKill(idParent));
            }
        }
Exemple #2
0
        public static Gamer CreateGamer(IModelForComponents model, PointF location)
        {
            var      gameObject = new Gamer(model, TypesGameObject.Player, TypesBehaveObjects.Active);
            ShapeDef CircleDef  = CreateBaseCircleDef(setupsGamer, SizeGamer);

            CircleDef.Filter.CategoryBits = (ushort)CollideCategory.Player;
            CircleDef.Filter.MaskBits     = (ushort)CollideCategory.Box | (ushort)CollideCategory.Stone
                                            | (ushort)CollideCategory.Grenade;

            var body = new SolidBody(gameObject, new RectangleF(location, SizeGamer), new ShapeDef[] { CircleDef });

            gameObject.Components.Add(body);

            var movement = new Movement(gameObject, SpeedGamer);

            gameObject.Components.Add(movement);

            var collector = new Collector(gameObject);

            gameObject.Components.Add(collector);

            var currentWeapon = new CurrentWeapon(gameObject);

            gameObject.Components.Add(currentWeapon);

            var healthy = new Healthy(gameObject);

            gameObject.Components.Add(healthy);

            var statistics = new Statistics(gameObject);

            gameObject.Components.Add(statistics);

            model.AddOrUpdateGameObject(gameObject);
            model.Players.Add(gameObject);

            return(gameObject);
        }