Example #1
0
    private void PrintBoard()
    {
        GameObject go = Resources.Load <GameObject>(FilePath.TilePrefab);
        SavedDatabase <TileTypes> tiles = Globals.campaign.GetTileData().Tiles;

        int sizeX = baseMap.sizeX;
        int sizeY = baseMap.sizeY;

        pathfinding = new Pathfinding(sizeX, sizeY);

        for (int x = 0; x < sizeX; x++)
        {
            for (int y = 0; y < sizeY; y++)
            {
                // Heres where we'll probably adjust the height map stuff
                GameObject temp = Instantiate(go, transform);
                TileData   data = new TileData(x, y);

                // Creating new tile types
                // We have to rework how maps are saved
                TileTypes types = tiles.GetCopy(baseMap.tileBoard[x, y]);

                Tile newTile = temp.GetComponent <Tile>();
                temp.GetComponent <Tile>().InitTile(data, types);

                pathfinding.AddTile(newTile, x, y);

                temp.transform.position = Globals.GridToWorld(x, y);

                temp.GetComponent <SpriteRenderer>().sprite = atlas.GetSprite(types.spriteFilePath);
                temp.name = x + " " + y;
            }
        }

        pathfinding.PopulateNieghbors();
    }
Example #2
0
    void GenerateBoard()
    {
        GameObject go = Resources.Load <GameObject>(FilePath.TilePrefab);
        SavedDatabase <TileTypes> tileDB = Globals.campaign.GetTileData().Tiles;

        int sizeX = currMap.sizeX;
        int sizeY = currMap.sizeY;

        pathfinding = new Pathfinding(sizeX, sizeY);
        EffectBoard = new TileEffectSprite[sizeX, sizeY];

        for (int x = 0; x < sizeX; x++)
        {
            for (int y = 0; y < sizeY; y++)
            {
                //Heres where we'll probably adjust the height map stuff

                GameObject temp = Instantiate(go, transform);
                TileData   data = new TileData(x, y);

                // maybe we should create a new board that will just replace the board in the current
                // map?
                TileTypes types = tileDB.GetCopy(currMap.tileBoard[x, y]);
                //currMap.tileBoard[x, y] = types;

                Tile newTile = temp.GetComponent <Tile>();
                temp.GetComponent <Tile>().InitTile(data, types);

                pathfinding.AddTile(newTile, x, y);

                // temp.transform.position = Globals.HeightCorrectedPosition(pathfinding.tiles[x, y]);
                temp.transform.position = Globals.GridToWorld(x, y);

                temp.GetComponent <SpriteRenderer>().sprite = atlas.GetSprite(types.spriteFilePath);
                temp.name = x + " " + y;

                // we create a concection between the tile effects on the map and the
            }
        }

        if (currentMission.started == false)
        {
            foreach (Tuple <MapCoords, List <string> > key in currentMission.initTileEffects)
            {
                int x = key.ele1.X;
                int y = key.ele1.Y;

                List <TileEffect> effects = new List <TileEffect>();

                foreach (string s in key.ele2)
                {
                    effects.Add(Globals.campaign.GetTileData().Effects.GetCopy(s));
                }

                pathfinding.tiles[x, y].tileEffects = effects;
                pathfinding.tiles[x, y].InitTileEffect();
                pathfinding.tiles[x, y].InitTileEffectsVisuals();
                pathfinding.tiles[x, y].ProcessEffectQueue();
            }
        }

        pathfinding.PopulateNieghbors();
    }