protected override void Awake() { game = BaseSaver.getGame(); GameObject.Find("HeaderTxt").GetComponent <Text> ().text = game.name; gridCanvas = GetComponentInChildren <Canvas>(); hexMesh = GetComponentInChildren <HexMesh>(); BattleInfo thisBattle = BaseSaver.getBattle(); if (thisBattle != null) { boardHeight = thisBattle.height > 0 ? thisBattle.height : 10; boardWidth = thisBattle.width > 0 ? thisBattle.width : 10; } else { boardHeight = 6; boardWidth = 8; } cells = new HexCell[boardHeight * boardWidth]; for (int z = 0, i = 0; z < boardHeight; z++) { for (int x = 0; x < boardWidth; x++) { CreateCell(x, z, i++); } } }
protected override void checkEnd() { bool playersLeft = checkCells(true); bool enemyLeft = checkCells(false); if (!playersLeft || !enemyLeft) { if (!playersLeft) { Debug.Log("Enemy Wins!"); } else { Debug.Log("Player Wins!"); } BattleInfo battle = BaseSaver.getBattle(); //This means that the player was attacked by the monster if (battle == null) { battle = new BattleInfo(); battle.redirect = "AdventureScene"; } battle.won = playersLeft; BaseSaver.putBattle(battle); SceneManager.LoadScene(battle.redirect); } }
void checkEndGame() { BattleInfo battle = BaseSaver.getBattle(); if (battle != null) { if (battle.won) { Debug.Log("Won"); } else { Debug.Log("Lost"); } BaseSaver.resetBattle(); SceneManager.LoadScene("EndGameScene"); } }
void Start() { BattleInfo thisBattle = BaseSaver.getBattle(); if (thisBattle != null) { placeAround(boardWidth + 1, thisBattle.playerRoster, 0, true); // UnitInfo[] roster = new UnitInfo[3]; // for (int i = 0; i < 3; i++) { // UnitInfo info = new UnitInfo (); // info.playerNo = 0; // info.type = UnitInfo.unitType.Lancer; // info.human = true; // roster[i] = info; // } // placeAround(0, roster, 0, true); placeAround(cells.Length - 2 - boardWidth, thisBattle.enemyRoster, 1, false); focusOnCell(cells[boardWidth + 1]); } else { placeAround(0, game.playerRoster, 0, true); focusOnCell(cells[0]); placePlayer(cells[cells.Length - 1], 1, false, UnitInfo.unitType.Monster, false); } foreach (HexCell cell in cells) { cell.setType(TileInfo.tileType.Road); } hexMesh.Triangulate(cells); setPTurn(players - 1); EndTurn(); ResetCells(); ResetBoard(); }
public void selectChoice(int btn, int idx, bool callback) { // ChoiceInfo choice = glossy.options[idx].GetComponent<ChoiceMain>().choice; OptionInfo option = lstOptions [btn - 1]; if (callback) { GameObject.Find("InfoDescription").GetComponent <Text> ().text = BaseSaver.getBattle().won ? choice.winningGreeting : choice.losingGreeting; OptionInfo final = new OptionInfo(); final.TextOptions = new string[] { "Continue" }; final.result = OptionInfo.resultType.None; final.reaction = "<confirm/>"; populateInfoButtons(new OptionInfo[] { final }); BaseSaver.resetBattle(); BaseSaver.resetChoice(); } else { if (!option.reaction.Equals("<confirm/>")) { GameObject.Find("InfoDescription").GetComponent <Text> ().text = option.reaction; OptionInfo final = new OptionInfo(); final.TextOptions = new string[] { "Continue" }; final.result = (option.result == OptionInfo.resultType.MiniGame || option.result == OptionInfo.resultType.Battle) ? option.result : OptionInfo.resultType.None; final.reaction = "<confirm/>"; populateInfoButtons(new OptionInfo[] { final }); } else { if (option.result == OptionInfo.resultType.MiniGame) { BaseSaver.putChoice(choice, idx, btn); SceneManager.LoadScene("MiniGameScene"); } else { if (option.result == OptionInfo.resultType.Battle) { BaseSaver.putChoice(choice, idx, btn); GameInfo game = BaseSaver.getGame(); BattleInfo battle = new BattleInfo(); battle.redirect = "ChoiceScene"; battle.playerRoster = game.playerRoster; int enemies = 2; battle.height = 5; battle.width = 7; switch (choice.difficulty) { case ChoiceInfo.DifficultyType.Medium: enemies = 4; battle.height = 6; battle.width = 8; break; case ChoiceInfo.DifficultyType.Hard: enemies = 6; battle.height = 7; battle.width = 9; break; case ChoiceInfo.DifficultyType.Insane: enemies = 10; battle.height = 10; battle.width = 12; break; } battle.enemyRoster = new UnitInfo[enemies]; for (int i = 0; i < enemies; i++) { UnitInfo info = new UnitInfo(); info.playerNo = 0; info.type = choiceArr[Random.Range(0, 3)]; Debug.Log("Choice: " + info.type); info.human = true; battle.enemyRoster [i] = info; } BaseSaver.putBattle(battle); SceneManager.LoadScene("BattleScene"); } else { SceneManager.LoadScene("AdventureScene"); } } } } }