public void InitializeSpellButtonRecursive(SpellButton button) { foreach (SpellTree.Node spell in button.Spell.Children) { SpellButton newButton = new SpellButton() { Spell = spell, ImageButton = new Button(GUI, MainPanel, spell.Spell.Name, GUI.SmallFont, Button.ButtonMode.ImageButton, spell.Spell.Image) { ToolTip = spell.Spell.Description, KeepAspectRatio = true, DontMakeSmaller = true, DontMakeBigger = true }, Level = button.Level + 1, Children = new List <SpellButton>(), Parent = button }; SpellTree.Node rSpell = spell; newButton.ImageButton.OnClicked += () => ImageButton_OnClicked(rSpell); button.Children.Add(newButton); SpellButtons.Add(newButton); InitializeSpellButtonRecursive(newButton); } }
public static void MakeFakeSubtree(WorldManager world, SpellTree.Node node) { int numChildren = (int)MathFunctions.Rand(-2, 4); for (int j = 0; j < numChildren; j++) { SpellTree.Node newNode = new SpellTree.Node() { ResearchProgress = MathFunctions.Rand(0, 101.0f), ResearchTime = 100.0f, Spell = new DestroyBlockSpell(world) }; node.Children.Add(newNode); MakeFakeSubtree(world, newNode); } }
private void ImageButton_OnClicked(SpellTree.Node spell) { if (spell.IsResearched || (spell.Parent != null && !spell.Parent.IsResearched)) { return; } else { List <CreatureAI> wizards = Faction.FilterMinionsWithCapability(PlayState.Master.SelectedMinions, GameMaster.ToolMode.Magic); foreach (CreatureAI wizard in wizards) { wizard.Tasks.Add(new ActWrapperTask(new GoResearchSpellAct(wizard, spell)) { Priority = Task.PriorityType.Low }); } } }
public void Research(SpellTree.Node spell) { List <CreatureAI> wizards = Faction.FilterMinionsWithCapability(Player.Faction.Minions, Task.TaskCategory.Research); var body = Player.Faction.FindNearestItemWithTags("Research", Vector3.Zero, false); if (body != null) { Player.World.ShowToolPopup(string.Format("{0} wizard{2} sent to research {1}", wizards.Count, spell.Spell.Name, wizards.Count > 1 ? "s" : "")); Player.TaskManager.AddTask(new ResearchSpellTask(spell.Spell.Name) { Priority = Task.PriorityType.Low }); } else { Player.World.ShowToolPopup(string.Format("Can't research {0}, no magical research object has been built.", spell.Spell.Name)); } }
public void InitializeSpellButtons() { SpellButtons = new List <SpellButton>(); int xOffset = 15; int yOffset = 32; SpellButton fakeButton = new SpellButton() { Children = new List <SpellButton>() }; foreach (SpellTree.Node spell in Tree.RootSpells) { SpellButton newButton = new SpellButton() { Spell = spell, ImageButton = new Button(GUI, MainPanel, spell.Spell.Name, GUI.SmallFont, Button.ButtonMode.ImageButton, spell.Spell.Image) { ToolTip = spell.Spell.Description, KeepAspectRatio = true, DontMakeSmaller = true, DontMakeBigger = true, LocalBounds = new Rectangle(xOffset, yOffset, 0, 0), }, Children = new List <SpellButton>(), Level = 0, Parent = fakeButton }; SpellTree.Node rSpell = spell; newButton.ImageButton.OnClicked += () => ImageButton_OnClicked(rSpell); SpellButtons.Add(newButton); InitializeSpellButtonRecursive(newButton); fakeButton.Children.Add(newButton); } //Rectangle newRect = AlignImagesTree(fakeButton, xOffset, yOffset); //xOffset = newRect.Left; //yOffset = newRect.Bottom; //MainPanel.LocalBounds = new Rectangle(0, 0, Math.Max(MainPanel.LocalBounds.Width, newRect.Width + xOffset), Math.Max(MainPanel.LocalBounds.Height, newRect.Height + yOffset)); CalculateNodePositions(fakeButton, 48, 10, 100); }
public static SpellTree MakeFakeTree(WorldManager world) { SpellTree toReturn = new SpellTree(); int numRoots = (int)MathFunctions.Rand(3, 5); for (int i = 0; i < numRoots; i++) { float val = MathFunctions.Rand(0, 1.0f); SpellTree.Node root = new SpellTree.Node() { ResearchProgress = MathFunctions.Rand(0, 101.0f), ResearchTime = 100.0f, Spell = new InspectSpell(world, val > 0.5f ? InspectSpell.InspectType.InspectBlock : InspectSpell.InspectType.InspectEntity) }; toReturn.RootSpells.Add(root); MakeFakeSubtree(world, root); } return(toReturn); }
public void Research(SpellTree.Node spell) { List <CreatureAI> wizards = Faction.FilterMinionsWithCapability(Player.SelectedMinions, GameMaster.ToolMode.Magic); var body = Player.Faction.FindNearestItemWithTags("Research", Vector3.Zero, false); if (body != null) { Player.World.ShowToolPopup(string.Format("{0} wizard{2} sent to research {1}", wizards.Count, spell.Spell.Name, wizards.Count > 1 ? "s" : "")); foreach (CreatureAI wizard in wizards) { wizard.Tasks.Add(new ActWrapperTask(new GoResearchSpellAct(wizard, spell)) { Priority = Task.PriorityType.Low }); } } else { Player.World.ShowToolPopup(string.Format("Can't research {0}, no library has been built.", spell.Spell.Name)); } }
public ResearchSpellAct(CreatureAI agent, SpellTree.Node spell) : base(agent) { Spell = spell; }
public GoResearchSpellAct(CreatureAI creature, SpellTree.Node node) : base(creature) { Spell = node; Name = "Research spell " + node.Spell.Name; }
public static SpellTree MakeFakeTree() { SpellTree toReturn = new SpellTree(); int numRoots = (int) MathFunctions.Rand(3, 5); for (int i = 0; i < numRoots; i++) { float val = MathFunctions.Rand(0, 1.0f); SpellTree.Node root = new SpellTree.Node() { ResearchProgress = MathFunctions.Rand(0, 101.0f), ResearchTime = 100.0f, Spell = new InspectSpell(val > 0.5f ? InspectSpell.InspectType.InspectBlock : InspectSpell.InspectType.InspectEntity) }; toReturn.RootSpells.Add(root); MakeFakeSubtree(root); } return toReturn; }
public static void MakeFakeSubtree(SpellTree.Node node) { int numChildren = (int)MathFunctions.Rand(-2, 4); for (int j = 0; j < numChildren; j++) { SpellTree.Node newNode = new SpellTree.Node() { ResearchProgress = MathFunctions.Rand(0, 101.0f), ResearchTime = 100.0f, Spell = new DestroyBlockSpell() }; node.Children.Add(newNode); MakeFakeSubtree(newNode); } }