public override void OnVoxelsSelected(SpellTree tree, List<Voxel> voxels) { bool destroyed = false; foreach (Voxel selected in voxels) { if (!selected.IsEmpty && !selected.Type.IsInvincible) { if (OnCast(tree)) { Vector3 p = selected.Position + Vector3.One * 0.5f; IndicatorManager.DrawIndicator("-" + ManaCost + " M", p, 1.0f, Color.Red); PlayState.ParticleManager.Trigger("star_particle", p, Color.White, 4); selected.Kill(); destroyed = true; } } } if (destroyed) { SoundManager.PlaySound(ContentPaths.Audio.tinkle, PlayState.CursorLightPos, true, 1.0f); } base.OnVoxelsSelected(tree, voxels); }
public SpellTreeDisplay(DwarfGUI gui, GUIComponent parent, SpellTree tree) : base(gui, parent) { Tree = tree; Scroller = new ScrollView(gui, this) { HeightSizeMode = SizeMode.Fit, WidthSizeMode = SizeMode.Fit }; MainPanel = new GUIComponent(gui, Scroller) { HeightSizeMode = SizeMode.Fixed, WidthSizeMode = SizeMode.Fixed }; InitializeSpellButtons(); }
public override void OnEntitiesSelected(SpellTree tree, List<Body> entities) { foreach (Body body in entities) { Creature creature = body.GetChildrenOfType<Creature>().FirstOrDefault(); if (creature == null) continue; else { foreach (Creature.Buff buff in Buffs) { if (OnCast(tree)) { Vector3 p = creature.AI.Position + Vector3.Up; IndicatorManager.DrawIndicator("-" + ManaCost + " M", p, 1.0f, Color.Red); creature.AddBuff(buff.Clone()); } } } } base.OnEntitiesSelected(tree, entities); }
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 static SpellTree CreateSpellTree(WorldManager world) { Texture2D icons = TextureManager.GetTexture(ContentPaths.GUI.icons); SpellTree toReturn = new SpellTree() { RootSpells = new List <SpellTree.Node>() { new SpellTree.Node() { Spell = new InspectSpell(world, InspectSpell.InspectType.InspectEntity), ResearchProgress = 10.0f, ResearchTime = 10.0f, Children = new List <SpellTree.Node>() { new SpellTree.Node() { Spell = new BuffSpell(world, new StatBuff(30.0f, new CreatureStats.StatNums() { Dexterity = 2.0f, Strength = 2.0f, Wisdom = 2.0f, Intelligence = 2.0f, Charisma = 0.0f, Constitution = 0.0f, Size = 0.0f }) { Particles = "star_particle", SoundOnStart = ContentPaths.Audio.powerup, SoundOnEnd = ContentPaths.Audio.wurp } ) { Name = "Minor Inspire", Description = "Makes the selected creatures work harder for 30 seconds (+2 to DEX, STR, INT and WIS)", Hint = "Click and drag to select creatures" }, ResearchProgress = 0.0f, ResearchTime = 30.0f, Children = new List <SpellTree.Node>() { new SpellTree.Node() { Spell = new BuffSpell(world, new StatBuff(60.0f, new CreatureStats.StatNums() { Dexterity = 5.0f, Strength = 5.0f, Wisdom = 5.0f, Intelligence = 5.0f, Charisma = 0.0f, Constitution = 0.0f, Size = 0.0f }) { Particles = "star_particle", SoundOnStart = ContentPaths.Audio.powerup, SoundOnEnd = ContentPaths.Audio.wurp } ) { Name = "Major Inspire", Description = "Makes the selected creatures work harder for 60 seconds (+5 to DEX, STR, INT and WIS)", Hint = "Click and drag to select creatures" }, Children = new List <SpellTree.Node>() { new SpellTree.Node() { Spell = new CreateEntitySpell(world, "Fairy", false) { Name = "Magic Helper", Description = "Creates a magical helper employee who persists for 30 seconds", Hint = "Click to spawn a helper" }, ResearchProgress = 0.0f, ResearchTime = 150.0f } }, ResearchProgress = 0.0f, ResearchTime = 60.0f, }, new SpellTree.Node() { Spell = new BuffSpell(world, new ThoughtBuff(30.0f, Thought.ThoughtType.Magic) { SoundOnStart = ContentPaths.Audio.powerup }) { Name = "Minor Happiness", Description = "Makes the selected creatures happy for 30 seconds.", Hint = "Click and drag to select creatures", Image = new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.icons), 32, 5, 2), TileRef = 21 }, ResearchTime = 60.0f, ResearchProgress = 0.0f, Children = new List <SpellTree.Node>() { new SpellTree.Node() { Spell = new BuffSpell(world, new ThoughtBuff(60.0f, Thought.ThoughtType.Magic) { SoundOnStart = ContentPaths.Audio.powerup }) { Name = "Major Happiness", Description = "Makes the selected creatures happy for 60 seconds.", Hint = "Click and drag to select creatures", Image = new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.icons), 32, 5, 2), TileRef = 21 }, ResearchTime = 120.0f, ResearchProgress = 0.0f } } } } } } }, new SpellTree.Node() { Spell = new InspectSpell(world, InspectSpell.InspectType.InspectBlock), ResearchProgress = 25.0f, ResearchTime = 25.0f, Children = new List <SpellTree.Node>() { new SpellTree.Node() { Spell = new PlaceBlockSpell(world, "Dirt", false), ResearchProgress = 0.0f, ResearchTime = 50.0f, Children = new List <SpellTree.Node>() { new SpellTree.Node() { ResearchProgress = 0.0f, ResearchTime = 100.0f, Spell = new PlaceBlockSpell(world, "Stone", false), Children = new List <SpellTree.Node>() { new SpellTree.Node() { ResearchProgress = 0.0f, ResearchTime = 150.0f, Spell = new DestroyBlockSpell(world) } } } } }, new SpellTree.Node() { Spell = new PlaceBlockSpell(world, "Magic", false) { Image = new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.icons), 32, 2, 3), Description = "Creates a temporary magic wall.", TileRef = 26 }, ResearchProgress = 0.0f, ResearchTime = 50.0f, Children = new List <SpellTree.Node>() { new SpellTree.Node() { ResearchProgress = 0.0f, ResearchTime = 100.0f, Spell = new PlaceBlockSpell(world, "Iron", true), Children = new List <SpellTree.Node>() { new SpellTree.Node() { ResearchProgress = 0.0f, ResearchTime = 150.0f, Spell = new PlaceBlockSpell(world, "Gold", true) } } } } } } }, new SpellTree.Node() { Spell = new BuffSpell(world, new OngoingHealBuff(2, 10) { Particles = "heart", SoundOnStart = ContentPaths.Audio.powerup, SoundOnEnd = ContentPaths.Audio.wurp }) { Name = "Minor Heal", Description = "Heals 2 damage per second for 10 seconds", Hint = "Click and drag to select creatures", Image = new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.icons), 32, 3, 2), TileRef = 19 }, ResearchProgress = 0.0f, ResearchTime = 30.0f, Children = new List <SpellTree.Node>() { new SpellTree.Node() { Spell = new BuffSpell(world, new OngoingHealBuff(5, 10) { Particles = "heart", SoundOnStart = ContentPaths.Audio.powerup, SoundOnEnd = ContentPaths.Audio.wurp }) { Name = "Major Heal", Description = "Heals 5 damage per second for 10 seconds", Hint = "Click and drag to select creatures", Image = new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.icons), 32, 3, 2), TileRef = 19 }, ResearchProgress = 0.0f, ResearchTime = 150.0f } } } } }; foreach (SpellTree.Node spell in toReturn.RootSpells) { spell.SetupParentsRecursive(); } return(toReturn); }
public override void OnVoxelsSelected(SpellTree tree, List<Voxel> voxels) { if (Transmute) return; bool got = false; foreach (Voxel voxel in voxels) { if (voxel.IsEmpty) { if (OnCast(tree)) { CreateEntity(voxel.Position + Vector3.One*0.5f); got = true; } } } if (got) { SoundManager.PlaySound(ContentPaths.Audio.tinkle, PlayState.CursorLightPos, true, 1.0f); } base.OnVoxelsSelected(tree, voxels); }
public override void OnVoxelsSelected(SpellTree tree, List<Voxel> voxels) { if (this.Type != InspectType.InspectBlock) return; string description = ""; bool first = true; foreach (Voxel selected in voxels) { if (!selected.IsEmpty) { if (!first) { description += "\n"; } else { first = false; } description += selected.TypeName + " at " + selected.GridPosition + ". Health: " + selected.Health; } } if (description != "") { PlayState.GUI.ToolTipManager.ToolTip = description; } else { PlayState.GUI.ToolTipManager.ToolTip = ""; } base.OnVoxelsSelected(tree, voxels); }
public virtual void OnVoxelsSelected(SpellTree tree, List<Voxel> voxels) { }
public virtual void OnVoxelsSelected(SpellTree tree, List <Voxel> voxels) { }
public virtual bool OnCast(SpellTree tree) { bool canCast = tree.CanCast(this); if (canCast) { tree.UseMagic(ManaCost); } else { SoundManager.PlaySound(ContentPaths.Audio.wurp, PlayState.CursorLightPos, true, 0.25f); PlayState.GUI.ToolTipManager.Popup("Not enough mana. Need " + (int)ManaCost + " but only have " + (int)tree.Mana); } return canCast; }
public virtual void OnEntitiesSelected(SpellTree tree, List<Body> entities) { }
public static SpellTree CreateSpellTree() { Texture2D icons = TextureManager.GetTexture(ContentPaths.GUI.icons); SpellTree toReturn = new SpellTree() { RootSpells = new List<SpellTree.Node>() { new SpellTree.Node() { Spell = new InspectSpell(InspectSpell.InspectType.InspectEntity), ResearchProgress = 10.0f, ResearchTime = 10.0f, Children = new List<SpellTree.Node>() { new SpellTree.Node() { Spell = new BuffSpell( new Creature.StatBuff(30.0f, new CreatureStats.StatNums() { Dexterity = 2.0f, Strength = 2.0f, Wisdom = 2.0f, Intelligence = 2.0f, Charisma = 0.0f, Constitution = 0.0f, Size = 0.0f }) {Particles = "star_particle", SoundOnStart = ContentPaths.Audio.powerup, SoundOnEnd = ContentPaths.Audio.wurp} ) { Name = "Minor Inspire", Description = "Makes the selected creatures work harder for 30 seconds (+2 to DEX, STR, INT and WIS)", Hint = "Click and drag to select creatures" }, ResearchProgress = 0.0f, ResearchTime = 30.0f, Children = new List<SpellTree.Node>() { new SpellTree.Node() { Spell = new BuffSpell( new Creature.StatBuff(60.0f, new CreatureStats.StatNums() { Dexterity = 5.0f, Strength = 5.0f, Wisdom = 5.0f, Intelligence = 5.0f, Charisma = 0.0f, Constitution = 0.0f, Size = 0.0f }) {Particles = "star_particle", SoundOnStart = ContentPaths.Audio.powerup, SoundOnEnd = ContentPaths.Audio.wurp} ) { Name = "Major Inspire", Description = "Makes the selected creatures work harder for 60 seconds (+5 to DEX, STR, INT and WIS)", Hint = "Click and drag to select creatures" }, Children = new List<SpellTree.Node>() { new SpellTree.Node() { Spell = new CreateEntitySpell("Fairy", false) { Name = "Magic Helper", Description = "Creates a magical helper employee who persists for 30 seconds", Hint = "Click to spawn a helper" }, ResearchProgress = 0.0f, ResearchTime = 150.0f } }, ResearchProgress = 0.0f, ResearchTime = 60.0f, }, new SpellTree.Node() { Spell = new BuffSpell(new Creature.ThoughtBuff(30.0f, Thought.ThoughtType.Magic) {SoundOnStart = ContentPaths.Audio.powerup}) { Name = "Minor Happiness", Description = "Makes the selected creatures happy for 30 seconds.", Hint = "Click and drag to select creatures", Image = new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.icons), 32, 5, 2) }, ResearchTime = 60.0f, ResearchProgress = 0.0f, Children = new List<SpellTree.Node>() { new SpellTree.Node() { Spell = new BuffSpell(new Creature.ThoughtBuff(60.0f, Thought.ThoughtType.Magic) {SoundOnStart = ContentPaths.Audio.powerup}) { Name = "Major Happiness", Description = "Makes the selected creatures happy for 60 seconds.", Hint = "Click and drag to select creatures", Image = new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.icons), 32, 5, 2) }, ResearchTime = 120.0f, ResearchProgress = 0.0f } } } } } } }, new SpellTree.Node() { Spell = new InspectSpell(InspectSpell.InspectType.InspectBlock), ResearchProgress = 25.0f, ResearchTime = 25.0f, Children = new List<SpellTree.Node>() { new SpellTree.Node() { Spell = new PlaceBlockSpell("Dirt", false), ResearchProgress = 0.0f, ResearchTime = 50.0f, Children = new List<SpellTree.Node>() { new SpellTree.Node() { ResearchProgress = 0.0f, ResearchTime = 100.0f, Spell = new PlaceBlockSpell("Stone", false), Children = new List<SpellTree.Node>() { new SpellTree.Node() { ResearchProgress = 0.0f, ResearchTime = 150.0f, Spell = new DestroyBlockSpell() } } } } }, new SpellTree.Node() { Spell = new PlaceBlockSpell("Magic", false) { Image = new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.icons), 32, 2, 3), Description = "Creates a temporary magic wall." }, ResearchProgress = 0.0f, ResearchTime = 50.0f, Children = new List<SpellTree.Node>() { new SpellTree.Node() { ResearchProgress = 0.0f, ResearchTime = 100.0f, Spell = new PlaceBlockSpell("Iron", true), Children = new List<SpellTree.Node>() { new SpellTree.Node() { ResearchProgress = 0.0f, ResearchTime = 150.0f, Spell = new PlaceBlockSpell("Gold", true) } } } } } } }, new SpellTree.Node() { Spell = new BuffSpell(new Creature.OngoingHealBuff(2, 10) { Particles = "heart", SoundOnStart = ContentPaths.Audio.powerup, SoundOnEnd = ContentPaths.Audio.wurp}) { Name = "Minor Heal", Description = "Heals 2 damage per second for 10 seconds", Hint = "Click and drag to select creatures", Image = new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.icons), 32, 3, 2) }, ResearchProgress = 0.0f, ResearchTime = 30.0f, Children = new List<SpellTree.Node>() { new SpellTree.Node() { Spell = new BuffSpell(new Creature.OngoingHealBuff(5, 10){Particles = "heart", SoundOnStart = ContentPaths.Audio.powerup, SoundOnEnd = ContentPaths.Audio.wurp}) { Name = "Major Heal", Description = "Heals 5 damage per second for 10 seconds", Hint = "Click and drag to select creatures", Image = new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.icons), 32, 3, 2) }, ResearchProgress = 0.0f, ResearchTime = 150.0f } } } } }; foreach (SpellTree.Node spell in toReturn.RootSpells) { spell.SetupParentsRecursive(); } return toReturn; }
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); } }
public override void OnVoxelsSelected(SpellTree tree, List<Voxel> voxels) { HashSet<Point3> chunksToRebuild = new HashSet<Point3>(); bool placed = false; foreach (Voxel selected in voxels) { if (selected != null && ((!Transmute && selected.IsEmpty) || Transmute && !selected.IsEmpty) && OnCast(tree)) { Vector3 p = selected.Position + Vector3.One*0.5f; IndicatorManager.DrawIndicator("-" + ManaCost + " M",p, 1.0f, Color.Red); PlayState.ParticleManager.Trigger("star_particle", p, Color.White, 4); VoxelLibrary.PlaceType(VoxelLibrary.GetVoxelType(VoxelType), selected); if (VoxelType == "Magic") { new VoxelListener(PlayState.ComponentManager, PlayState.ComponentManager.RootComponent, PlayState.ChunkManager, selected) { DestroyOnTimer = true, DestroyTimer = new Timer(5.0f + MathFunctions.Rand(-0.5f, 0.5f), true) }; } placed = true; chunksToRebuild.Add(selected.ChunkID); } } foreach (Point3 point in chunksToRebuild) { VoxelChunk chunk = PlayState.ChunkManager.ChunkData.ChunkMap[point]; chunk.ShouldRebuild = true; chunk.NotifyTotalRebuild(true); } if (placed) { SoundManager.PlaySound(ContentPaths.Audio.tinkle, PlayState.CursorLightPos, true, 1.0f); } RechargeTimer.Reset(RechargeTimer.TargetTimeSeconds); base.OnVoxelsSelected(tree, voxels); }
public virtual void OnEntitiesSelected(SpellTree tree, List <Body> entities) { }
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 override void OnEntitiesSelected(SpellTree tree, List<Body> entities) { if (!Transmute) return; foreach (Body body in entities) { if (OnCast(tree)) { CreateEntity(body.Position); body.Delete(); } } base.OnEntitiesSelected(tree, entities); }
public override void OnEntitiesSelected(SpellTree tree, List<Body> entities) { if (this.Type != InspectType.InspectEntity) return; string desc = ""; bool first = true; foreach (Body body in entities) { if (!first) desc += "\n"; desc += body.GetDescription(); first = false; } if (desc != "") { PlayState.GUI.ToolTipManager.ToolTip = desc; } else { PlayState.GUI.ToolTipManager.ToolTip = ""; } base.OnEntitiesSelected(tree, entities); }