Exemple #1
0
 public void SetTarget(GameObject target)
 {
     this.target = target;
 }
Exemple #2
0
 // Reads the textfile and creates a tile or gameobject
 public void CreateMap(List<String> list)
 {
     ReadString(list);
     int Cost = 1;
     nodeArray = new Node[list.Count, list[1].Length];
     for (int i = 0; i < list.Count; i++)
     {
         for (int j = 0; j < list[i].Length; j++)
         {
             if (list[i][j] == 'x')
             {
                 nodeArray[i, j] = new Node(false, Cost, i, j);
                 wallList.Add(new Wall_Tile(tex2, new Vector2((j * 20), (i * 20))));
             }
             if (list[i][j] == 'f')
             {
                 nodeArray[i, j] = new Node(true, Cost, i, j);
                 floorList.Add(new Food_Tile(tex3, new Vector2((j * 20), (i * 20))));
             }
             if (list[i][j] == 's')
             {
                 nodeArray[i, j] = new Node(true, Cost, i, j);
                 floorList.Add(new Food_Tile(tex2, new Vector2((j * 20), (i * 20))));
                 specialWall.Add(new Food_Tile(tex2, new Vector2((j * 20), (i * 20))));
             }
             if (list[i][j] == 'b')
             {
                 nodeArray[i, j] = new Node(true, Cost, i, j);
                 floorList.Add(new Bonus_Tile(tex1, new Vector2((j * 20), (i * 20))));
                 bonusList.Add(new Bonus_Tile(tex1, new Vector2((j * 20), (i * 20))));
             }
             if (list[i][j] == 'u')
             {
                 nodeArray[i, j] = new Node(true, Cost, i, j);
                 floorList.Add(new Uber_Tile(tex1, new Vector2((j * 20), (i * 20))));
                 uberList.Add(new Uber_Tile(tex1, new Vector2((j * 20), (i * 20))));
             }
             if (list[i][j] == 'g')
             {
                 nodeArray[i, j] = new Node(true, Cost, i, j);
                 ghost = new Ghost(tex1, new Vector2((j * 20), (i * 20)));
                 ghostList.Add(ghost);
                 objectList.Add(ghost);
             }
             if (list[i][j] == 'p')
             {
                 nodeArray[i, j] = new Node(true, Cost, i, j);
                 pacman = new Pacman(tex1, new Vector2((j * 20), (i * 20)));
                 objectList.Add(pacman);
             }
         }
     }
     Ghost g = (Ghost)ghostList[0];
     g.SetTarget(pacman);
     g.FindPath();
     maxScore = floorList.Count();
 }