public override void CreateCosmeticChildren(ComponentManager manager) { CreateSprite(ContentPaths.Entities.Dwarf.Sprites.fairy_animation, manager, 0.15f); Sprite.AddChild(new Bobber(Manager, 0.25f, 3.0f, MathFunctions.Rand(), Sprite.LocalTransform.Translation.Y)).SetFlag(Flag.ShouldSerialize, false); Sprite.LightsWithVoxels = false; Physics.AddChild(Shadow.Create(0.75f, manager)); Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 0, 0))).SetFlag(Flag.ShouldSerialize, false); NoiseMaker = new NoiseMaker(); NoiseMaker.Noises["Hurt"] = new List <string> { ContentPaths.Audio.tinkle }; NoiseMaker.Noises["Chew"] = new List <string> { ContentPaths.Audio.tinkle }; NoiseMaker.Noises["Jump"] = new List <string> { ContentPaths.Audio.tinkle }; Physics.AddChild(new ParticleTrigger("star_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 5, SoundToPlay = ContentPaths.Audio.wurp, }).SetFlag(Flag.ShouldSerialize, false); base.CreateCosmeticChildren(manager); }
public override void CreateCosmeticChildren(ComponentManager manager) { CreateSprite(ContentPaths.Entities.Animals.Rabbit.rabbit0_animation, manager, 0.35f); Physics.AddChild(Shadow.Create(0.3f, manager)); NoiseMaker = new NoiseMaker(); NoiseMaker.Noises["Hurt"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_rabbit_hurt_1, ContentPaths.Audio.Oscar.sfx_oc_rabbit_hurt_2 }; NoiseMaker.Noises["Chirp"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_rabbit_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_rabbit_neutral_2 }; Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 1, SoundToPlay = ContentPaths.Audio.Oscar.sfx_oc_rabbit_hurt_1 }).SetFlag(Flag.ShouldSerialize, false); base.CreateCosmeticChildren(manager); }
public Creature( ComponentManager Manager, CreatureStats stats, string allies, PlanService planService, Faction faction, string name) : base(Manager, name, stats.MaxHealth, 0.0f, stats.MaxHealth) { Gender = Mating.RandomGender(); DrawLifeTimer.HasTriggered = true; HasMeat = true; HasBones = true; HasCorpse = false; Buffs = new List <Buff>(); IsOnGround = true; Stats = stats; Faction = faction; PlanService = planService; Allies = allies; Controller = new PIDController(Stats.MaxAcceleration, Stats.StoppingForce * 2, 0.0f); JumpTimer = new Timer(0.2f, true); Status = new CreatureStatus(); IsHeadClear = true; NoiseMaker = new NoiseMaker(); OverrideCharacterMode = false; }
/// <summary> /// Called whenever the creature takes damage. /// </summary> 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); if (damage > 0) { NoiseMaker.MakeNoise("Hurt", AI.Position); Sprite.Blink(0.5f); AI.AddThought(Thought.ThoughtType.TookDamage); var deathParticleTrigger = Parent.EnumerateAll().OfType <ParticleTrigger>().Where(p => p.Name == "Death Gibs").FirstOrDefault(); if (deathParticleTrigger != null) { Manager.World.ParticleManager.Trigger(deathParticleTrigger.EmitterName, AI.Position, Color.White, 2); } DrawLifeTimer.Reset(); } return(damage); }
public Creature(CreatureStats stats, string allies, PlanService planService, Faction faction, Physics parent, ChunkManager chunks, GraphicsDevice graphics, ContentManager content, string name) : base(parent.Manager, name, parent, stats.MaxHealth, 0.0f, stats.MaxHealth) { HasMeat = true; HasBones = true; Buffs = new List <Buff>(); IsOnGround = true; Physics = parent; Stats = stats; Chunks = chunks; Graphics = graphics; Content = content; Faction = faction; PlanService = planService; Allies = allies; Controller = new PIDController(Stats.MaxAcceleration, Stats.StoppingForce * 2, 0.0f); JumpTimer = new Timer(0.2f, true); Status = new CreatureStatus(); IsHeadClear = true; NoiseMaker = new NoiseMaker(); OverrideCharacterMode = false; SelectionCircle = new SelectionCircle(Manager, Physics) { IsVisible = false }; }
public IEnumerable <Act.Status> HitAndWait(bool loadBar, Func <float> maxProgress, Func <float> progress, Action incrementProgress, Func <Vector3> pos, string playSound = "", Func <bool> continueHitting = null, bool maintainPos = true) { Vector3 currentPos = Physics.LocalTransform.Translation; CurrentCharacterMode = Stats.CurrentClass.AttackMode; Sprite.ResetAnimations(CurrentCharacterMode); Sprite.PlayAnimations(CurrentCharacterMode); var p_current = pos(); Timer incrementTimer = new Timer(1.0f, false); while (progress() < maxProgress()) { if (continueHitting != null && !continueHitting()) { yield break; } if (loadBar) { Drawer2D.DrawLoadBar(Manager.World.Renderer.Camera, AI.Position + Vector3.Up, Color.LightGreen, Color.Black, 64, 4, progress() / maxProgress()); } Physics.Active = false; Physics.Face(p_current); if (Attacks[0].PerformNoDamage(this, DwarfTime.LastTime, p_current)) { p_current = pos(); } Physics.Velocity = Vector3.Zero; if (!String.IsNullOrEmpty(playSound)) { NoiseMaker.MakeNoise(playSound, AI.Position, true); } incrementTimer.Update(DwarfTime.LastTime); if (incrementTimer.HasTriggered) { Sprite.ReloopAnimations(Stats.CurrentClass.AttackMode); incrementProgress(); } if (maintainPos) { var matrix = Physics.LocalTransform; matrix.Translation = currentPos; Physics.LocalTransform = matrix; } yield return(Act.Status.Running); } Sprite.PauseAnimations(Stats.CurrentClass.AttackMode); CurrentCharacterMode = CharacterMode.Idle; Physics.Active = true; yield return(Act.Status.Success); yield break; }
/// <summary> /// Called whenever the creature takes damage. /// </summary> public override float Damage(float amount, DamageType type = DamageType.Normal) { IsCloaked = false; float damage = base.Damage(amount, type); string prefix = damage > 0 ? "-" : "+"; Color color = damage > 0 ? GameSettings.Default.Colors.GetColor("Negative", Color.Red) : GameSettings.Default.Colors.GetColor("Positive", Color.Green); if (AI != null) { IndicatorManager.DrawIndicator(prefix + (int)amount + " HP", AI.Position + Vector3.Up + MathFunctions.RandVector3Cube() * 0.5f, 0.5f, color); NoiseMaker.MakeNoise("Hurt", AI.Position); Sprite.Blink(0.5f); AddThought("I got hurt recently.", new TimeSpan(2, 0, 0, 0), -5.0f); var deathParticleTriggers = Parent.EnumerateAll().OfType <ParticleTrigger>().Where(p => p.Name == "Death Gibs"); foreach (var trigger in deathParticleTriggers) { Manager.World.ParticleManager.Trigger(trigger.EmitterName, AI.Position, Color.White, 2); } DrawLifeTimer.Reset(); } return(damage); }
public override void CreateCosmeticChildren(ComponentManager manager) { CreateSprite(SpriteAsset + "_animation.json", Manager, 0.35f); Physics.AddChild(Shadow.Create(0.3f, manager)); NoiseMaker = new NoiseMaker(); NoiseMaker.Noises.Add("chirp", new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_bird_neutral_2 }); NoiseMaker.Noises["Hurt"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_hurt }; NoiseMaker.Noises["Lay Egg"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_lay_egg }; Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 1, SoundToPlay = ContentPaths.Audio.Oscar.sfx_oc_bird_hurt }).SetFlag(Flag.ShouldSerialize, false); base.CreateCosmeticChildren(manager); }
public override void CreateCosmeticChildren(ComponentManager manager) { CreateDwarfSprite(Stats.CurrentClass, manager); Physics.AddChild(Shadow.Create(0.75f, manager)); Physics.AddChild(new VoxelRevealer(manager, Physics, 5)).SetFlag(Flag.ShouldSerialize, false); Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 0, 0))).SetFlag(Flag.ShouldSerialize, false); NoiseMaker = new NoiseMaker(); NoiseMaker.Noises["Hurt"] = new List <string> { ContentPaths.Audio.Oscar.sfx_ic_dwarf_hurt_1, ContentPaths.Audio.Oscar.sfx_ic_dwarf_hurt_2, }; NoiseMaker.Noises["Ok"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_ic_dwarf_ok_1, ContentPaths.Audio.Oscar.sfx_ic_dwarf_ok_2, ContentPaths.Audio.Oscar.sfx_ic_dwarf_ok_3 }; NoiseMaker.Noises["Die"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_ic_dwarf_death }; NoiseMaker.Noises["Pleased"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_ic_dwarf_pleased }; NoiseMaker.Noises["Tantrum"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_ic_dwarf_tantrum_1, ContentPaths.Audio.Oscar.sfx_ic_dwarf_tantrum_2, ContentPaths.Audio.Oscar.sfx_ic_dwarf_tantrum_3, }; NoiseMaker.Noises["Jump"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_ic_dwarf_jump }; NoiseMaker.Noises["Climb"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_ic_dwarf_climb_1, ContentPaths.Audio.Oscar.sfx_ic_dwarf_climb_2, ContentPaths.Audio.Oscar.sfx_ic_dwarf_climb_3 }; Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 1, BoxTriggerTimes = 10, SoundToPlay = ContentPaths.Entities.Dwarf.Audio.dwarfhurt1, }).SetFlag(Flag.ShouldSerialize, false); base.CreateCosmeticChildren(manager); }
/// <summary> Updates the creature </summary> public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera) { if (FirstUpdate) { FirstUpdate = false; Faction.Minions.Add(AI); Physics.AllowPhysicsSleep = false; } if (!Active) { return; } DrawLifeTimer.Update(gameTime); if (!DrawLifeTimer.HasTriggered) { float val = Hp / MaxHealth; Color color = val < 0.75f ? (val < 0.5f ? Color.Red : Color.Orange) : Color.LightGreen; Drawer2D.DrawLoadBar(Manager.World.Camera, AI.Position - Vector3.Up * 0.5f, color, Color.Black, 32, 2, Hp / MaxHealth); } CheckNeighborhood(chunks, (float)gameTime.ElapsedGameTime.TotalSeconds); UpdateAnimation(gameTime, chunks, camera); Status.Update(this, gameTime, chunks, camera); JumpTimer.Update(gameTime); HandleBuffs(gameTime); if (Stats.LaysEggs) { if (EggTimer == null) { EggTimer = new Timer(1200f + MathFunctions.Rand(-30, 30), false); } EggTimer.Update(gameTime); if (EggTimer.HasTriggered) { LayEgg(); EggTimer = new Timer(1200f + MathFunctions.Rand(-30, 30), false); } } if (IsPregnant && World.Time.CurrentDate > CurrentPregnancy.EndDate) { var baby = EntityFactory.CreateEntity <GameComponent>(BabyType, Physics.Position); baby.GetRoot().GetComponent <CreatureAI>().PositionConstraint = AI.PositionConstraint; CurrentPregnancy = null; } if (MathFunctions.RandEvent(0.0001f)) { NoiseMaker.MakeNoise("Chirp", AI.Position, true, 0.25f); } }
public void LayEgg() { NoiseMaker.MakeNoise("Lay Egg", AI.Position, true, 1.0f); var eggResource = new Resource("Egg") { DisplayName = Stats.CurrentClass.Name + " Egg" }; var resourceEntity = Manager.RootComponent.AddChild(new ResourceEntity(Manager, eggResource, Physics.Position)); resourceEntity.AddChild(new Egg(resourceEntity, Stats.Species.BabyType, Manager, Physics.Position, AI.PositionConstraint)); }
private void MakeNoises() { if (AI == null) { return; } if (MathFunctions.RandEvent(0.0001f)) { NoiseMaker.MakeNoise("Chirp", AI.Position, true, 0.25f); } }
public override void Die() { if (World == null) { return; // WUT } if (Stats == null) { return; // SERIOUSLY WTF?? } World.RemoveFromSpeciesTracking(Stats.Species); NoiseMaker.MakeNoise("Die", Physics.Position, true); if (AI.Stats.Money > 0) { EntityFactory.CreateEntity <CoinPile>("Coins Resource", AI.Position, Blackboard.Create("Money", AI.Stats.Money)); } if (Stats.Species.HasMeat) { String type = Stats.CurrentClass.Name + " " + "Meat"; if (!Library.DoesResourceTypeExist(type)) { var r = Library.CreateResourceType(Library.GetResourceType(Stats.Species.BaseMeatResource)); r.Name = type; r.ShortName = type; Library.AddResourceType(r); } Inventory.AddResource(new ResourceAmount(type, 1)); } if (Stats.Species.HasBones) { String type = Stats.CurrentClass.Name + " Bone"; if (!Library.DoesResourceTypeExist(type)) { var r = Library.CreateResourceType(Library.GetResourceType("Bone")); r.Name = type; r.ShortName = type; Library.AddResourceType(r); } Inventory.AddResource(new ResourceAmount(type, 1)); } base.Die(); }
public override void CreateCosmeticChildren(ComponentManager manager) { CreateSprite(ContentPaths.Entities.Demon.demon_animations, manager, 0.15f); Physics.AddChild(Shadow.Create(0.75f, manager)); Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 3, 1))).SetFlag(Flag.ShouldSerialize, false); NoiseMaker = new NoiseMaker(); NoiseMaker.Noises["Hurt"] = new List <string> { ContentPaths.Audio.Oscar.sfx_ic_demon_hurt_1, ContentPaths.Audio.Oscar.sfx_ic_demon_hurt_2, }; NoiseMaker.Noises["Chew"] = new List <string> { ContentPaths.Audio.chew }; NoiseMaker.Noises["Jump"] = new List <string> { ContentPaths.Audio.Oscar.sfx_ic_demon_angered, }; NoiseMaker.Noises["Flap"] = new List <string> { ContentPaths.Audio.Oscar.sfx_ic_demon_flap_wings_1, ContentPaths.Audio.Oscar.sfx_ic_demon_flap_wings_2, ContentPaths.Audio.Oscar.sfx_ic_demon_flap_wings_3, }; NoiseMaker.Noises["Chirp"] = new List <string> { ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_1, ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_2, ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_3, ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_4, ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_5, ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_6, ContentPaths.Audio.Oscar.sfx_ic_demon_pleased, }; Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 5, SoundToPlay = ContentPaths.Audio.Oscar.sfx_ic_demon_death }).SetFlag(Flag.ShouldSerialize, false); base.CreateCosmeticChildren(manager); }
/// <summary> /// Kills the creature and releases its resources. /// </summary> public override void Die() { // This is just a silly hack to make sure that creatures // carrying resources to a trade depot release their resources // when they die. CreateMeatAndBones(); NoiseMaker.MakeNoise("Die", Physics.Position, true); if (AI.Status.Money > 0) { EntityFactory.CreateEntity <CoinPile>("Coins Resource", AI.Position, Blackboard.Create("Money", AI.Status.Money)); } base.Die(); }
public void LayEgg() { NoiseMaker.MakeNoise("Lay Egg", AI.Position, true, 1.0f); // Todo: Egg resource type and the baby made need to be in the species. if (!Library.DoesResourceTypeExist(Stats.CurrentClass.Name + " Egg") || !EntityFactory.EnumerateEntityTypes().Contains(Stats.CurrentClass.Name + " Egg Resource")) { var newEggResource = Library.CreateResourceType(Library.GetResourceType("Egg")); newEggResource.Name = Stats.CurrentClass.Name + " Egg"; Library.AddResourceType(newEggResource); } var parent = EntityFactory.CreateEntity <GameComponent>(Stats.CurrentClass.Name + " Egg Resource", Physics.Position); parent.AddChild(new Egg(parent, Stats.Species.BabyType, Manager, Physics.Position, AI.PositionConstraint)); }
public void LayEgg() { NoiseMaker.MakeNoise("Lay Egg", AI.Position, true, 1.0f); if (ResourceLibrary.GetResourceByName(Species + " Egg") == null || !EntityFactory.EnumerateEntityTypes().Contains(Species + " Egg Resource")) { Resource newEggResource = new Resource(ResourceLibrary.GetResourceByName(ResourceType.Egg)); newEggResource.Name = Species + " Egg"; ResourceLibrary.Add(newEggResource); } var parent = EntityFactory.CreateEntity <Body>(this.Species + " Egg Resource", Physics.Position); parent.AddChild(new Egg(parent, this.Species, Manager, Physics.Position, AI.PositionConstraint)); }
public IEnumerable <Act.Status> HitAndWait(bool loadBar, Func <float> maxProgress, Func <float> progress, Action incrementProgress, Func <Vector3> pos, string playSound = "", Func <bool> continueHitting = null) { CurrentCharacterMode = CharacterMode.Attacking; Sprite.ResetAnimations(CharacterMode.Attacking); Sprite.PlayAnimations(CharacterMode.Attacking); CurrentCharacterMode = CharacterMode.Attacking; Timer incrementTimer = new Timer(1.0f, false); while (progress() < maxProgress()) { if (continueHitting != null && !continueHitting()) { yield break; } if (loadBar) { Drawer2D.DrawLoadBar(Manager.World.Camera, AI.Position + Vector3.Up, Color.LightGreen, Color.Black, 64, 4, progress() / maxProgress()); } Attacks[0].PerformNoDamage(this, DwarfTime.LastTime, pos()); Physics.Velocity = Vector3.Zero; Sprite.ReloopAnimations(CharacterMode.Attacking); if (!String.IsNullOrEmpty(playSound)) { NoiseMaker.MakeNoise(playSound, AI.Position, true); } incrementTimer.Update(DwarfTime.LastTime); if (incrementTimer.HasTriggered) { incrementProgress(); } yield return(Act.Status.Running); } Sprite.PauseAnimations(CharacterMode.Attacking); CurrentCharacterMode = CharacterMode.Idle; yield return(Act.Status.Success); yield break; }
public override void ReceiveMessageRecursive(Message messageToReceive) { switch (messageToReceive.Type) { case Message.MessageType.OnChunkModified: break; case Message.MessageType.OnHurt: 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); break; } base.ReceiveMessageRecursive(messageToReceive); }
public Creature( ComponentManager Manager, CreatureStats stats, Faction faction, string name) : base(Manager, name, stats.MaxHealth, 0.0f, stats.MaxHealth) { Stats = stats; Stats.Gender = Mating.RandomGender(); DrawLifeTimer.HasTriggered = true; IsOnGround = true; Faction = faction; Controller = new PIDController(Stats.MaxAcceleration, Stats.StoppingForce * 2, 0.0f); IsHeadClear = true; NoiseMaker = new NoiseMaker(); NoiseMaker.BasePitch = stats.VoicePitch; OverrideCharacterMode = false; InitializeAttacks(); }
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 override void Die() { if (World == null) { return; // WUT } if (Stats == null) { return; // SERIOUSLY WTF?? } if (!FirstUpdate) { World.RemoveFromSpeciesTracking(Stats.Species); } NoiseMaker.MakeNoise("Die", Physics.Position, true); if (AI.Stats.Money > 0) { Manager.RootComponent.AddChild(new CoinPile(Manager, AI.Position) // I don't like how it's implictly added to manager. { Money = AI.Stats.Money }); } if (Stats.Species.HasMeat) { var meatResource = new Resource(Stats.Species.BaseMeatResource); meatResource.DisplayName = Stats.CurrentClass.Name + " Meat"; Inventory.AddResource(meatResource); } if (Stats.Species.HasBones) { var generatedResource = new Resource("Bone"); generatedResource.DisplayName = Stats.CurrentClass.Name + " Bone"; Inventory.AddResource(generatedResource); } base.Die(); }
/// <summary> /// Basic Act that causes the creature to wait for the specified time. /// Also draws a loading bar above the creature's head when relevant. /// </summary> public IEnumerable <Act.Status> HitAndWait(float f, bool loadBar, Func <Vector3> pos, string playSound = "", Func <bool> continueHitting = null) { var waitTimer = new Timer(f, true); CurrentCharacterMode = AttackMode; Sprite.ResetAnimations(CurrentCharacterMode); Sprite.PlayAnimations(CurrentCharacterMode); while (!waitTimer.HasTriggered) { waitTimer.Update(DwarfTime.LastTime); if (continueHitting != null && !continueHitting()) { yield break; } Physics.Active = false; if (loadBar) { Drawer2D.DrawLoadBar(Manager.World.Camera, AI.Position + Vector3.Up, Color.LightGreen, Color.Black, 64, 4, waitTimer.CurrentTimeSeconds / waitTimer.TargetTimeSeconds); } Attacks[0].PerformNoDamage(this, DwarfTime.LastTime, pos()); Physics.Velocity = Vector3.Zero; Sprite.ReloopAnimations(AttackMode); if (!String.IsNullOrEmpty(playSound)) { NoiseMaker.MakeNoise(playSound, AI.Position, true); } yield return(Act.Status.Running); } Sprite.PauseAnimations(AttackMode); CurrentCharacterMode = CharacterMode.Idle; Physics.Active = true; yield return(Act.Status.Success); yield break; }
public override void CreateCosmeticChildren(ComponentManager manager) { var spriteSheet = new SpriteSheet(SpriteAsset, 48, 48); var sprite = new CharacterSprite(manager, "Sprite", Matrix.CreateTranslation(0, 0.35f, 0)); var anims = Library.LoadNewLayeredAnimationFormat("Entities\\Animals\\Slimes\\slime-animations.json"); foreach (var anim in anims) { anim.Value.SpriteSheet = spriteSheet; } sprite.SetAnimations(anims); Physics.AddChild(sprite); sprite.SetFlag(Flag.ShouldSerialize, false); Physics.AddChild(Shadow.Create(0.3f, manager)); NoiseMaker = new NoiseMaker(); NoiseMaker.Noises.Add("chirp", new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_bird_neutral_2 }); NoiseMaker.Noises["Hurt"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_hurt }; NoiseMaker.Noises["Lay Egg"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_lay_egg }; Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 1, SoundToPlay = ContentPaths.Audio.Oscar.sfx_oc_bird_hurt }).SetFlag(Flag.ShouldSerialize, false); base.CreateCosmeticChildren(manager); }
public override void CreateCosmeticChildren(ComponentManager manager) { CreateSprite(ContentPaths.Entities.Troll.troll_animation, manager, 0.15f); Physics.AddChild(Shadow.Create(0.75f, manager)); Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 1, 3))).SetFlag(Flag.ShouldSerialize, false); NoiseMaker = new NoiseMaker(); NoiseMaker.Noises["Hurt"] = new List <string> { ContentPaths.Audio.Oscar.sfx_ic_goblin_angered, }; Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 3, SoundToPlay = ContentPaths.Audio.Oscar.sfx_ic_demon_hurt_1, }).SetFlag(Flag.ShouldSerialize, false); base.CreateCosmeticChildren(manager); }
/// <summary> /// Called when the creature receives an event message from another source. /// This somewhat janky messaging system is rarely used anymore and should /// probably be removed for clarity. /// </summary> public override void ReceiveMessageRecursive(Message messageToReceive) { switch (messageToReceive.Type) { case Message.MessageType.OnHurt: NoiseMaker.MakeNoise("Hurt", AI.Position); Sprite.Blink(0.5f); AddThought("I got hurt recently.", new TimeSpan(2, 0, 0, 0), -5.0f); var deathParticleTriggers = Parent.EnumerateAll().OfType <ParticleTrigger>().Where(p => p.Name == "Death Gibs"); foreach (var trigger in deathParticleTriggers) { Manager.World.ParticleManager.Trigger(trigger.EmitterName, AI.Position, Color.White, 2); } break; } base.ReceiveMessageRecursive(messageToReceive); }
public override void CreateCosmeticChildren(ComponentManager manager) { CreateSprite(ContentPaths.Entities.Golems.mud_golem, manager, 0.15f); Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 2, 3))).SetFlag(Flag.ShouldSerialize, false); NoiseMaker = new NoiseMaker(); NoiseMaker.Noises["Hurt"] = new List <string> { ContentPaths.Audio.demon0, ContentPaths.Audio.gravel, }; Physics.AddChild(new ParticleTrigger("dirt_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 5, SoundToPlay = ContentPaths.Audio.gravel }).SetFlag(Flag.ShouldSerialize, false); base.CreateCosmeticChildren(manager); }
public override void CreateCosmeticChildren(ComponentManager manager) { CreateSprite(ContentPaths.Entities.Skeleton.necro_animations, manager, 0.15f); Physics.AddChild(Shadow.Create(0.75f, manager)); Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 2, 1))).SetFlag(Flag.ShouldSerialize, false); NoiseMaker = new NoiseMaker(); NoiseMaker.Noises["Hurt"] = new List <string> { ContentPaths.Audio.Oscar.sfx_ic_necromancer_angered, ContentPaths.Audio.skel1, ContentPaths.Audio.skel2 }; Physics.AddChild(new ParticleTrigger("sand_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 5, SoundToPlay = ContentPaths.Audio.Oscar.sfx_ic_necromancer_angered }).SetFlag(Flag.ShouldSerialize, false); base.CreateCosmeticChildren(manager); }
/// <summary> /// Called when the creature receives an event message from another source. /// This somewhat janky messaging system is rarely used anymore and should /// probably be removed for clarity. /// </summary> public override void ReceiveMessageRecursive(Message messageToReceive) { switch (messageToReceive.Type) { case Message.MessageType.OnChunkModified: break; case Message.MessageType.OnHurt: NoiseMaker.MakeNoise("Hurt", AI.Position); Sprite.Blink(0.5f); AI.AddThought(Thought.ThoughtType.TookDamage); var deathParticleTrigger = Parent.EnumerateAll().OfType <ParticleTrigger>().Where(p => p.Name == "Death Gibs").FirstOrDefault(); if (deathParticleTrigger != null) { Manager.World.ParticleManager.Trigger(deathParticleTrigger.EmitterName, AI.Position, Color.White, 2); } break; } base.ReceiveMessageRecursive(messageToReceive); }
public Creature(CreatureStats stats, string allies, PlanService planService, Faction faction, Physics parent, ChunkManager chunks, GraphicsDevice graphics, ContentManager content, string name) : base(parent.Manager, name, parent, stats.MaxHealth, 0.0f, stats.MaxHealth) { Buffs = new List<Buff>(); IsOnGround = true; Physics = parent; Stats = stats; Chunks = chunks; Graphics = graphics; Content = content; Faction = faction; PlanService = planService; Allies = allies; Controller = new PIDController(Stats.MaxAcceleration, Stats.StoppingForce * 2, 0.0f); JumpTimer = new Timer(0.2f, true); Status = new CreatureStatus(); IsHeadClear = true; NoiseMaker = new NoiseMaker(); OverrideCharacterMode = false; SelectionCircle = new SelectionCircle(Manager, Physics) { IsVisible = false }; }
/// <summary> /// Checks the voxels around the creature and reacts to changes in its immediate environment. /// For example this function determines when the creature is standing on solid ground. /// </summary> public void CheckNeighborhood(ChunkManager chunks, float dt) { var below = new VoxelHandle(chunks, GlobalVoxelCoordinate.FromVector3(Physics.GlobalTransform.Translation - Vector3.UnitY * 0.8f)); var above = new VoxelHandle(chunks, GlobalVoxelCoordinate.FromVector3(Physics.GlobalTransform.Translation + Vector3.UnitY * 0.8f)); if (above.IsValid) { IsHeadClear = above.IsEmpty; } if (below.IsValid && Physics.IsInLiquid) { IsOnGround = false; } else if (below.IsValid) { IsOnGround = !below.IsEmpty; } else { IsOnGround = false; } if (!IsOnGround) { if (CurrentCharacterMode != CharacterMode.Flying) { if (Physics.Velocity.Y > 0.05) { CurrentCharacterMode = CharacterMode.Jumping; } else if (Physics.Velocity.Y < -0.05) { CurrentCharacterMode = CharacterMode.Falling; } } if (Physics.IsInLiquid) { CurrentCharacterMode = CharacterMode.Swimming; } } if (CurrentCharacterMode == CharacterMode.Falling && IsOnGround) { CurrentCharacterMode = CharacterMode.Idle; } if (Stats.IsAsleep) { CurrentCharacterMode = CharacterMode.Sleeping; if (MathFunctions.RandEvent(0.01f)) { NoiseMaker.MakeNoise("Sleep", AI.Position, true); } } else if (CurrentCharacterMode == CharacterMode.Sleeping) { CurrentCharacterMode = CharacterMode.Idle; } if (/*World.Time.IsDay() && */ Stats.IsAsleep && !Stats.Energy.IsDissatisfied() && !Stats.Health.IsCritical()) { Stats.IsAsleep = false; } }