public static string ConverCellTypeText(HexCellType type)
    {
        switch (type)
        {
        case HexCellType.Desert:
            return("沙漠");

        case HexCellType.Forest:
            return("森林");

        case HexCellType.Grass:
            return("草原");

        case HexCellType.Hill:
            return("丘陵");

        case HexCellType.Montain:
            return("山脉");

        case HexCellType.Snow:
            return("雪原");

        case HexCellType.Water:
            return("湖泊");

        default: return("");
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Creates the map decorations
    /// </summary>
    private void PlaceSceneryObjects()
    {
        if (occupyingSceneryObjects.Length == 0)
        {
            Debug.LogError("No scenery objects have been assigned!");
            return;
        }

        // Code from https://stackoverflow.com/a/3188804
        HexCellType tallestCellType = cellTypes.Aggregate((t1, t2) => t1.elevation > t2.elevation ? t1 : t2);

        PlaceSceneryOnMapEdge(tallestCellType);
        PlaceSceneryOnPlayArea(occupyingSceneryObjects, true, tallestCellType);
        PlaceSceneryOnPlayArea(nonOccupyingSceneryObjects, false, tallestCellType);
    }
Exemplo n.º 3
0
    private void PlaceSceneryOnMapEdge(HexCellType tallestCellType)
    {
        // Adding a wall around the map
        foreach (HexCell cell in edgeCells)
        {
            if (mountainBorder)
            {
                cell.CellType = tallestCellType;
            }

            if (treeBorder)
            {
                GameObject sceneryObj = cell.InstantiatePrefabOnCell(occupyingSceneryObjects[0]);
                float      yRotation  = Random.Range(0f, 360f);
                sceneryObj.transform.Rotate(0, yRotation, 0);
            }
        }
    }
Exemplo n.º 4
0
    private void PlaceSceneryOnPlayArea(GameObject[] sceneryObjects, bool occupying, HexCellType tallestCellType)
    {
        foreach (HexCell cell in cells)
        {
            float elevation = cell.CellType.elevation;
            if (Random.Range(0, 100) > 10f ||
                elevation < 0 ||
                elevation >= tallestCellType.elevation ||
                cell.IsOccupied)
            {
                continue;
            }

            int        sceneryIndex  = Random.Range(0, sceneryObjects.Length);
            GameObject sceneryObject = cell.InstantiatePrefabOnCell(sceneryObjects[sceneryIndex]);
            float      yRotation     = Random.Range(0f, 360f);
            sceneryObject.transform.Rotate(0, yRotation, 0);

            if (!occupying)
            {
                cell.OccupyingObject = null;
            }
        }
    }