public Entity(Map currentMap) { Performance.Push("Entity ctor"); VisibleRange = 0; IconIndex = 0; currentTarget = null; PreviousTarget = null; CurrentMap = currentMap; Performance.Push("Create base sprite"); sprite = new Sprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName("Human Peasant"))); Performance.Pop(); Performance.Push("new HateList"); HateList = new HateList(); Performance.Pop(); Performance.Push("new StateMachine"); StateMachine = new StateMachine(this); Performance.Pop(); Performance.Push("StateMachine.ChangeState"); StateMachine.ChangeState(new StateIdle(this)); Performance.Pop(); Performance.Pop(); }
private void ShowMultiUI() { // Fail-safe if (currentEntities.Length <= 1 || currentEntities.Length > 4) { return; } SpriteResource res = WarFile.GetSpriteResource(race == Race.Humans ? 360 : 359); }
private void ShowSingleUI() { // Fail-safe if (currentEntities.Length != 1) { return; } SpriteResource res = WarFile.GetSpriteResource(race == Race.Humans ? 360 : 359); SpriteResource resUnit = WarFile.GetSpriteResource(361); Entity ent = currentEntities[0]; UISpriteImage unitFrame = new UISpriteImage(new Sprite(res)); unitFrame.FixedSpriteFrame = ent.Mana > 0 ? 1 : 0; unitFrame.X = 0; unitFrame.Y = 0; AddComponent(unitFrame); UISpriteImage unitIcon = new UISpriteImage(new Sprite(resUnit)); unitIcon.FixedSpriteFrame = ent.IconIndex; unitIcon.X = 4; unitIcon.Y = 4; unitFrame.AddComponent(unitIcon); UILabel nameLabel = new UILabel(currentEntities[0].Name); nameLabel.TextAlign = TextAlignHorizontal.Left; nameLabel.X = 4; nameLabel.Y = unitIcon.Y + unitIcon.Height + 2; unitFrame.AddComponent(nameLabel); UIImage img = new UIImage(null); img.X = 35; img.Y = 20; img.Height = 3; img.BackgroundColor = new Color(0.0f, 1.0f, 0.0f, 1.0f); SetHealthbar(img, ent); unitFrame.AddComponent(img); healthBars.Add(ent, img); }
private void ShowBuildSubMenu() { // Remove all old components ClearComponents(); isInSubmenu = true; healthBars.Clear(); // No entities? Then just exit if (currentEntities == null || currentEntities.Length == 0) { return; } if (currentEntities.Length == 1) { ShowSingleUI(); } else { ShowMultiUI(); } int buttonIndex = 0; if (ShowCancel) { UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Cancel"); btn.OnMouseUpInside += (position) => { RebuildUI(); }; SetButtonPosition(btn, 5); AddComponent(btn); buttonIndex++; } }
public HumanConjurer(Map currentMap) : base(currentMap) { sprite = new UnitSprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName("Human Wizard"))); }
public OrcGrunt(Map currentMap) : base(currentMap) { sprite = new UnitSprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName("Orc Grunt"))); }
public HumanBarracks(Map currentMap) : base(currentMap) { sprite = new Sprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName("Human Barracks"))); }
public OrcTownhall(Map currentMap) : base(currentMap) { sprite = new Sprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName("Orc Base"))); }
public HumanFootman(Map currentMap) : base(currentMap) { sprite = new UnitSprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName("Human Warrior"))); }
internal static UISpriteImage FromSpriteResource(string name) { UISpriteImage res = new UISpriteImage(new UnitSprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName(name)))); return(res); }
private void RebuildUI() { // Remove all old components ClearComponents(); isInSubmenu = false; healthBars.Clear(); // No entities? Then just exit if (currentEntities == null || currentEntities.Length == 0) { return; } if (currentEntities.Length == 1) { ShowSingleUI(); } else { ShowMultiUI(); } int buttonIndex = 0; if (ShowMove) { UISpriteButton moveBtn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Move" + race); moveBtn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Move); }; SetButtonPosition(moveBtn, buttonIndex); AddComponent(moveBtn); buttonIndex++; } if (ShowStop) { UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Shield1" + (race == Race.Humans ? "" : "Orcs")); btn.OnMouseUpInside += (position) => { Stop(); }; SetButtonPosition(btn, buttonIndex); AddComponent(btn); buttonIndex++; } if (ShowAttack) { UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Sword1"); btn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Attack); }; SetButtonPosition(btn, buttonIndex); AddComponent(btn); buttonIndex++; } if (ShowRepair) { UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Repair"); btn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Repair); }; SetButtonPosition(btn, buttonIndex); AddComponent(btn); buttonIndex++; } if (ShowHarvest) { UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Harvest"); btn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Harvest); }; SetButtonPosition(btn, buttonIndex); AddComponent(btn); buttonIndex++; } if (ShowBuild) { UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Build"); btn.OnMouseUpInside += (position) => { ShowBuildSubMenu(); }; SetButtonPosition(btn, buttonIndex); AddComponent(btn); buttonIndex++; } if (ShowCancel) { UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Cancel"); btn.OnMouseUpInside += (position) => { RebuildUI(); }; SetButtonPosition(btn, 6); AddComponent(btn); buttonIndex++; } if (currentEntities.Length == 1) { currentEntities[0].AddCustomUI(this); } }
public OrcSpearman(Map currentMap) : base(currentMap) { sprite = new UnitSprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName("Orc Axethrower"))); }
public Corpse(Map currentMap) : base(currentMap) { sprite = new Sprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName("Corpse"))); }
public HumanArcher(Map currentMap) : base(currentMap) { sprite = new UnitSprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName("Human Bowman"))); }
public HumanStormwind(Map currentMap) : base(currentMap) { sprite = new Sprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName("Stormwind"))); }
public HumanCatapult(Map currentMap) : base(currentMap) { sprite = new UnitSprite(WarFile.GetSpriteResource(WarFile.KnowledgeBase.IndexByName("Human Catapult"))); }