Exemple #1
0
    public static Ground Create(GroundName a, Cell parentCell)
    {
        GameObject pref;

        if (a == GroundName.Grassland)
        {
            pref = grasslandPref;
        }
        else if (a == GroundName.Sea)
        {
            pref = waterPref;
        }
        else if (a == GroundName.Mountain)
        {
            pref = mountainPref;
        }
        else
        {
            pref = voidPref;
        }

        GameObject parent = parentCell.gameObject;

        GameObject ground = Instantiate(
            pref,
            parent.transform.position,
            Quaternion.identity,
            parent.transform.parent);

        Ground groundScript = ground.GetComponent <Ground>();

        groundScript.altitude = a;

        return(groundScript);
    }
Exemple #2
0
    public void SpawnGroundOnCellByAltitude(Cell cell, GroundName altitude)
    {
        cell.ground          = InstantiateGroundOnCell(cell, groundPrefabs[altitude]);
        cell.ground.altitude = altitude;
        ResetHoverOnCell(cell);

        // rename the object in the editor
        cell.ground.gameObject.name = cell.ground.altitude.ToString();
    }
Exemple #3
0
    public GameObject GetGroundbyName(GroundName a_Name)
    {
        string name = a_Name.ToString();

        if (!_GroundsbyName.ContainsKey(name))
        {
            Debug.LogError(string.Format("ERROR! Ground \"{0}\" not found!", name));
            return(null);
        }
        else
        {
            return(_GroundsbyName[name]);
        }
    }
Exemple #4
0
 public void LoopGroundOnCellByAltitude(Cell cell, GroundName groundName)
 {
     // Void, Sea -> Grassland
     if (groundName == GroundName.Void || groundName == GroundName.Sea)
     {
         SpawnGroundOnCellByAltitude(cell, GroundName.Grassland);
     }
     // Mountain -> Sea
     else if (groundName == GroundName.Mountain)
     {
         SpawnGroundOnCellByAltitude(cell, GroundName.Sea);
     }
     // Grassland -> Mountain
     else
     {
         SpawnGroundOnCellByAltitude(cell, GroundName.Mountain);
     }
 }
Exemple #5
0
 public void SetGroundOnCell(Cell cell, GroundName groundName)
 {
     Destroy(cell.ground.gameObject);
     instantiator.SpawnGroundOnCellByAltitude(cell, groundName);
 }