Пример #1
0
 public override void Use(EntityBase user)
 {
     base.Use(user);
     if (user is Worker)
     {
         var workerCast = (Worker) user;
         workerCast.ResourceCount = 0;
     }
 }
Пример #2
0
 public override void Use(EntityBase user)
 {
     base.Use(user);
     //TODO: Blood/Glue effect
     for (int i = 0; i < 5; i++)
     {
         MyGameMode.AddEffect(new GlueParticle(Position));
     }
 }
Пример #3
0
        public Projectile()
        {
            Damage = 0;
            Element = Entity.DamageElement.Normal;
            Target = null;
            Speed = 0;

            toDraw = new AnimatedSprite(10);

            toDraw.Sprites = new List<Sprite>(ExternalResources.GetSprites("Resources/Sprites/Projectiles"));
            toDraw.Reset();
        }
Пример #4
0
        public override void Use(EntityBase user)
        {
            base.Use(user);
            if (user is Worker)
            {
                var workerCast = (Worker) user;

                if (!workerCast.IsHoldingResources)
                {
                    byte toGive = ResourcesPerTrip;
                    if (RemainingResources < ResourcesPerTrip)
                    {
                        toGive = (byte) RemainingResources;
                    }
                    RemainingResources -= toGive;

                    workerCast.GiveResource(ResourceType, toGive);
                }
            }
        }
Пример #5
0
        protected EntityBase()
        {
            HotkeyString = "";

            Neutral = false;
            HasBeenViewed = false;
            Team = 0;

            Type = Entity.EntityType.Unit;
            BoundsSize = new Vector2f(20, 20);
            WorldId = 0;
            EntityToUse = null;
            WorldEntities = null;
            rallyPoints = new List<Entity.RallyPoint>();
            Health = 0;
            MaxHealth = 0;
            Position = new Vector2f();
            Energy = 0;
            MaxHealth = 0;
            EnergyRegenRate = 0;
            MyGameMode = null;
        }
Пример #6
0
        private void sendUseCommand(EntityBase entity, bool rallyReset = true)
        {
            if (selectedUnits != null)
            {
                var idList = new List<ushort>();
                foreach (EntityBase entityBase in selectedUnits)
                {
                    idList.Add(entityBase.WorldId);
                }
                if (idList.Count > 0)
                {
                    InputHandler.SendEntityUseChange(idList.ToArray(), entity.WorldId, rallyReset);
                }

                PlayUseSound(ExternalResources.UseSounds.CliffUsing);
            }
        }
Пример #7
0
        protected void FilterSelectedUnits(ref EntityBase[] listArray)
        {
            if (listArray != null)
            {
                var list = new List<EntityBase>(listArray);
                foreach (EntityBase entityBase in listArray)
                {
                    if (entities.ContainsValue(entityBase) == false || unitFilter(entityBase))
                        list.Remove(entityBase);
                }

                listArray = list.ToArray();
            }
        }
Пример #8
0
 protected bool unitFilter(EntityBase entity)
 {
     return entity.Team != myPlayer.Team || entity.Neutral;
 }
Пример #9
0
 public virtual void OnHit(EntityBase entity)
 {
     //play sound or something
 }
Пример #10
0
 public HotkeySheet GetHotkeySheet(EntityBase entity)
 {
     return Settings.GetSheet(entity.HotkeyString);
 }
Пример #11
0
        protected override void ParseUpdate(MemoryStream memoryStream)
        {
            var reader = new BinaryReader(memoryStream);
            Damage = reader.ReadSingle();
            Element = (Entity.DamageElement) reader.ReadByte();
            Speed = reader.ReadSingle();
            Position = new Vector2f(reader.ReadSingle(), reader.ReadSingle());
            var targetId = reader.ReadUInt16();

            if(MyGameMode.EntityBases.ContainsKey(targetId))
            {
                Target = MyGameMode.EntityBases[targetId];
            }
        }
Пример #12
0
 protected virtual void onAttack(EntityBase ent)
 {
     if (!RangedUnit) //Happy asshole?
     {
         ent.OnTakeDamage(StandardAttackDamage, StandardAttackElement);
     }
     //Ranged units send projectiles, this is handled in the game mode, and is not needed to do prediction here
 }
Пример #13
0
 public override void OnUseChange(EntityBase entity)
 {
     base.OnUseChange(entity);
     MyGameMode.PlayUseSound(ExternalResources.UseSounds.CliffUsing);
 }
Пример #14
0
 private void AddEntity(EntityBase entity, ushort id)
 {
     if (entities.ContainsKey(id) == false)
     {
         entity.MyGameMode = this;
         entity.WorldId = id;
         entities.Add(id, entity);
     }
 }
Пример #15
0
        private void ParseEntityToUseChange(MemoryStream memoryStream)
        {
            var reader = new BinaryReader(memoryStream);
            bool isNotNull = reader.ReadBoolean();

            if (isNotNull)
            {
                ushort id = reader.ReadUInt16();
                if (WorldEntities.ContainsKey(id))
                {
                    EntityToUse = WorldEntities[id];
                    OnUseChange(EntityToUse);
                }
            }
            else
            {
                EntityToUse = null;
            }
        }
Пример #16
0
 public virtual void Use(EntityBase user)
 {
     //minerals may give the user minerals to hold, etc
 }
Пример #17
0
 public virtual void OnUseChange(EntityBase entity)
 {
     //Play a sound or something
 }