Example #1
0
 public Game1()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     FileStream fileStream = new FileStream("Content\\GameContent\\Maps.xml", FileMode.Open);
     XmlSerializer xml = new XmlSerializer(typeof(Maps));
     maps = (Maps)xml.Deserialize(fileStream);
 }
Example #2
0
        public bool constructMap(int counter, Maps maps)
        {
            map = new MapCell[Engine.MAP_LENGTH, Engine.MAP_HEIGHT];

            for (int i = 0; i < map.GetLength(0); i++)
            {
                row row = maps.maps[counter].rows[i];
                var chars = row.text.ToCharArray();
                for (int j = 0; j < map.GetLength(1); j++)
                {
                    int type = 0;
                    char numchar = chars[j];
                    type = Convert.ToInt32(new string(numchar,1));
                    map[i,j] = new MapCell(type, i.ToString() + j.ToString(), j*Engine.TILE_WIDTH, i*Engine.TILE_HEIGHT, Engine.TILE_WIDTH, Engine.TILE_HEIGHT);
                }
            }
            constructPlayer(counter, maps);
            constructEnd(counter, maps);
            constructEnemies(counter, maps);
            constructGameObjects(counter, maps);
            constructTriggers(counter, maps);
            return false;
        }
Example #3
0
        public void constructEnemies(int counter, Maps maps)
        {
            enemies = new List<Enemy>();
            for (int i = 0; i < maps.maps[counter].Enemies.Count; i++)
            {
                Enemy temp = new Enemy(maps.maps[counter].Enemies[i].id, "Object",
                    maps.maps[counter].Enemies[i].XLoc, maps.maps[counter].Enemies[i].YLoc,
                    maps.maps[counter].Enemies[i].Width, maps.maps[counter].Enemies[i].Height,
                    maps.maps[counter].Enemies[i].Horizontal, maps.maps[counter].Enemies[i].Left,
                    maps.maps[counter].Enemies[i].Up, maps.maps[counter].Enemies[i].Speed);
                if (temp._horizontal)
                {
                    if (temp._left)
                    {
                        temp.direction = Direction.LEFT;
                    }
                    else
                    {
                        temp.direction = Direction.RIGHT;
                    }
                }
                else
                {
                    if (temp._up)
                    {
                        temp.direction = Direction.UP;
                    }
                    else
                    {
                        temp.direction = Direction.DOWN;
                    }
                }

                enemies.Add(temp);
            }
        }
Example #4
0
 public void constructGameObjects(int counter, Maps maps)
 {
     gameObjects = new List<GameObjectChild>();
     for (int i = 0; i < maps.maps[counter].GameObjects.Count; i++)
     {
         GameObjectChild temp = new GameObjectChild(maps.maps[counter].GameObjects[i].id,
             "Object", maps.maps[counter].GameObjects[i].XLoc, maps.maps[counter].GameObjects[i].YLoc,
             maps.maps[counter].GameObjects[i].Width, maps.maps[counter].GameObjects[i].Height);
         temp._collider = maps.maps[counter].GameObjects[i].Collision;
         gameObjects.Add(temp);
     }
 }
Example #5
0
 public void constructEnd(int counter, Maps maps)
 {
     endGoal = new EndGoal(3, "Target", maps.maps[counter].EndGoal[0].XLoc, maps.maps[counter].EndGoal[0].YLoc, Engine.ENDGOAL_WIDTH, Engine.ENDGOAL_HEIGHT);
 }
Example #6
0
 public void constructPlayer(int counter, Maps maps)
 {
     player = new Player(4, "Player", maps.maps[counter].Player[0].XLoc, maps.maps[counter].Player[0].YLoc, Engine.PLAYER_WIDTH, Engine.PLAYER_HEIGHT);
 }
Example #7
0
 public void constructTriggers(int counter, Maps maps)
 {
     triggers = new List<Trigger>();
     for (int i = 0; i < maps.maps[counter].Triggers.Count; i++)
     {
         List<int> tempList = new List<int>();
         for (int j = 0; j < maps.maps[counter].Triggers[i].InfoItems.Count; j++)
         {
             int tempint = maps.maps[counter].Triggers[i].InfoItems[j].Item;
             tempList.Add(tempint);
         }
         Trigger temp = new Trigger(maps.maps[counter].Triggers[i].id,
             "Trigger", maps.maps[counter].Triggers[i].XLoc, maps.maps[counter].Triggers[i].YLoc,
             maps.maps[counter].Triggers[i].Width, maps.maps[counter].Triggers[i].Height,
             tempList);
         temp._collider = false;
         triggers.Add(temp);
     }
 }