public void Initialize() { Physics.Orientation = Physics.OrientMode.RotateY; Sprite = new CharacterSprite(Graphics, Manager, "Demon Sprite", Physics, Matrix.CreateTranslation(new Vector3(0, 0.35f, 0))); foreach (Animation animation in Stats.CurrentClass.Animations) { Sprite.AddAnimation(animation.Clone()); } Hands = new Grabber("hands", Physics, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero); Sensors = new EnemySensor(Manager, "EnemySensor", Physics, Matrix.Identity, new Vector3(20, 5, 20), Vector3.Zero); AI = new PacingCreatureAI(this, "Demon AI", Sensors, PlanService) { Movement = { CanFly = true, CanSwim = false } }; Attacks = new List <Attack>() { new Attack(Stats.CurrentClass.Attacks[0]) }; Inventory = new Inventory("Inventory", Physics) { Resources = new ResourceContainer { MaxResources = 16 } }; Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f); shadowTransform.Translation = new Vector3(0.0f, -0.5f, 0.0f); SpriteSheet shadowTexture = new SpriteSheet(ContentPaths.Effects.shadowcircle); Shadow = new Shadow(Manager, "Shadow", Physics, shadowTransform, shadowTexture); List <Point> shP = new List <Point> { new Point(0, 0) }; Animation shadowAnimation = new Animation(Graphics, new SpriteSheet(ContentPaths.Effects.shadowcircle), "sh", 32, 32, shP, false, Color.Black, 1, 0.7f, 0.7f, false); Shadow.AddAnimation(shadowAnimation); shadowAnimation.Play(); Shadow.SetCurrentAnimation("sh"); Physics.Tags.Add("Demon"); DeathParticleTrigger = new ParticleTrigger("blood_particle", Manager, "Death Gibs", Physics, Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 5, SoundToPlay = ContentPaths.Entities.Goblin.Audio.goblinhurt1 }; NoiseMaker.Noises["Hurt"] = new List <string> { ContentPaths.Audio.demon0, ContentPaths.Audio.demon1, ContentPaths.Audio.demon2, ContentPaths.Audio.demon3, }; MinimapIcon minimapIcon = new MinimapIcon(Physics, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 3, 0)); NoiseMaker.Noises["Chew"] = new List <string> { ContentPaths.Audio.chew }; NoiseMaker.Noises["Jump"] = new List <string> { ContentPaths.Audio.jump }; Stats.FullName = TextGenerator.GenerateRandom("$goblinname"); //Stats.LastName = TextGenerator.GenerateRandom("$elffamily"); Stats.Size = 4; }
/// <summary> /// Initialize function creates all the required components for the bird. /// </summary> /// <param name="sprites">The sprite sheet to use for the bird</param> public void Initialize(string sprites) { // When true, causes the bird to face the direction its moving in Physics.Orientation = Physics.OrientMode.RotateY; // Create the sprite component for the bird. Sprite = new CharacterSprite (Graphics, Manager, "Frog Sprite", Physics, Matrix.CreateTranslation(0, 0.5f, 0) ); CompositeAnimation.Descriptor descriptor = FileUtils.LoadJsonFromString <CompositeAnimation.Descriptor>( ContentPaths.GetFileAsString(sprites)); List <CompositeAnimation> animations = descriptor.GenerateAnimations("Rabbit"); foreach (CompositeAnimation animation in animations) { Sprite.AddAnimation(animation); } // Used to grab other components Hands = new Grabber("hands", Physics, Matrix.Identity, new Vector3(0.2f, 0.2f, 0.2f), Vector3.Zero); // Used to sense hostile creatures Sensors = new EnemySensor(Manager, "EnemySensor", Physics, Matrix.Identity, new Vector3(20, 5, 20), Vector3.Zero); // Controls the behavior of the creature AI = new PacingCreatureAI(this, "Rabbit AI", Sensors, PlanService); // The bird can peck at its enemies (0.1 damage) Attacks = new List <Attack> { new Attack("Bite", 0.01f, 2.0f, 1.0f, ContentPaths.Audio.frog, ContentPaths.Effects.bite) }; // The bird can hold one item at a time in its inventory Inventory = new Inventory("Inventory", Physics) { Resources = new ResourceContainer { MaxResources = 1 } }; // The shadow is rotated 90 degrees along X, and is 0.25 blocks beneath the creature Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f); shadowTransform.Translation = new Vector3(0.0f, -0.25f, 0.0f); shadowTransform *= Matrix.CreateScale(0.75f); SpriteSheet shadowTexture = new SpriteSheet(ContentPaths.Effects.shadowcircle); Shadow = new Shadow(Manager, "Shadow", Physics, shadowTransform, shadowTexture); // We set up the shadow's animation so that it's just a static black circle // TODO: Make the shadow set this up automatically List <Point> shP = new List <Point> { new Point(0, 0) }; Animation shadowAnimation = new Animation(Graphics, new SpriteSheet(ContentPaths.Effects.shadowcircle), "sh", 32, 32, shP, false, Color.Black, 1, 0.7f, 0.7f, false); Shadow.AddAnimation(shadowAnimation); shadowAnimation.Play(); Shadow.SetCurrentAnimation("sh"); // The bird will emit a shower of blood when it dies DeathParticleTrigger = new ParticleTrigger("blood_particle", Manager, "Death Gibs", Physics, Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 1 }; // The bird is flammable, and can die when exposed to fire. Flames = new Flammable(Manager, "Flames", Physics, this); // Tag the physics component with some information // that can be used later Physics.Tags.Add("Frog"); Physics.Tags.Add("Animal"); Stats.FullName = TextGenerator.GenerateRandom("$firstname") + " the frog"; Stats.CurrentClass = new EmployeeClass() { Name = "Frog", Levels = new List <EmployeeClass.Level>() { new EmployeeClass.Level() { Index = 0, Name = "Frog" } } }; NoiseMaker.Noises.Add("Idle", new List <string>() { ContentPaths.Audio.frog }); NoiseMaker.Noises.Add("Hurt", new List <string>() { ContentPaths.Audio.frog }); }
public void Initialize(SpriteSheet spriteSheet) { Physics.Orientation = Physics.OrientMode.RotateY; const int frameWidth = 48; const int frameHeight = 40; Sprite = new CharacterSprite (Graphics, Manager, "Deer Sprite", Physics, Matrix.CreateTranslation(Vector3.Up * 0.6f) ); // Add the idle animation Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Forward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 0, 0); Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Left, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 1, 0); Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Right, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 2, 0); Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Backward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 3, 0); // Add the running animation Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Forward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 4, 0, 1, 2, 3); Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Left, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 5, 0, 1, 2, 3); Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Right, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 6, 0, 1, 2, 3); Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Backward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 7, 0, 1, 2, 3); // Add the jumping animation Sprite.AddAnimation(CharacterMode.Jumping, OrientedAnimation.Orientation.Forward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 8, 0, 1); Sprite.AddAnimation(CharacterMode.Jumping, OrientedAnimation.Orientation.Left, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 9, 0, 1); Sprite.AddAnimation(CharacterMode.Jumping, OrientedAnimation.Orientation.Right, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 10, 0, 1); Sprite.AddAnimation(CharacterMode.Jumping, OrientedAnimation.Orientation.Backward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 11, 0, 1); // Add hands Hands = new Grabber("hands", Physics, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero); // Add sensor Sensors = new EnemySensor(Manager, "EnemySensor", Physics, Matrix.Identity, new Vector3(20, 5, 20), Vector3.Zero); // Add AI AI = new PacingCreatureAI(this, "Deer AI", Sensors, PlanService); Attacks = new List <Attack> { new Attack("None", 0.0f, 0.0f, 0.0f, ContentPaths.Audio.pick, ContentPaths.Effects.hit) }; Inventory = new Inventory("Inventory", Physics) { Resources = new ResourceContainer { MaxResources = 1 } }; // Shadow Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f); shadowTransform.Translation = new Vector3(0.0f, -.25f, 0.0f); SpriteSheet shadowTexture = new SpriteSheet(ContentPaths.Effects.shadowcircle); Shadow = new Shadow(Manager, "Shadow", Physics, shadowTransform, shadowTexture); List <Point> shP = new List <Point> { new Point(0, 0) }; Animation shadowAnimation = new Animation(Graphics, new SpriteSheet(ContentPaths.Effects.shadowcircle), "sh", 32, 32, shP, false, Color.Black, 1, 0.7f, 0.7f, false); Shadow.AddAnimation(shadowAnimation); shadowAnimation.Play(); Shadow.SetCurrentAnimation("sh"); // The bird will emit a shower of blood when it dies DeathParticleTrigger = new ParticleTrigger("blood_particle", Manager, "Death Gibs", Physics, Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 1, BoxTriggerTimes = 10 }; // The bird is flammable, and can die when exposed to fire. Flames = new Flammable(Manager, "Flames", Physics, this); // Tag the physics component with some information // that can be used later Physics.Tags.Add("Deer"); Physics.Tags.Add("Animal"); Stats.FullName = TextGenerator.GenerateRandom("$firstname"); Stats.CurrentClass = new EmployeeClass() { Name = "Deer", Levels = new List <EmployeeClass.Level>() { new EmployeeClass.Level() { Index = 0, Name = "Deer" } } }; }