GridGenerator.UpdateGridMap C# (CSharp) Méthode

UpdateGridMap() public méthode

public UpdateGridMap ( ) : void
Résultat void
    public void UpdateGridMap()
    {
        //initialise parent object group
        if(GameObject.Find("Units") == null){
            new GameObject("Units");
        }
        if(GameObject.Find("Buildings") == null){
            new GameObject("Buildings");
        }
        //refresh tree
        if(GameObject.Find("Vegetation") != null){
            GameObject.DestroyImmediate(GameObject.Find("Vegetation"));
        }
        new GameObject("Vegetation");
        //get size of grids
        GetGridSize();
        //TODO: all constants are hard coded, this is bad
        foreach(GameObject e in m_grids){
            TnGAttribute tempTnG = e.GetComponent<TnGAttribute>();
            HexGridModel tempModel = e.GetComponent<HexGridModel>();
            //update height of grid
            if(tempTnG.m_height < 1)
                tempTnG.m_height = 1;
            if(tempTnG.m_height > 10)
                tempTnG.m_height = 10;
            Vector3 scaling = new Vector3(1.0f,0.2f*tempTnG.m_height,1.0f);
            e.transform.localScale = scaling;

            //object has unit on top, place unit to proper place
            if(tempTnG.m_unit != null){
                tempTnG.m_unit.transform.position =
                    new Vector3(tempModel.m_center.x,e.renderer.bounds.max.y,tempModel.m_center.y);
                tempTnG.m_unit.tag = "Unit";
                tempTnG.m_unit.transform.parent = GameObject.Find("Units").transform;
            }
            if(tempTnG.m_building != null){
                tempTnG.m_building.transform.position =
                    new Vector3(tempModel.m_center.x,e.renderer.bounds.max.y,tempModel.m_center.y);
                tempTnG.m_building.tag = "Building";
                tempTnG.m_building.transform.parent = GameObject.Find("Buildings").transform;
            }

            //place trees on top of forest
            if(tempTnG.m_terrainType == TerrainType.forest)
            {
                PlantTrees(e);
            }
        }
    }