Пример #1
0
 private void InitializeMap(DiffuseAble typeToInitialize, int iterations = 50)
 {
     for (int i = 0; i < iterations; i++)
     {
         typeToInitialize.FullDiffuse();
     }
 }
Пример #2
0
 private void updateLists()
 {
     heightMap      = GridManager.Singleton.TypeToDiffuse[typeof(Height)];
     treeCityMap    = GridManager.Singleton.TypeToDiffuse[typeof(Tree)];
     saltMap        = GridManager.Singleton.TypeToDiffuse[typeof(SaltLevels)];
     temperatureMap = GridManager.Singleton.TypeToDiffuse[typeof(Temperature)];
     nutrientsMap   = GridManager.Singleton.TypeToDiffuse[typeof(Nutrients)];
     hydrationMap   = GridManager.Singleton.TypeToDiffuse[typeof(Hydration)];
 }
Пример #3
0
    public void setTiles(DiffuseAble heightLst, DiffuseAble valLst, Color clrPos, Color clrNeg, int clrMergeOption, bool setHeight)
    {
        if (tileList == null)
        {
            genTiles(heightLst, heightPosClr, heightNegClr);
        }

        updateTiles(heightLst, valLst, clrPos, clrNeg, clrMergeOption, setHeight);
    }
Пример #4
0
    public void updateTiles(DiffuseAble heightLst, DiffuseAble valLst, Color clrPos, Color clrNeg, int clrMergeOption, bool setHeight)
    {
        //float heightMult = (lst.Count + lst[0].L.Count) / 2 * heightScale;

        for (int x = 0; x < GridManager.Singleton.Width; x++)
        {
            for (int y = 0; y < GridManager.Singleton.Height; y++)
            {
                Tile currTile = tileList[x][y];

                currTile.posClr = clrPos;
                currTile.negClr = clrNeg;

                currTile.clrMergeOption = clrMergeOption;

                //Tile tileHandler = currTile.GetComponent<Tile>();

                float currHeight    = heightLst.GetValueWithOutEffects(x, y);
                float currHeightVal = heightLst.GetValueWithEffects(x, y); // for color
                float currVal       = valLst.GetValueWithEffects(x, y);

                float currCityVal = treeCityMap.GetValueWithEffects(x, y);
                if (currCityVal < 0)
                {
                    currCityVal *= -1;
                    currCityVal  = currCityVal * Time.deltaTime / 200;
                    if (Random.Range(0f, 1f) < currCityVal)
                    {
                        //Debug.Log("POINT POP AT: " + x + "," + y);
                        GameObject carbonPointObj = Instantiate(carbonPoint);
                        carbonPointObj.transform.position = new Vector3(currTile.transform.position.x, currTile.transform.lossyScale.y, currTile.transform.position.z);
                    }
                }

                //float currHeight = mapHeight(currVal);
                //Debug.Log("2gen tile " + x + "," + y + " val: " + currVal);

                if (setHeight)
                {
                    currTile.setHeight(currHeight);
                }
                currTile.setHeightVal(currHeightVal);
                currTile.setVal(currVal);
                //currTile.setColor(currClr);
            }
        }
    }
Пример #5
0
 public void genTiles(DiffuseAble lst, Color clrPos, Color clrNeg)
 {
     tileList = new List <List <Tile> >();
     for (int x = 0; x < GridManager.Singleton.Width; x++)
     {
         tileList.Add(new List <Tile>());
         for (int y = 0; y < GridManager.Singleton.Height; y++)
         {
             GameObject currTile    = Instantiate(tile);
             Tile       tileHandler = currTile.GetComponent <Tile>();
             tileHandler.hPosClr       = clrPos;
             tileHandler.hNegClr       = clrNeg;
             tileHandler.heightScale   = (GridManager.Singleton.Width + GridManager.Singleton.Height) / 2 * heightScale;
             tileHandler.animTime      = animTimeSec;
             tileHandler.clrMin        = clrMin;
             tileHandler.mergeVal      = mergeVal;
             currTile.transform.parent = transform;
             tileHandler.setPos(new Vector3(x, 0, y));
             tileList[x].Add(tileHandler);
         }
     }
 }