public override void Use(EntityBase user) { base.Use(user); if (user is Worker) { var workerCast = (Worker) user; workerCast.ResourceCount = 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)); } }
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(); }
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); } } }
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; }
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); } }
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(); } }
protected bool unitFilter(EntityBase entity) { return entity.Team != myPlayer.Team || entity.Neutral; }
public virtual void OnHit(EntityBase entity) { //play sound or something }
public HotkeySheet GetHotkeySheet(EntityBase entity) { return Settings.GetSheet(entity.HotkeyString); }
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]; } }
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 }
public override void OnUseChange(EntityBase entity) { base.OnUseChange(entity); MyGameMode.PlayUseSound(ExternalResources.UseSounds.CliffUsing); }
private void AddEntity(EntityBase entity, ushort id) { if (entities.ContainsKey(id) == false) { entity.MyGameMode = this; entity.WorldId = id; entities.Add(id, entity); } }
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; } }
public virtual void Use(EntityBase user) { //minerals may give the user minerals to hold, etc }
public virtual void OnUseChange(EntityBase entity) { //Play a sound or something }