Ejemplo n.º 1
0
    void Start()
    {
        //make copy of the grid so you can modify it
        Dictionary <Vector2, GameTypes.MapType> grid = new Dictionary <Vector2, GameTypes.MapType>(mGrid);

        //check the already instantiated Regions to see if their properties match the default grid
        foreach (Region reg in mWorldManager.getRegions())
        {
            Vector2           rgp = reg.getGridPos();
            GameTypes.MapType mt  = reg.mType;
            if (mGrid.ContainsKey(rgp))
            {
                //the grid knows about this Region
                mGrid[rgp] = mt;
                grid.Remove(rgp);
            }
            else
            {
                //the grid doesnt know about this region
                mGrid.Add(rgp, mt);
            }
        }
        //make other regions defined in the default
        foreach (KeyValuePair <Vector2, GameTypes.MapType> kp in grid)
        {
            //make a new region
            ObjectManager.initRegion(kp.Key, kp.Value, mWorldManager, mWorldManager.getRandomSeed());
        }
    }
Ejemplo n.º 2
0
    //-------------------------------------------------------------------------------------------------
    // public methods
    //-------------------------------------------------------------------------------------------------

    public void addGridEntry(Vector2 loc, GameTypes.MapType mtype)
    {
        if (hasGridEntry(loc))
        {
            Debug.LogError("This entry already exists in the GridMap");
        }
        mGrid[loc] = mtype;
    }
Ejemplo n.º 3
0
        //init Region function
        public static Region initRegion(Vector2 grid_pos, GameTypes.MapType mt, WorldManager wm, int seed)
        {
            Region reg = GameObject.Instantiate(getRegion("Region"), wm.gameObject.transform).GetComponent <Region>();

            reg.setGridPos(grid_pos);
            reg.mType = mt;
            reg.mSeed = seed;
            //wm.addRegion(reg);
            return(reg);
        }
Ejemplo n.º 4
0
        //init map function
        public static Map initMap(Vector3 pos, GameTypes.MapType mt, Region reg, int seed)
        {
            Map map = GameObject.Instantiate(getMap(mt.ToString()), reg.gameObject.transform).GetComponent <Map>();

            map.gameObject.transform.position = pos;
            map.mType = mt;
            reg.addMap(map);
            map.mSeed = seed;
            return(map);
        }