Example #1
0
        public static Body GenerateTestSeketon(Vector3 position)
        {
            CreatureDef dwarfDef = ContentPaths.LoadFromJson <CreatureDef>(ContentPaths.Entities.Skeleton.skeleton);
            Creature    toReturn = new Creature(position, dwarfDef, "Skeleton", 0, "Undead");

            toReturn.AI.AddThought(Thought.CreateStandardThought(Thought.ThoughtType.JustArrived, PlayState.Time.CurrentDate), false);
            return(toReturn.Physics);
        }
Example #2
0
 void InitializeAnimations()
 {
     CompositeAnimation.Descriptor descriptor =
         FileUtils.LoadJsonFromString <CompositeAnimation.Descriptor>(
             ContentPaths.GetFileAsString(ContentPaths.Entities.Demon.demon_animations));
     Animations = new List <Animation>();
     Animations.AddRange(descriptor.GenerateAnimations(CompositeLibrary.Demon));
 }
Example #3
0
        public static Body GenerateTestMoleman(WorldManager world, Vector3 position)
        {
            CreatureDef dwarfDef = ContentPaths.LoadFromJson <CreatureDef>(ContentPaths.Entities.Moleman.moleman);
            Creature    toReturn = new Creature(world.ComponentManager, position, dwarfDef, "Moleman Miner", 0, "Molemen");

            toReturn.AI.AddThought(Thought.CreateStandardThought(Thought.ThoughtType.JustArrived, world.Time.CurrentDate), false);
            return(toReturn.Physics);
        }
Example #4
0
 public static Race FindRace(String Name)
 {
     if (Races == null)
     {
         Races = ContentPaths.LoadFromJson <Dictionary <string, Race> >(ContentPaths.World.races);
     }
     return(Races[Name]);
 }
Example #5
0
        public static Body GenerateTestDwarf(Vector3 position)
        {
            CreatureDef dwarfDef = ContentPaths.LoadFromJson <CreatureDef>(ContentPaths.Entities.Dwarf.dwarf);
            Creature    toReturn = new Creature(position, dwarfDef, "Wizard", 0, "Player");

            toReturn.AI.AddThought(Thought.CreateStandardThought(Thought.ThoughtType.JustArrived, PlayState.Time.CurrentDate), false);
            return(toReturn.Physics);
        }
Example #6
0
        public static void InitializeStatics()
        {
            Biomes = ContentPaths.LoadFromJson <List <BiomeData> >(ContentPaths.World.biomes);
            byte id = 0;

            foreach (var biome in Biomes)
            {
                biome.Biome = id;
                id++;
            }
        }
Example #7
0
        public override void OnEnter()
        {
            // Todo - HACK - Remove when input transition is complete.
            DwarfGame.GumInputMapper.GetInputQueue();

            CurrentScroll = 0;
            CreditsFont   = GameState.Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default);
            Entries       = ContentPaths.LoadFromJson <List <CreditEntry> >("credits.json");
            IsInitialized = true;
            IsDone        = false;
            base.OnEnter();
        }
Example #8
0
 void InitializeAnimations()
 {
     /*
      * Texture2D dwarfSprites = TextureManager.GetTexture(ContentPaths.Entities.Dwarf.Sprites.dwarf_animations);
      * Animations = Dwarf.CreateDefaultAnimations(dwarfSprites, 32, 40);
      */
     CompositeAnimation.Descriptor descriptor =
         FileUtils.LoadJsonFromString <CompositeAnimation.Descriptor>(
             ContentPaths.GetFileAsString(ContentPaths.Entities.Dwarf.Sprites.worker_animation));
     Animations = new List <Animation>();
     Animations.AddRange(descriptor.GenerateAnimations(CompositeLibrary.Dwarf));
 }
Example #9
0
        public static void AddClasses(string file)
        {
            if (!staticClassInitialized)
            {
                InitializeClassStatics();
            }
            List <EmployeeClassDef> defs = ContentPaths.LoadFromJson <List <EmployeeClassDef> >(file);

            foreach (EmployeeClassDef empClass in defs)
            {
                Classes[empClass.Name] = new EmployeeClass(empClass);
            }
        }
Example #10
0
        protected void CreateSprite(string animations, ComponentManager manager)
        {
            // Create the sprite component for the bird.
            var sprite = Physics.AddChild(new CharacterSprite
                                              (manager.World.GraphicsDevice,
                                              manager,
                                              "Sprite",
                                              Matrix.CreateTranslation(0, 0.5f, 0)
                                              )) as CharacterSprite;

            CompositeAnimation.Descriptor descriptor =
                FileUtils.LoadJsonFromString <CompositeAnimation.Descriptor>(
                    ContentPaths.GetFileAsString(animations));

            List <CompositeAnimation> animations_list = descriptor.GenerateAnimations(Name);

            foreach (CompositeAnimation animation in animations_list)
            {
                sprite.AddAnimation(animation);
            }
            sprite.SetFlag(Flag.ShouldSerialize, false);
        }
Example #11
0
        public void Initialize(PlayState state, string name, string motto, NamedImageFrame logo, Color color)
        {
            Races = new Dictionary <string, Race>();

            /*
             * Races["Dwarf"] = new Race()
             * {
             *  Name = "Dwarf",
             *  CreatureTypes = new List<string> {"Dwarf", "AxeDwarf"},
             *  IsIntelligent = true,
             *  IsNative = false,
             *  FactionNameFile = ContentPaths.Text.Templates.nations_dwarf,
             *  NameFile = ContentPaths.Text.Templates.names_dwarf,
             *  FactionNameTemplates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.nations_dwarf)
             * };
             *
             * Races["Goblins"] = new Race()
             * {
             *  Name = "Goblins",
             *  CreatureTypes = new List<string> { "Goblin"},
             *  IsIntelligent = true,
             *  IsNative = true,
             *  FactionNameFile = ContentPaths.Text.Templates.nations_dwarf,
             *  NameFile = ContentPaths.Text.Templates.names_goblin,
             *  FactionNameTemplates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.nations_goblin)
             * };
             *
             * Races["Molemen"] = new Race()
             * {
             *  Name = "Molemen",
             *  CreatureTypes = new List<string> { "Moleman" },
             *  IsIntelligent = true,
             *  IsNative = true,
             *  FactionNameFile = ContentPaths.Text.Templates.nations_dwarf,
             *  NameFile = ContentPaths.Text.Templates.names_dwarf,
             *  FactionNameTemplates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.nations_goblin)
             * };
             *
             * Races["Elf"] = new Race()
             * {
             *  Name = "Elf",
             *  CreatureTypes = new List<string> { "Elf" },
             *  IsIntelligent = true,
             *  IsNative = true,
             *  FactionNameFile = ContentPaths.Text.Templates.nations_elf,
             *  NameFile = ContentPaths.Text.Templates.names_elf,
             *  FactionNameTemplates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.nations_elf)
             * };
             *
             * Races["Undead"] = new Race()
             * {
             *  Name = "Undead",
             *  CreatureTypes = new List<string> { "Necromancer", "Skeleton" },
             *  IsIntelligent = true,
             *  IsNative = true,
             *  FactionNameFile = ContentPaths.Text.Templates.nations_undead,
             *  NameFile = ContentPaths.Text.Templates.names_undead,
             *  FactionNameTemplates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.nations_undead)
             * };
             *
             *
             * Races["Herbivore"] = new Race()
             * {
             *  Name = "Herbivore",
             *  CreatureTypes = new List<string> { "Bird", "Deer" },
             *  IsIntelligent = false,
             *  IsNative = true,
             *  FactionNameFile = ContentPaths.Text.Templates.nations_dwarf,
             *  NameFile = ContentPaths.Text.Templates.names_dwarf,
             * };
             */
            Races = ContentPaths.LoadFromJson <Dictionary <string, Race> >(ContentPaths.World.races);

            Factions           = new Dictionary <string, Faction>();
            Factions["Player"] = new Faction
            {
                Name = "Player",
                Race = Races["Dwarf"]
            };
            Factions["Player"].Economy = new Economy(Factions["Player"], 300.0f, state, name, motto, logo, color);

            Factions["Goblins"] = new Faction
            {
                Name = "Goblins",
                Race = Races["Goblins"]
            };

            Factions["Elf"] = new Faction
            {
                Name = "Elf",
                Race = Races["Elf"]
            };

            Factions["Undead"] = new Faction
            {
                Name = "Undead",
                Race = Races["Undead"]
            };

            Factions["Herbivore"] = new Faction
            {
                Name = "Herbivore",
                Race = Races["Herbivore"]
            };


            Factions["Molemen"] = new Faction
            {
                Name = "Molemen",
                Race = Races["Molemen"]
            };
        }
Example #12
0
 public ParticleManager(GraphicsDevice Device, ComponentManager Components)
 {
     Effects = new Dictionary <string, ParticleEffect>();
     Load(Device, Components, ContentPaths.LoadFromJson <Dictionary <string, List <EmitterData> > >(ContentPaths.Particles.particles));
 }
Example #13
0
        public EmployeeClass(EmployeeClassDef definition)
        {
            Name    = definition.Name;
            Levels  = definition.Levels;
            Actions = new List <GameMaster.ToolMode>();
            foreach (string s in definition.Actions)
            {
                GameMaster.ToolMode value = GameMaster.ToolMode.SelectUnits;
                if (Enum.TryParse(s, true, out value))
                {
                    Actions.Add(value);
                }
            }

            CompositeAnimation.Descriptor descriptor = FileUtils.LoadJsonFromString <CompositeAnimation.Descriptor>(ContentPaths.GetFileAsString(definition.Animations));
            Animations = new List <Animation>();
            Animations.AddRange(descriptor.GenerateAnimations(Name));

            Attacks = definition.Attacks;
        }
Example #14
0
 public static T LoadFromJson <T>(string asset)
 {
     return(FileUtils.LoadJsonFromString <T>(ContentPaths.GetFileAsString(asset)));
 }
Example #15
0
 public static void Initialize()
 {
     EmbarkmentLibrary = ContentPaths.LoadFromJson <Dictionary <string, Embarkment> >(ContentPaths.World.embarks);
     DefaultEmbarkment = EmbarkmentLibrary["Normal"];
 }
Example #16
0
        /// <summary>
        /// Initialize function creates all the required components for the bird.
        /// </summary>
        /// <param name="spriteSheet">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 CreatureAI(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.flash)
            };


            // 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
            });
        }
Example #17
0
 public static void InitializeStatics()
 {
     Biomes = ContentPaths.LoadFromJson <Dictionary <Overworld.Biome, BiomeData> >(ContentPaths.World.biomes);
 }
Example #18
0
 public void InitializeRaces()
 {
     Races = new Dictionary <string, Race>();
     Races = ContentPaths.LoadFromJson <Dictionary <string, Race> >(ContentPaths.World.races);
 }
Example #19
0
        public static List <Animation> LoadCompositeAnimationSet(String Path, String CompositeName)
        {
            if (!Animations.ContainsKey(Path))
            {
                try
                {
                    var descriptor = ContentPaths.LoadFromJson <AnimationSetDescriptor>(Path);
                    Animations.Add(Path, GenerateAnimations(CompositeName, descriptor).Select(a =>
                    {
                        bool simplify = true;
                        string asset  = null;
                        foreach (var frame in a.CompositeFrames)
                        {
                            if (frame.Cells.Count != 1)
                            {
                                simplify = false;
                                break;
                            }

                            if (asset == null)
                            {
                                asset = frame.Cells[0].Sheet.AssetName;
                            }
                            else if (asset != frame.Cells[0].Sheet.AssetName)
                            {
                                simplify = false;
                                break;
                            }
                        }

                        if (simplify)
                        {
                            var sheet = a.CompositeFrames[0].Cells[0].Sheet;
                            return(new Animation()
                            {
                                SpriteSheet = sheet,
                                Name = a.Name,
                                Speeds = a.Speeds,
                                Loops = a.Loops,
                                FrameHZ = a.FrameHZ,
                                SpeedMultiplier = a.SpeedMultiplier,
                                //Todo: Support per-cell tint in standard animation?
                                Tint = a.CompositeFrames[0].Cells[0].Tint,
                                Flipped = a.Flipped,
                                Frames = a.CompositeFrames.Select(f => f.Cells[0].Tile).ToList(),
                            });
                        }

                        return(a as Animation);
                    }).ToList());
                }
                catch (Exception)
                {
                    var errorAnimations = new List <Animation>();

                    errorAnimations.Add(
                        new Animation()
                    {
                        SpriteSheet = new SpriteSheet(ContentPaths.Error, 32),
                        Frames      = new List <Point> {
                            Point.Zero
                        },
                        Name = "ERROR"
                    });


                    Animations.Add(Path, errorAnimations);
                }
            }

            return(Animations[Path]);
        }