void Start() { checkEndGame(); TileInfo[] bTiles = BaseSaver.getTiles(); UnitInfo[] bUnits = BaseSaver.getUnits(); HexCell hPos = cells [0]; if (bTiles != null && bUnits != null) { game = BaseSaver.getGame(); for (int i = 0; i < cells.Length; i++) { cells [i].SetInfo(bUnits[i]); cells [i].SetTile(bTiles[i]); if (bUnits[i].human) { int mv = game.movement - game.fatigue; cells [i].GetInfo().actions = mv < 0 ? 0 : mv; hPos = cells [i]; focusOnCell(cells [i]); } } GameObject.Find("TurnImg").GetComponent <Image>().color = playerColors [0]; setPTurn(0); /* * Here is where the new quests need to be calculated if there are any */ foreach (QuestInfo quest in game.quests) { if (!quest.placed) { quest.startIdx = hPos.coordinates; List <HexCell> dests = new List <HexCell> (); for (int i = 0; i < cells.Length; i++) { if (cells[i].GetTile().type == quest.locType && !cells[i].GetTile().interaction) { HexCell[] path = HexAI.aStar(cells, hPos, cells[i]); if (path != null && path.Length < 10) { dests.Add(cells[i]); } } } if (dests.Count > 0) { HexCell[] theseDests = dests.ToArray(); HexUtilities.ShuffleArray(theseDests); theseDests [0].GetTile().interaction = true; quest.endIdx = theseDests [0].coordinates; quest.placed = true; Debug.Log("Destination Set: " + quest.endIdx.ToString()); Debug.Log("Tiles saved"); BaseSaver.putBoard(cells, BaseSaver.getBoardInfo().name, BaseSaver.getBoardInfo().height, BaseSaver.getBoardInfo().width); BaseSaver.putGame(game); } else { Debug.Log("No destinations! Quest invalid..."); } } } ResetCells(); hexMesh.Triangulate(cells); // BaseSaver.resetBoard (); } else { Debug.Log("Maps: "); foreach (MapInfo mp in BaseSaver.getMaps()) { Debug.Log(mp.name); } // foreach(HexCell cell in cells) { // cell.GetTile ().fog = true; // } // MapInfo map = BaseSaver.getMap("Basic Level"); // MapInfo map = BaseSaver.getMap(MAP_NAME); Debug.Log("Next Map: " + BaseSaver.getNextMap()); MapInfo map = BaseSaver.getMap(BaseSaver.getNextMap()); List <int> playerPos = new List <int> (); List <int> enemyPos = new List <int> (); for (int i = 0; i < cells.Length; i++) { if (map.tiles[i].type == TileInfo.tileType.pSpawn) { cells[i].setType(TileInfo.tileType.Road); playerPos.Add(i); } else if (map.tiles[i].type == TileInfo.tileType.eSpawn) { cells[i].setType(TileInfo.tileType.Road); enemyPos.Add(i); } else { cells[i].setType(map.tiles[i].type); if (cells[i].GetTile().type == TileInfo.tileType.Castle || cells[i].GetTile().type == TileInfo.tileType.City) { cells [i].GetTile().meta = StaticNames.getTownName(); Debug.Log("Town Name: " + cells [i].GetTile().meta); } } } int[] pArr = playerPos.ToArray(); int[] eArr = enemyPos.ToArray(); HexUtilities.ShuffleArray(pArr); HexUtilities.ShuffleArray(eArr); placePlayer(cells[pArr[0]], 0, false, UnitInfo.unitType.Adventure, true); cells [pArr[0]].removeFog(); placePlayer(cells[eArr[0]], 1, false, UnitInfo.unitType.Adventure, false); // if (players > 2) { // placePlayer(cells[cells.Length - width], 2, false, UnitInfo.unitType.Adventure, false); // } // // if (players > 3) { // placePlayer (cells [width - 1], 3, false, UnitInfo.unitType.Adventure, false); // } // foreach (HexCell cell in cells) { // // cell.setType((TileInfo.tileType) Random.Range(0, 7)); // cell.setType(TileInfo.tileType.Grass); // } // HexCell[] road = HexAI.aStar (cells, cells[0], cells[cells.Length - 1]); // foreach (HexCell cell in road) { // cell.setType(TileInfo.tileType.Road); // } // // HexAdventureGenerator.generateMap (cells, height, width); // // int mountain = Random.Range (3, cells.Length - 3); // cells [mountain].setType (TileInfo.tileType.Mountain); // foreach(HexDirection dir in cells [mountain].dirs) { // if (cells [mountain].GetNeighbor(dir) && TileInfo.tileType.Grass == cells [mountain].GetNeighbor(dir).GetTile().type) { // cells [mountain].GetNeighbor (dir).setType (TileInfo.tileType.Forest); // } // } // foreach (HexCell cell in cells){ // if (cell.GetPlayer() == -1) { // int chp = Random.Range(0, 4); // if (chp == 0) { // cell.GetTile ().interaction = true; //// cell.setLabel ("I"); // } // } // } hexMesh.Triangulate(cells); setPTurn(players - 1); EndTurn(); ResetCells(); } }