Example #1
0
 public static void LoadBluePrints()
 {
     /*
      * using(StreamReader r = new StreamReader("World/Entity/Blueprint/test.json"))
      * {
      *  string json = r.ReadToEnd();
      *  System.Console.WriteLine(json);
      *  var obj = JsonConvert.DeserializeObject<BaseEntity>(json, new JsonSerializerSettings()
      *          {
      *              TypeNameHandling = TypeNameHandling.Objects
      *          });
      *  System.Console.WriteLine(string.Format("obj.ToString():{0}", obj.ToString()));
      * }
      */
     using (StreamWriter w = new StreamWriter("World/Entity/Blueprint/test.json"))
     {
         var testMob = new BaseEntity();
         testMob.AddComponent(new SpriteAnimation('M', Color.Blue, Color.Black));
         testMob.AddComponent(new Actor());
         string s = JsonConvert.SerializeObject(testMob, Formatting.Indented, new JsonSerializerSettings
         {
             TypeNameHandling       = TypeNameHandling.Objects,
             TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple
         });
         w.Write(s);
     }
 }
Example #2
0
        public DungeonScreen(Game gameRef, GameStateManager manager) : base(gameRef, manager)
        {
            //TODO: Get these values dynamically.
            int width  = 80;
            int height = 45;

            messageConsole = new MessagePanel((int)(width), (int)(height * 0.30));
            Add(messageConsole);
            dungeonViewConsole     = new DungeonViewConsole((int)(width * 0.80), (int)(height * 0.70), 30, 30);
            characterStatusPanel   = new CharacterStatusPanel((int)(width * 0.20), (int)(height * 0.70));
            inventoryConsole       = new InventoryConsole((int)(width * 0.30), (int)(height * 0.60));
            characterStatusConsole = new CharacterStatusConsole((int)(width * 0.30), (int)(height * 0.60));


            characterStatusPanel.Position   = new Point((int)(width * 0.80), 0);
            messageConsole.Position         = new Point(0, (int)(height * 0.70));
            inventoryConsole.Position       = new Point((int)(width * 0.80) / 2, (int)(width * 0.30) / 2);
            characterStatusConsole.Position = new Point((int)(width * 0.10), (int)(width * 0.30) / 2);
            Add(characterStatusPanel);
            Add(dungeonViewConsole);

            BaseEntity test_item = new BaseEntity();

            test_item.NAME = "Test Item";
            test_item.AddComponent(new Item(ItemType.Food));
            test_item.AddComponent(new SpriteAnimation('Y', Color.Red, Color.Yellow));

            BaseEntity test_eq = new BaseEntity();

            test_eq.NAME = "Test Sword";
            test_eq.AddComponent(new Item(ItemType.Equipment, "A Really Sharp Sword."));
            test_eq.AddComponent(new Statistic(EquipmentSlot.Hand));
            test_eq.GetComponent <Statistic>(ComponentType.Stats).attack.AddMod("add", 10);
            test_eq.AddComponent(new Attack());
            test_eq.AddComponent(new SpriteAnimation('/', Color.Green, Color.Black));

            inventoryConsole.Hide();
            characterStatusConsole.Hide();
            inventoryConsole.inventoryUser           = dungeonViewConsole.Player;
            characterStatusConsole.StatusConsoleUser = dungeonViewConsole.Player;
            dungeonViewConsole.mapLevel.ItemContainer.Add(test_item);
            dungeonViewConsole.mapLevel.ItemContainer.Add(test_eq);

            inventoryConsole.inventory.AddItem(test_item);
            inventoryConsole.inventory.AddItem(test_eq);
            //TODO: Find a way to init those dynamically.

            dungeonViewConsole.Player.GetComponent <Actor>(ComponentType.Actor).Stats.StatsChanged += characterStatusPanel.StatusChanged;
            dungeonViewConsole.Player.GetComponent <Actor>(ComponentType.Actor).Stats.StatsChanged += characterStatusConsole.StatusChanged;
            dungeonViewConsole.mapLevel.EntityContainer[0].GetComponent <Actor>(ComponentType.Actor).Stats.StatsChanged += characterStatusPanel.actor_StatusChanged;
        }
Example #3
0
        private void Start()
        {
            if (Main == null)
            {
                Main = this;
            }

            Renderer = (EditorRenderer)Engine.Renderer;

            //init editor gui
            ImGuiController.OnImGui += OnImGui;

            BaseEntity.AddComponent <GridRenderer>();
            BaseEntity.AddComponent <SceneHierachy>();
            BaseEntity.AddComponent <Inspector>();
            BaseEntity.AddComponent <AssetManager>();

            pc = BaseEntity.AddComponent <ProjectManager>();

            editorCamera = new Entity("EditorCamera");
            editorCamera.AddComponent <Camera>();
            cm = editorCamera.AddComponent <CameraMove>();

            editorCamera.Unlist();
        }
Example #4
0
        public void CreateCone()
        {
            var entity = new ConeEntity("cone" + _currentEntityIndex++.ToString())
            {
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Cone,
                InDesign             = _inDesign,
                Diameter             = 5.0f,
                Height = 5.0f,
                Scale  = new Vector3(5, 5, 5)
            };

            BaseEntity baseEntity = new BaseEntity
                                    (
                entity.GetEntityName(),
                this,
                SceneDebugRenderer,
                new Vector3(10, 2.5f, 0),
                new Vector3(0, 0, 0),
                entity.Scale
                                    )
            {
                InDesign = _inDesign
            };

            baseEntity.AddComponent(entity);

            PulsarModel model = new PulsarModel(entity.GetEntityName());

            baseEntity.AddComponent(model);
            model.SetModel("Models/Cone.mdl");

            PulsarMaterial material = new PulsarMaterial(entity.GetEntityName());

            baseEntity.AddComponent(material);
            material.SetMaterial("Materials/StoneTiled.xml");

            model.SetMaterial(material);
            entity.CreateEntity();

            //ensure the gizmo is not visible on first creation
            baseEntity.GetGizmo().SetGizmoVisible(false);
        }
        public DungeonViewConsole(int viewWidth, int viewHeight, int mapWidth, int mapHeight) : base(mapWidth, mapHeight)
        {
            RogueSharp.MapCreation.IMapCreationStrategy <RogueSharp.Map> ms = (RogueSharp.MapCreation.IMapCreationStrategy <RogueSharp.Map>) new RogueSharp.MapCreation.RandomRoomsMapCreationStrategy <RogueSharp.Map>(mapWidth, mapHeight, 100, 13, 7);

            mapLevel = new MapLevel(mapWidth, mapHeight, ms, TextSurface);

            inputManager = new InputManager();
            inputManager.AddButton(Keys.Down, Input.South);
            inputManager.AddButton(Keys.Up, Input.North);
            inputManager.AddButton(Keys.Left, Input.West);
            inputManager.AddButton(Keys.Right, Input.East);
            inputManager.AddButton(Keys.OemPeriod, Input.None);
            inputManager.AddButton(Keys.OemComma, Input.Pickup);

            inputManager.AddButton(Keys.NumPad2, Input.South);
            inputManager.AddButton(Keys.NumPad8, Input.North);
            inputManager.AddButton(Keys.NumPad4, Input.West);
            inputManager.AddButton(Keys.NumPad6, Input.East);
            inputManager.AddButton(Keys.NumPad9, Input.NorthEast);
            inputManager.AddButton(Keys.NumPad7, Input.NorthWest);
            inputManager.AddButton(Keys.NumPad3, Input.SouthEast);
            inputManager.AddButton(Keys.NumPad1, Input.SouthWest);
            inputManager.AddButton(Keys.NumPad5, Input.None);

            TextSurface.RenderArea = new Rectangle(0, 0, viewWidth, viewHeight);
            playerEntity           = new BaseEntity(GameWorld.MessageLog);
            playerEntity.NAME      = "Player";
            playerEntity.AddComponent(new PlayerInput());
            playerEntity.AddComponent(new Inventory());
            playerEntity.AddComponent(new Actor(Color.Orange, Color.Black, mapLevel, 10, 10, 10, 10, '@'));
            playerEntity.AddComponent(new FOV());
            mapLevel.CameraFollow = playerEntity;

            testMob = new BaseEntity(GameWorld.MessageLog);
            testMob.AddComponent(new Actor(mapLevel));
            testMob.AddComponent(new AI());
            mapLevel.EntityContainer.Add(testMob);
            mapLevel.EntityContainer.Add(playerEntity);

            testMob.GetComponent <SpriteAnimation>(ComponentType.SpriteAnimation).Position      = mapLevel.MapData.GetWalkablePosition();
            playerEntity.GetComponent <SpriteAnimation>(ComponentType.SpriteAnimation).Position = mapLevel.MapData.GetWalkablePosition();
        }
Example #6
0
        public void CreateCylinder()
        {
            var entity = new CylinderEntity("cylinder" + _currentEntityIndex++.ToString())
            {
                PulsarComponentClass = PulsarComponent.ComponentClass.Node,
                PulsarComponentType  = PulsarComponent.ComponentType.Cylinder,
                InDesign             = _inDesign,
                Diameter             = 5.0f,
                Height = 5.0f,
                Scale  = new Vector3(1, 1, 1)
            };

            BaseEntity baseEntity = new BaseEntity
                                    (
                entity.GetEntityName(),
                this,
                SceneDebugRenderer,
                new Vector3(-5, 2.5f, 0),
                new Vector3(0, 0, 0),
                entity.Scale
                                    )
            {
                InDesign = _inDesign
            };

            baseEntity.AddComponent(entity);

            PulsarModel model = new PulsarModel(entity.GetEntityName());

            baseEntity.AddComponent(model);
            model.SetModel("Models/Cylinder.mdl");

            PulsarMaterial material = new PulsarMaterial(entity.GetEntityName());

            baseEntity.AddComponent(material);
            material.SetMaterial("Materials/StoneTiled.xml");

            model.SetMaterial(material);
            entity.CreateEntity();
        }
Example #7
0
 public void SetMaterial(PulsarMaterial material)
 {
     if (material != null)
     {
         _model.SetMaterial(material.Material);
         if (_baseEntity != null)
         {
             Component existingComponent = _baseEntity.Components.ToList().Find(component => component.Equals(material));
             if (existingComponent == null)
             {
                 _baseEntity.AddComponent(material);
             }
             else
             {
                 //if in select mode, the Gizmo handles the temporary material which will need updating
                 GizmoHelper.UpdateTemporaryMaterialStore(_model.Node, material.Material);
             }
         }
     }
 }