public void CreateEntity(Vector3 position) { EntityFactory.CreateEntity <Body>(Entity, position); PlayState.ParticleManager.Trigger("star_particle", position, Color.White, 4); Vector3 p = position + Vector3.Up; IndicatorManager.DrawIndicator("-" + ManaCost + " M", p, 1.0f, Color.Red); }
/// <summary> Pay the creature this amount of money. The money goes into the creature's wallet. </summary> public void AddMoney(DwarfBux pay) { Stats.Money += pay; bool good = pay > 0; Color textColor = good ? GameSettings.Default.Colors.GetColor("Positive", Color.Green) : GameSettings.Default.Colors.GetColor("Negative", Color.Red); string prefix = good ? "+" : ""; IndicatorManager.DrawIndicator(prefix + pay, Position + Vector3.Up + MathFunctions.RandVector3Cube() * 0.5f, 1.0f, textColor); }
public override Act CreateScript(Creature creature) { Name = "Flee Entity: " + ScaryEntity.Name + " " + ScaryEntity.GlobalID; IndicatorManager.DrawIndicator(IndicatorManager.StandardIndicators.Exclaim, creature.AI.Position, 1.0f, 1.0f, Vector2.UnitY * -32); return(new FleeEntityAct(creature.AI) { Entity = ScaryEntity, PathLength = Distance }); }
public void AddMoney(float pay) { Status.Money += pay; bool good = pay > 0; Color textColor = good ? Color.Green : Color.Red; string prefix = good ? "+" : ""; IndicatorManager.DrawIndicator(prefix + "$" + pay, Position + Vector3.Up + MathFunctions.RandVector3Cube() * 0.5f, 1.0f, textColor); }
public override void Die() { if (HitAnimation != null) { HitAnimation.Reset(); HitAnimation.Play(); IndicatorManager.DrawIndicator(HitAnimation, Position, HitAnimation.FrameHZ * HitAnimation.Frames.Count, 1.0f, Vector2.Zero, Color.White, false); } base.Die(); }
public void DrawIndicator(ImageFrame image, Color tint) { if (!((DateTime.Now - LastIndicatorTime).TotalSeconds >= IndicatorRateLimit)) { return; } IndicatorManager.DrawIndicator(image, AI.Position + new Vector3(0, 0.5f, 0), 1, 1.5f, new Vector2(image.SourceRect.Width / 2.0f, -image.SourceRect.Height / 2.0f), tint); LastIndicatorTime = DateTime.Now; }
public void DrawIndicator(IndicatorManager.StandardIndicators indicator) { if (!((DateTime.Now - LastIndicatorTime).TotalSeconds >= IndicatorRateLimit)) { return; } IndicatorManager.DrawIndicator(indicator, AI.Position + new Vector3(0, 0.5f, 0), 1, 2, new Vector2(16, -16)); LastIndicatorTime = DateTime.Now; }
public void UpdateXP() { foreach (int xp in XPEvents) { Stats.XP += xp; string sign = xp > 0 ? "+" : ""; IndicatorManager.DrawIndicator(sign + xp.ToString() + " XP", Position + Vector3.Up + MathFunctions.RandVector3Cube() * 0.5f, 0.5f, xp > 0 ? Color.Green : Color.Red); } XPEvents.Clear(); }
public bool Perform(Creature performer, Vector3 pos, Voxel other, DwarfTime time, float bonus, string faction) { if (other == null) { return(false); } switch (TriggerMode) { case AttackTrigger.Timer: RechargeTimer.Update(time); if (!RechargeTimer.HasTriggered) { return(false); } break; case AttackTrigger.Animation: if (performer.Sprite.CurrentAnimation == null || performer.Sprite.CurrentAnimation.CurrentFrame != TriggerFrame) { return(false); } break; } switch (Mode) { case AttackMode.Melee: { other.Health -= DamageAmount + bonus; PlayNoise(other.Position); if (HitParticles != "") { PlayState.ParticleManager.Trigger(HitParticles, other.Position, Color.White, 5); } if (HitAnimation != null) { HitAnimation.Reset(); HitAnimation.Play(); IndicatorManager.DrawIndicator(HitAnimation, other.Position + Vector3.One * 0.5f, 0.6f, 2.0f, MathFunctions.RandVector2Circle(), Color.White, MathFunctions.Rand() > 0.5f); } break; } case AttackMode.Ranged: { LaunchProjectile(pos, other.Position, faction); break; } } return(true); }
void InputManager_MouseClickedCallback(InputManager.MouseButton button) { if (button != InputManager.MouseButton.Right || World.UserInterface.CurrentTool != this || KeyManager.RotationEnabled(World.Renderer.Camera)) { return; } var mouseState = KeyManager.TrueMousePos; var vox = VoxelHelpers.FindFirstVisibleVoxelOnScreenRay( World.ChunkManager, mouseState.X, mouseState.Y, World.Renderer.Camera, GameState.Game.GraphicsDevice.Viewport, 150.0f, false, voxel => voxel.IsValid && (!voxel.IsEmpty || voxel.LiquidLevel > 0)); if (!vox.IsValid) { return; } foreach (CreatureAI minion in World.PersistentData.SelectedMinions) { if (minion.Creature.Stats.IsAsleep) { continue; } if (minion.CurrentTask.HasValue(out var currentTask)) { minion.AssignTask(currentTask); // Make sure the minion keeps the current task - avoided if the task stays in their queue in the first place! } var above = VoxelHelpers.GetVoxelAbove(vox); if (above.IsValid) { minion.Blackboard.SetData("MoveTarget", above); var moveTask = new ActWrapperTask(new GoToNamedVoxelAct("MoveTarget", PlanAct.PlanType.Adjacent, minion)); moveTask.AutoRetry = false; moveTask.Priority = TaskPriority.Urgent; minion.ChangeTask(moveTask); } } OnConfirm(World.PersistentData.SelectedMinions); if (World.PersistentData.SelectedMinions.Count > 0) { IndicatorManager.DrawIndicator(IndicatorManager.StandardIndicators.DownArrow, vox.WorldPosition + Vector3.One * 0.5f, 0.5f, 2.0f, new Vector2(0, -50), Color.LightGreen); } }
public override MaybeNull <Act> CreateScript(Creature creature) { if (ScaryEntity == null || creature == null || creature.AI == null) { return(null); // Todo: How is this possible? } Name = "Flee Entity: " + ScaryEntity.Name + " " + ScaryEntity.GlobalID; IndicatorManager.DrawIndicator(IndicatorManager.StandardIndicators.Exclaim, creature.AI.Position, 1.0f, 1.0f, Vector2.UnitY * -32); return(new FleeEntityAct(creature.AI) { Entity = ScaryEntity, PathLength = Distance, ParentTask = this }); }
void InputManager_MouseClickedCallback(InputManager.MouseButton button) { if (button != InputManager.MouseButton.Right || Player.CurrentTool != this || KeyManager.RotationEnabled()) { return; } var mouseState = KeyManager.TrueMousePos; var vox = VoxelHelpers.FindFirstVisibleVoxelOnScreenRay( Player.World.ChunkManager.ChunkData, mouseState.X, mouseState.Y, Player.World.Camera, GameState.Game.GraphicsDevice.Viewport, 150.0f, false, voxel => voxel.IsValid && (!voxel.IsEmpty || voxel.WaterCell.WaterLevel > 0)); if (!vox.IsValid) { return; } foreach (CreatureAI minion in Player.SelectedMinions) { if (minion.Creature.IsAsleep) { continue; } if (minion.CurrentTask != null) { minion.AssignTask(minion.CurrentTask); if (minion.CurrentTask.Script != null) { minion.CurrentAct.OnCanceled(); minion.CurrentTask.Script.Initialize(); } minion.CurrentTask.SetupScript(minion.Creature); minion.CurrentTask = null; } var above = VoxelHelpers.GetVoxelAbove(vox); minion.Blackboard.SetData("MoveTarget", above); minion.CurrentTask = new GoToNamedVoxelAct("MoveTarget", PlanAct.PlanType.Adjacent, minion).AsTask(); minion.CurrentTask.AutoRetry = false; } OnConfirm(Player.SelectedMinions); IndicatorManager.DrawIndicator(IndicatorManager.StandardIndicators.DownArrow, vox.WorldPosition + Vector3.One * 0.5f, 0.5f, 2.0f, new Vector2(0, -50), Color.LightGreen); }
public override void Update(DwarfTime Time, ChunkManager Chunks, Camera Camera) { if (Active) { // Prevent towers from healing when they have no charge. var magicalObject = GetComponent <MagicalObject>(); if (magicalObject.HasValue(out var magObject) && magObject.CurrentCharges == 0) { return; } HealTimer.Update(Time); if (HealTimer.HasTriggered) { var objects = World.EnumerateIntersectingObjects(new BoundingBox(-Vector3.One * HealRadius + Position, Vector3.One * HealRadius + Position), CollisionType.Dynamic); foreach (var obj in objects) { if (obj.GetRoot().GetComponent <Creature>().HasValue(out var creature)) { if (creature.AI == null || creature.AI.Faction != creature.World.PlayerFaction || creature.Hp == creature.MaxHealth) { continue; } if (MathFunctions.RandEvent(0.5f)) { creature.Heal(HealIncrease); IndicatorManager.DrawIndicator((HealIncrease).ToString() + " HP", creature.Physics.Position, 1.0f, GameSettings.Default.Colors.GetColor("Positive", Microsoft.Xna.Framework.Color.Green)); creature.DrawLifeTimer.Reset(); World.ParticleManager.Trigger("star_particle", obj.Position, Color.Red, 10); World.ParticleManager.TriggerRay("star_particle", Position, obj.Position); SoundManager.PlaySound(ContentPaths.Audio.tinkle, obj.Position, true, 1.0f); if (magicalObject.HasValue(out var magObj)) { magObj.CurrentCharges -= 1; if (magObj.CurrentCharges == 0) { return; } } } } } } } base.Update(Time, Chunks, Camera); }
private IEnumerable <Act.Status> PerformOnVoxel(Creature performer, Vector3 pos, KillVoxelTask DigAct, DwarfTime time, float bonus, string faction) { var tool = ActHelper.GetEquippedItem(performer, "Tool"); // Play the attack animations. Creature.CurrentCharacterMode = tool.Tool_AttackAnimation; Creature.OverrideCharacterMode = true; Creature.Sprite.ResetAnimations(Creature.CurrentCharacterMode); Creature.Sprite.PlayAnimations(Creature.CurrentCharacterMode); while (true) { if (!DigAct.Voxel.IsValid) { performer.AI.SetTaskFailureReason("Failed to dig. Voxel was not valid."); yield return(Act.Status.Fail); yield break; } Drawer2D.DrawLoadBar(performer.World.Renderer.Camera, DigAct.Voxel.WorldPosition + Vector3.One * 0.5f, Color.White, Color.Black, 32, 1, (float)DigAct.VoxelHealth / DigAct.Voxel.Type.StartingHealth); while (!performer.Sprite.AnimPlayer.HasValidAnimation() || performer.Sprite.AnimPlayer.CurrentFrame < tool.Tool_AttackTriggerFrame) { if (performer.Sprite.AnimPlayer.HasValidAnimation()) { performer.Sprite.AnimPlayer.Play(); } yield return(Act.Status.Running); } DigAct.VoxelHealth -= (tool.Tool_AttackDamage + bonus); DigAct.Voxel.Type.HitSound.Play(DigAct.Voxel.WorldPosition); if (!String.IsNullOrEmpty(tool.Tool_AttackHitParticles)) { performer.Manager.World.ParticleManager.Trigger(tool.Tool_AttackHitParticles, DigAct.Voxel.WorldPosition, Color.White, 5); } if (!String.IsNullOrEmpty(tool.Tool_AttackHitEffect)) { IndicatorManager.DrawIndicator(Library.CreateSimpleAnimation(tool.Tool_AttackHitEffect), DigAct.Voxel.WorldPosition + Vector3.One * 0.5f, 10.0f, 1.0f, MathFunctions.RandVector2Circle() * 10, tool.Tool_AttackHitColor, MathFunctions.Rand() > 0.5f); } yield return(Act.Status.Success); yield break; } }
public override Act CreateScript(Creature creature) { var otherCreature = EntityToKill.GetRoot().GetComponent <Creature>(); if (otherCreature != null && !creature.AI.FightOrFlight(otherCreature.AI)) { Name = "Flee Entity: " + EntityToKill.Name + " " + EntityToKill.GlobalID; IndicatorManager.DrawIndicator(IndicatorManager.StandardIndicators.Exclaim, creature.AI.Position, 1.0f, 1.0f, Vector2.UnitY * -32); return(new FleeEntityAct(creature.AI) { Entity = EntityToKill, PathLength = 5 }); } return(new KillEntityAct(EntityToKill, creature.AI, Mode)); }
public override void Update(DwarfTime time, Creature creature) { DamageTimer.Update(time); if (DamageTimer.HasTriggered) { creature.Heal(DamagePerSecond); creature.DrawLifeTimer.Reset(); IndicatorManager.DrawIndicator((DamagePerSecond).ToString() + " HP", creature.Physics.Position, 1.0f, GameSettings.Current.Colors.GetColor("Positive", Microsoft.Xna.Framework.Color.Green)); } base.Update(time, creature); }
/// <summary> Add a custom thought to the creature </summary> public void AddThought(Thought thought) { if (HasThought(thought.Description)) { return; } Thoughts.Add(thought); var good = thought.HappinessModifier > 0; var textColor = good ? GameSettings.Default.Colors.GetColor("Positive", Color.Green) : GameSettings.Default.Colors.GetColor("Negative", Color.Red); var prefix = good ? "+" : ""; var postfix = good ? ":)" : ":("; IndicatorManager.DrawIndicator(prefix + thought.HappinessModifier + " " + postfix, Creature.Physics.Position + Vector3.Up + MathFunctions.RandVector3Cube() * 0.5f, 1.0f, textColor); }
public override void Die() { if (HitAnimation != null) { HitAnimation.Reset(); HitAnimation.Play(); if (Target != null) { Vector3 camvelocity0 = GameState.Game.GraphicsDevice.Viewport.Project(Position, PlayState.Camera.ProjectionMatrix, PlayState.Camera.ViewMatrix, Matrix.Identity); Vector3 camvelocity1 = GameState.Game.GraphicsDevice.Viewport.Project(Position + Velocity, PlayState.Camera.ProjectionMatrix, PlayState.Camera.ViewMatrix, Matrix.Identity); IndicatorManager.DrawIndicator(HitAnimation, Target.Position, HitAnimation.FrameHZ * HitAnimation.Frames.Count + 1.0f, 1.0f, Vector2.Zero, Color.White, camvelocity1.X - camvelocity0.X > 0); } } base.Die(); }
public override MaybeNull <Act> CreateScript(Creature creature) { if (creature.IsDead || creature.AI.IsDead) { return(null); } if (EntityToKill.GetRoot().GetComponent <Creature>().HasValue(out var otherCreature)) { if (!otherCreature.IsDead && otherCreature.AI != null) { // Flee if the other creature is too scary. if (otherCreature != null && (creature.AI.Position - EntityToKill.Position).Length() < 10 && creature.AI.FightOrFlight(otherCreature.AI) == CreatureAI.FightOrFlightResponse.Flee) { Name = "Flee Entity: " + EntityToKill.Name + " " + EntityToKill.GlobalID; ReassignOnDeath = false; IndicatorManager.DrawIndicator(IndicatorManager.StandardIndicators.Exclaim, creature.AI.Position, 1.0f, 1.0f, Vector2.UnitY * -32); return(new FleeEntityAct(creature.AI) { Entity = EntityToKill, PathLength = 20 }); } // Make the other creature defend itself. var otherKill = new KillEntityTask(creature.Physics, KillType.Auto) { AutoRetry = true, ReassignOnDeath = false }; if (!otherCreature.AI.HasTaskWithName(otherKill)) { otherCreature.AI.AssignTask(otherKill); } } } float radius = this.Mode == KillType.Auto ? 20.0f : 0.0f; return(new KillEntityAct(EntityToKill, creature.AI) { RadiusDomain = radius, Defensive = Mode == KillType.Auto }); }
public override float Damage(float amount, DamageType type = DamageType.Normal) { float damage = base.Damage(amount, type); string prefix = damage > 0 ? "-" : "+"; Color color = damage > 0 ? Color.Red : Color.Green; IndicatorManager.DrawIndicator(prefix + (int)amount + " HP", AI.Position + Vector3.Up + MathFunctions.RandVector3Cube() * 0.5f, 0.5f, color, Indicator.IndicatorMode.Indicator3D); if (damage > 0) { NoiseMaker.MakeNoise("Hurt", AI.Position); this.Sprite.Blink(0.5f); AI.AddThought(Thought.ThoughtType.TookDamage); PlayState.ParticleManager.Trigger(DeathParticleTrigger.EmitterName, AI.Position, Color.White, 2); } return(damage); }
public void Update(DwarfTime time, WorldManager world) { ChargeTimer.Update(time); if (ManaSprite != null && Charge > 0.0f && world.Master.Spells.Mana < world.Master.Spells.MaxMana) { if (ChargeTimer.HasTriggered) { SoundManager.PlaySound(ContentPaths.Audio.tinkle, ManaSprite.Position); IndicatorManager.DrawIndicator("+" + (int)ChargeRate + " M", ManaSprite.Position, 1.0f, Color.Green); world.ParticleManager.Trigger("star_particle", ManaSprite.Position, Color.White, 1); Charge -= ChargeRate; world.Master.Spells.Recharge(ChargeRate); } } else if (Charge <= 0.01f) { ReCreateTimer.Update(time); } }
public IEnumerable <Act.Status> PerformOnVoxel(Creature performer, Vector3 pos, KillVoxelTask DigAct, DwarfTime time, float bonus, string faction) { while (true) { if (!DigAct.Voxel.IsValid) { performer.AI.SetTaskFailureReason("Failed to dig. Voxel was not valid."); yield return(Act.Status.Fail); yield break; } Drawer2D.DrawLoadBar(performer.World.Renderer.Camera, DigAct.Voxel.WorldPosition + Vector3.One * 0.5f, Color.White, Color.Black, 32, 1, (float)DigAct.VoxelHealth / DigAct.Voxel.Type.StartingHealth); while (!performer.Sprite.AnimPlayer.HasValidAnimation() || performer.Sprite.AnimPlayer.CurrentFrame < Weapon.TriggerFrame) { if (performer.Sprite.AnimPlayer.HasValidAnimation()) { performer.Sprite.AnimPlayer.Play(); } yield return(Act.Status.Running); } DigAct.VoxelHealth -= (Weapon.DamageAmount + bonus); DigAct.Voxel.Type.HitSound.Play(DigAct.Voxel.WorldPosition); if (!String.IsNullOrEmpty(Weapon.HitParticles)) { performer.Manager.World.ParticleManager.Trigger(Weapon.HitParticles, DigAct.Voxel.WorldPosition, Color.White, 5); } if (Weapon.HitAnimation != null) { IndicatorManager.DrawIndicator(Weapon.HitAnimation, DigAct.Voxel.WorldPosition + Vector3.One * 0.5f, 10.0f, 1.0f, MathFunctions.RandVector2Circle() * 10, Weapon.HitColor, MathFunctions.Rand() > 0.5f); } yield return(Act.Status.Success); yield break; } }
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); World.ParticleManager.Trigger("star_particle", p, Color.White, 4); VoxelLibrary.PlaceType(VoxelLibrary.GetVoxelType(VoxelType), selected); if (VoxelType == "Magic") { new VoxelListener(World.ComponentManager, World.ComponentManager.RootComponent, World.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 = World.ChunkManager.ChunkData.ChunkMap[point]; chunk.ShouldRebuild = true; chunk.NotifyTotalRebuild(true); } if (placed) { SoundManager.PlaySound(ContentPaths.Audio.tinkle, World.CursorLightPos, true, 1.0f); } RechargeTimer.Reset(RechargeTimer.TargetTimeSeconds); base.OnVoxelsSelected(tree, voxels); }
public bool PerformNoDamage(Creature performer, DwarfTime time, Vector3 pos) { switch (TriggerMode) { case AttackTrigger.Timer: RechargeTimer.Update(time); if (!RechargeTimer.HasTriggered) { HasTriggered = false; return(false); } break; case AttackTrigger.Animation: if (performer.Sprite.CurrentAnimation == null || performer.Sprite.CurrentAnimation.CurrentFrame != TriggerFrame) { HasTriggered = false; return(false); } break; } if (Mode == AttackMode.Melee) { if (HitParticles != "") { performer.Manager.World.ParticleManager.Trigger(HitParticles, pos, Color.White, 5); } if (HitAnimation != null && !HasTriggered) { HitAnimation.Reset(); HitAnimation.Play(); IndicatorManager.DrawIndicator(HitAnimation.Clone(), pos, 10.0f, 1.0f, MathFunctions.RandVector2Circle(), Color.White, MathFunctions.Rand() > 0.5f); PlayNoise(pos); } } HasTriggered = true; return(true); }
public void AddThought(Thought thought, bool allowDuplicates) { if (allowDuplicates) { Thoughts.Add(thought); } else { if (HasThought(thought.Type)) { return; } Thoughts.Add(thought); } bool good = thought.HappinessModifier > 0; Color textColor = good ? Color.Yellow : Color.Red; string prefix = good ? "+" : ""; string postfix = good ? ":)" : ":("; IndicatorManager.DrawIndicator(prefix + thought.HappinessModifier + " " + postfix, Position + Vector3.Up + MathFunctions.RandVector3Cube() *0.5f, 1.0f, textColor); }
void InputManager_MouseClickedCallback(InputManager.MouseButton button) { if (button != InputManager.MouseButton.Right || Player.CurrentTool != this || KeyManager.RotationEnabled()) { return; } Voxel vox = Player.World.ChunkManager.ChunkData.GetFirstVisibleBlockHitByMouse(Mouse.GetState(), Player.World.Camera, GameState.Game.GraphicsDevice.Viewport); if (vox == null) { return; } foreach (CreatureAI minion in Player.SelectedMinions) { if (minion.Creature.IsAsleep) { continue; } if (minion.CurrentTask != null) { minion.Tasks.Add(minion.CurrentTask); if (minion.CurrentTask.Script != null) { minion.CurrentAct.OnCanceled(); minion.CurrentTask.Script.Initialize(); } minion.CurrentTask.SetupScript(minion.Creature); minion.CurrentTask = null; } minion.Blackboard.SetData("MoveTarget", vox); minion.CurrentTask = new GoToVoxelAct("MoveTarget", PlanAct.PlanType.Adjacent, minion).AsTask(); minion.CurrentTask.AutoRetry = false; } OnConfirm(Player.SelectedMinions); IndicatorManager.DrawIndicator(IndicatorManager.StandardIndicators.DownArrow, vox.Position + Vector3.One * 0.5f, 0.5f, 2.0f, new Vector2(0, -50), Color.LightGreen); }
public void PerformNoDamage(Creature performer, DwarfTime time, Vector3 pos) { switch (TriggerMode) { case AttackTrigger.Timer: RechargeTimer.Update(time); if (!RechargeTimer.HasTriggered) { return; } break; case AttackTrigger.Animation: if (performer.Sprite.CurrentAnimation == null || performer.Sprite.CurrentAnimation.CurrentFrame != TriggerFrame) { return; } break; } if (Mode == AttackMode.Melee) { PlayNoise(pos); if (HitParticles != "") { PlayState.ParticleManager.Trigger(HitParticles, pos, Color.White, 5); } if (HitAnimation != null) { HitAnimation.Reset(); HitAnimation.Play(); IndicatorManager.DrawIndicator(HitAnimation, pos, 0.6f, 2.0f, MathFunctions.RandVector2Circle(), Color.White, MathFunctions.Rand() > 0.5f); } } }
public IEnumerable <Act.Status> HealAlly() { Timer healTimer = new Timer(5.0f, false); while (!Ally.IsDead && Ally.Stats.Health.IsDissatisfied()) { Agent.Physics.Face(Ally.Position); Agent.Creature.CurrentCharacterMode = CharacterMode.Sitting; healTimer.Update(DwarfTime.LastTime); if (healTimer.HasTriggered) { int amount = MathFunctions.RandInt(1, (int)Agent.Stats.Wisdom); Ally.Creature.Heal(amount); IndicatorManager.DrawIndicator((amount).ToString() + " HP", Ally.Position, 1.0f, GameSettings.Current.Colors.GetColor("Positive", Microsoft.Xna.Framework.Color.Green)); Ally.Creature.DrawLifeTimer.Reset(); } yield return(Act.Status.Running); } Ally.ResetPositionConstraint(); yield return(Act.Status.Success); }
public bool Perform(Creature performer, Body other, DwarfTime time, float bonus, Vector3 pos, string faction) { switch (TriggerMode) { case AttackTrigger.Timer: RechargeTimer.Update(time); if (!RechargeTimer.HasTriggered) { return(false); } break; case AttackTrigger.Animation: if (performer.Sprite.CurrentAnimation == null || performer.Sprite.CurrentAnimation.CurrentFrame != TriggerFrame) { return(false); } break; } switch (Mode) { case AttackMode.Melee: case AttackMode.Dogfight: { Health health = other.GetRootComponent().GetChildrenOfType <Health>(true).FirstOrDefault(); if (health != null) { health.Damage(DamageAmount + bonus); } PlayNoise(other.GlobalTransform.Translation); if (HitParticles != "") { PlayState.ParticleManager.Trigger(HitParticles, other.LocalTransform.Translation, Color.White, 5); } if (HitAnimation != null) { HitAnimation.Reset(); HitAnimation.Play(); IndicatorManager.DrawIndicator(HitAnimation.Clone(), other.BoundingBox.Center(), 10.0f, 1.0f, MathFunctions.RandVector2Circle(), Color.White, MathFunctions.Rand() > 0.5f); } Physics physics = other as Physics; if (physics != null) { Vector3 force = other.Position - pos; if (force.LengthSquared() > 0.01f) { force.Normalize(); physics.ApplyForce(force * Knockback, 1.0f); } } break; } case AttackMode.Ranged: { PlayNoise(other.GlobalTransform.Translation); LaunchProjectile(pos, other.Position, other); break; } } return(true); }
public void DoDamage(Creature performer, GameComponent other, float bonus) { if (!String.IsNullOrEmpty(Weapon.DiseaseToSpread)) { if (other.GetRoot().GetComponent <Creature>().HasValue(out var otherCreature)) { var disease = DiseaseLibrary.GetDisease(Weapon.DiseaseToSpread); if (disease != null) { if (MathFunctions.RandEvent(disease.LikelihoodOfSpread)) { otherCreature.Stats.AcquireDisease(disease); } } } } var health = other.GetRoot().EnumerateAll().OfType <Health>().FirstOrDefault(); if (health != null) { health.Damage(Weapon.DamageAmount + bonus); var injury = DiseaseLibrary.GetRandomInjury(); if (MathFunctions.RandEvent(injury.LikelihoodOfSpread)) { if (other.GetRoot().GetComponent <Creature>().HasValue(out var creature)) { creature.Stats.AcquireDisease(injury); } } Vector3 knock = other.Position - performer.Physics.Position; knock.Normalize(); knock *= 0.2f; if (other.AnimationQueue.Count == 0) { other.AnimationQueue.Add(new KnockbackAnimation(0.15f, other.LocalTransform, knock)); } } else { other.GetRoot().Die(); } PlayNoise(other.GlobalTransform.Translation); if (Weapon.HitParticles != "") { performer.Manager.World.ParticleManager.Trigger(Weapon.HitParticles, other.LocalTransform.Translation, Color.White, 5); if (Weapon.ShootLaser) { performer.Manager.World.ParticleManager.TriggerRay(Weapon.HitParticles, performer.AI.Position, other.LocalTransform.Translation); } } if (Weapon.HitAnimation != null) { IndicatorManager.DrawIndicator(Weapon.HitAnimation, other.BoundingBox.Center(), 10.0f, 1.0f, MathFunctions.RandVector2Circle(), Color.White, MathFunctions.Rand() > 0.5f); } Physics physics = other as Physics; if (physics != null) { Vector3 force = other.Position - performer.AI.Position; if (force.LengthSquared() > 0.01f) { force.Normalize(); physics.ApplyForce(force * Weapon.Knockback, 1.0f); } } }