// Use this for initialization
 void Start()
 {
     griddata     = grid.GetComponent <Griddrawing>();
     mapdata      = grid.GetComponent <Samplezeromapgrid>();
     otherdogdata = otherdog.GetComponent <New_method_dogmove>();
     //mapdata.setallfree();
     mapdata.settwentyfree();
     //mapdata.setmapA();
     //mapdata.setmapB();
     //mapdata.setmapC();
     realchanceset();
     blockallo.blockinit();
     targetpos          = new Vector3(posx * 32.0f / 20.0f, posy * 32.0f / 20.0f, 0.0f);
     transform.position = targetpos;
 }
Esempio n. 2
0
    public void blockinit()
    {
        gridmap = grid.GetComponent <Griddrawing>();
        mapdata = grid.GetComponent <Samplezeromapgrid>();
        ysize   = gridmap.verticalgridnum;
        xsize   = gridmap.horizongridnum;
        maxsize = gridmap.maxgridnum;

        for (int y = 0; y < ysize; y++)
        {
            for (int x = 0; x < xsize; x++)
            {
                float textureScaling = 0.1f + (0.9f * (mapdata.chance[x, y] / 100.0f));
                blocks.transform.GetChild((y * xsize) + x).position   = new Vector3(((float)maxsize / xsize) * x, ((float)maxsize / ysize) * y, 0.0f);
                blocks.transform.GetChild((y * xsize) + x).localScale = new Vector3(5.0f / xsize, 5.0f / ysize, 1.0f);
                blockcolor = new Color(textureScaling, textureScaling, textureScaling, textureScaling);
                blocks.transform.GetChild((y * xsize) + x).GetComponent <SpriteRenderer>().color = blockcolor;
            }
        }
    }