public Tile spawnReinforcementAtNextMarker() { if (GameManagerTacticsInterface.instance.intoTheBreachMode) { for (int i = 0; i < board.passiveObjects.Count; i++) { PassiveObject passive = board.passiveObjects [i]; if (passive.type == PassiveObject.PassiveObjectType.ReinforcementMarker) { ReinforcementMarker thisMarker = (ReinforcementMarker)passive; thisMarker.isDone = true; Tile originTile = board.getTileFromPos(thisMarker.CurTilePos); podPlacement.makePod(this, board, originTile, thisMarker.challengeRating, curAreaNum); //manually remove the marker board.passiveObjects.RemoveAt(i); return(originTile); //just one at a time } } } return(null); }
private void advanceAITurn() { if (gm.GameIsOver) { return; } aiTurnPhase++; Debug.Log("ai phase: " + aiTurnPhase); //check for reinforcements (this will happen for every AI unit even though there could only be reinforcements before the first one, but it will just be skipped if there are none) if (aiTurnPhase == -1) { ReinforcementMarker marker = gm.getNextReinforcementMarker(); if (marker == null) { Debug.Log("no reinforcements, skip ahead"); aiTurnPhase = 1; //skip ahead } else { //otherwise focus the cam Debug.Log("get ready to reinforce"); cam.setTarget(marker.CurTilePos); return; } } if (aiTurnPhase == 0) { Debug.Log("time now to reinforce"); Tile reinforcementTile = gm.spawnReinforcementAtNextMarker(); //if there was nothing, move on if (reinforcementTile == null) { aiTurnPhase++; } //otherwise hang out here and focus the camera else { Debug.Log("we got more reinforcememnts"); aiTurnPhase = -2; cam.setTarget(reinforcementTile.Pos); return; } } //if there is no active AI unit, move on if (gm.activeAIUnit == null) { if (intoTheBreachMode) { aiTurnPhase = -2; gm.startCleanupPhase(); } else { aiTurnPhase = -2; gm.startPlayerTurn(); } return; } //are we done with this AI unit's turn? Debug.Log("active ai: " + gm.activeAIUnit.idName); Debug.Log(" at: " + gm.activeAIUnit.CurTile.Pos.x + " , " + gm.activeAIUnit.CurTile.Pos.y); Debug.Log("active info: " + gm.activeAIUnit.aiTurnInfo); //Debug.Log("active moves: "+gm.activeAIUnit.aiTurnInfo.moves); //if the unit is out of moves or has none, end their turn if (aiTurnPhase == 1) { if (gm.activeAIUnit.aiTurnInfo == null) { gm.endAITurn(); aiTurnPhase = -2; //reset for next time return; } if (gm.activeAIUnit.curAITurnStep >= gm.activeAIUnit.aiTurnInfo.moves.Count) { gm.endAITurn(); aiTurnPhase = -2; return; } } //otherwise reveal the card and mark the target if (aiTurnPhase == 1) { //turn on the reveal flag if (gm.activeAIUnit.aiTurnInfo.moves [gm.activeAIUnit.curAITurnStep].passMove == false) { string cardIDName = gm.activeAIUnit.aiTurnInfo.moves [gm.activeAIUnit.curAITurnStep].cardIDName; Card thisCard = gm.activeAIUnit.deck.getCardInHandFromID(cardIDName); TilePos targetPos = gm.activeAIUnit.aiTurnInfo.moves [gm.activeAIUnit.curAITurnStep].targetTilePos; //if the unit or the target is visible, demo it if (gm.board.Grid [targetPos.x, targetPos.y].isVisibleToPlayer || gm.activeAIUnit.getIsVisibleToPlayer() || intoTheBreachMode) { autoPlayAITurn = false; thisCard.revealAICardFlag = true; //spawn one or more targets TargetGO target = GameObjectManager.instance.getTargetGO(); target.activate(targetPos, thisCard.baseHighlightColor); //focus camera on the target cam.setTarget(targetPos); //if the target is a unit and the card is an attack, let's get some info about the hit Unit thisUnit = gm.board.getUnitOnTile(targetPos); if (thisUnit != null) { thisCard.setPotentialTargetInfo(thisUnit); } } //otherwise, just move on else { autoPlayAITurn = true; } } else { Instantiate(passTurnMarkerPrefab, gm.activeAIUnit.CurTile.Pos.getV3(), Quaternion.identity); } } //play the card if (aiTurnPhase == 2) { if (gm.activeAIUnit.aiTurnInfo.moves [gm.activeAIUnit.curAITurnStep].passMove == false) { gm.advanceAITurn(); aiTurnPhase = 0; autoPlayAITurn = !gm.activeAIUnit.getIsVisibleToPlayer() && !intoTheBreachMode; //remove targets GameObjectManager.instance.turnOffAllTargets(); } else { aiTurnPhase = -2; //reset for next time gm.endAITurn(); } } }