示例#1
0
 public IEnumerator GenerateMazeAnim()   // maakt de maze in een soort van animatie
 {
     _path = new List <RoomData>();
     GetRandomStart();
     while (_path.Count > 0)
     {
         _currentX = _curChecking.GridX;
         _currentY = _curChecking.GridY;
         List <RoomData.WallDir> directions = new List <RoomData.WallDir>();
         for (int i = 0; i < 4; i++)
         {
             if (_curChecking.ContainsWall((RoomData.WallDir)i))
             {
                 directions.Add((RoomData.WallDir)i);
             }
         }
         if (directions.Count != 0)
         {
             ChangeColor(_curChecking, Color.yellow);
             CheckRoom(directions[GetRandomDir(directions.Count)]);
         }
         else if (_path.Count - 1 > 0)
         {
             ChangeColor(_curChecking, Color.white);
             _distance--;
             _path.Remove(_path[_path.Count - 1]);
             _curChecking = _path[_path.Count - 1];
             ChangeColor(_curChecking, Color.yellow);
         }
         else
         {
             ChangeColor(_curChecking, Color.white);
             break;
         }
         yield return(new WaitForSeconds(_animSpeed));
     }
     MakeEnds();
 }