Exemple #1
0
 /// <summary>Set the type of this Tile</summary>
 /// <param name="type">Type of Tile.</param>
 /// <param name="objectPos">Position of Tile in world space.</param>
 /// <param name="tileList">List of Tile Prefabs.</param>
 public void SetTileType(HexTileType type, Vector3 objectPos, TileList tileList)
 {
     switch (type) {
         case HexTileType.Flat:
             SetTileObject(tileList.hexagonFlat, objectPos, true);
             break;
         case HexTileType.FlatSand:
             SetTileObject(tileList.hexagonFlatSand, objectPos, true);
             break;
         case HexTileType.Hill:
             SetTileObject(tileList.hexagonHill, objectPos, false);
             break;
         default:
             tileObject = null; isWalkable = false;
             break;
     }
 }
Exemple #2
0
 /// <summary>
 /// Set all tiles to one type.
 /// </summary>
 /// <param name="type">Tile type</param>
 public void SetAllTiles(HexTileType type)
 {
     for(int x = 0; x < _boardWidth; x++){
         for(int y = 0; y < _boardHeight; y++){
             if (GetTile(x, y) != null) GetTile(x, y).Destroy();
             SetTile(x, y, new HexTile(x, y));
             GetTile(x, y).SetTileType(type, CalcHexPosition(new Point2(x, y)), _tileList);
         }
     }
 }
Exemple #3
0
    public void SetTile(Point2 pos, HexTileType h)
    {
        myBoard.GetTile(pos).Destroy();
        myBoard.SetTile(pos, new HexTile(pos));
        myBoard.GetTile(pos).SetTileType(h, myBoard.CalcHexPosition(pos), tileList);

        GameObject particles = (GameObject)Instantiate(tileList.toggleEffect, myBoard.CalcHexPosition(pos) + (Vector3.up * 0.4f), Quaternion.identity);
        particles.GetComponent<ParticleSystem>().Play();
        Destroy(particles, 2);
    }
    GameObject GetTileObjectByType(HexTileType type)
    {
        GameObject tilePrefab;
        if (type == HexTileType.Normal)
        {
            tilePrefab = NormalTiles[UnityEngine.Random.Range(0, NormalTiles.Length)];
        }
        else if (type == HexTileType.Wall)
        {
            tilePrefab = NormalTiles[UnityEngine.Random.Range(0, NormalTiles.Length)];
        }
        else
        {
            // ERROR
            Debug.LogError("ERROR: TileType not handled");
            tilePrefab = new GameObject();
        }

        return tilePrefab;
    }
Exemple #5
0
 /// <summary>Set all tiles to one tile type.</summary>
 /// <param name="type">Type of tile to use.</param>
 public void SetAllTiles(HexTileType type)
 {
     myBoard.SetAllTiles(type);
 }