Example #1
0
    /// <summary>
    /// Updates the world to represent the boundary that is being made by the player.
    /// </summary>
    public void DisplayMap()
    {
        ClearMap();
        for (int i = 0; i < map.GetWidth(); i++)
        {
            for (int j = 0; j < map.GetHeight(); j++)
            {
                switch (map.GetTypeAtPosition(i, j))
                {
                case SingleSpaceType.VERTICAL_STRAIGHT:
                    GameObject.Instantiate(verticalStraightPrefab,
                                           ConvertToWorldPosition(new Vector2Int(i, j)), new Quaternion());
                    break;

                case SingleSpaceType.HORIZONTAL_STRAIGHT:
                    GameObject.Instantiate(horizontalStraightPrefab,
                                           ConvertToWorldPosition(new Vector2Int(i, j)), new Quaternion());
                    break;

                case SingleSpaceType.CORNER_1Q:
                    GameObject.Instantiate(corner1QPrefab,
                                           ConvertToWorldPosition(new Vector2Int(i, j)), new Quaternion());
                    break;

                case SingleSpaceType.CORNER_2Q:
                    GameObject.Instantiate(corner2QPrefab,
                                           ConvertToWorldPosition(new Vector2Int(i, j)), new Quaternion());
                    break;

                case SingleSpaceType.CORNER_3Q:
                    GameObject.Instantiate(corner3QPrefab,
                                           ConvertToWorldPosition(new Vector2Int(i, j)), new Quaternion());
                    break;

                case SingleSpaceType.CORNER_4Q:
                    GameObject.Instantiate(corner4QPrefab,
                                           ConvertToWorldPosition(new Vector2Int(i, j)), new Quaternion());
                    break;

                case SingleSpaceType.PLAYER_SPAWN:
                    if (editable)
                    {
                        GameObject.Instantiate(playerSpawnPrefab,
                                               ConvertToWorldPosition(new Vector2Int(i, j)), new Quaternion());
                    }
                    break;
                }
            }
        }
    }
Example #2
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="copy">The BoundaryMap to be copied from.</param>
 public BoundaryMap(BoundaryMap copy)
 {
     width              = copy.GetWidth();
     height             = copy.GetHeight();
     gridRepresentation = new SingleSpaceType[width, height];
     for (int i = 0; i < width; i++)
     {
         for (int j = 0; j < height; j++)
         {
             gridRepresentation[i, j] = copy.GetTypeAtPosition(i, j);
         }
     }
     playerSpawnPos_x = copy.GetPlayerSpawnX();
     playerSpawnPos_y = copy.GetPlayerSpawnY();
 }