示例#1
0
文件: Game.cs 项目: Woljix/Xalizium
        public void LoadMap(string Filename)
        {
            // Very Hardcoded ATM, i'll fix this later when i feel like it.

            if (File.Exists(Filename))
            {
                string[] file = File.ReadAllLines(Filename);

                for (int y = 0; y < file.Length; y++)
                {
                    for (int x = 0; x < file[y].Length; x++)
                    {
                        Block  block  = null;
                        Entity entity = null;

                        char c = file[y][x];
                        switch (c)
                        {
                        case 'X': block = (Block)Blockionary.GetBlockByName("BlockDummy"); break;

                        case 'Z': block = (Block)Blockionary.GetBlockByName("BlockMockWall"); break;

                        case '#': World.Player.Position = new Vector2(x, y); break;

                        case 'O': block = (Block)Blockionary.GetBlockByName("BlockFloorDummy"); break;

                        case 'T': entity = new CharacterDummy(); break;

                        case 'H': block = (Block)Blockionary.GetBlockByName("BlockHealth"); break;
                        }

                        if (block != null)
                        {
                            block.Position = new Vector2(x, y);
                            GameObject.Create(block);
                        }

                        if (entity != null)
                        {
                            entity.Position = new Vector2(x, y);
                            World.EntityManager.Add(entity);
                        }
                    }
                }
            }
        }
示例#2
0
文件: Game.cs 项目: Woljix/Xalizium
        public Game()
        {
            Blockionary.Add("BlockDummy", new BlockDummy());
            Blockionary.Add("BlockFloorDummy", new BlockFloorDummy());
            Blockionary.Add("BlockHealth", new BlockHealth());
            Blockionary.Add("BlockMockWall", new BlockMockWall());

            Entitionary.Add("CharacterDummy", new CharacterDummy());

            //Debug.WriteLine(Blockionary._blocks.Count);

            PluginManager.LoadAllTheFiles();

            // NOTE: Maybe use this for initializing GameObjects & Items for later use.

            LoadMap("Map1.txt");

            //Map.LoadMap("Map2.json");

            //MapFile.MakeCurrentMapIntoFile("Map2.json");
        }