public IEnumerator UpdateTurn() { uiController.SetPlayerTurnIndicators(); yield return(new WaitForSeconds(0.5f)); if (firstTurn) { firstTurn = false; playerTurn = true; //uiController.SetEndTurnButtonState(); } if (combatActive) { if (playerTurn && abilityController.AbilityUsed && movementController.HasMoved) { if (abilityController.laserRange < resourceAndUpgradeManager.CurrentMaxLaserRange) { abilityController.laserRange += resourceAndUpgradeManager.CurrentMaxLaserRecharge; if (abilityController.laserRange > resourceAndUpgradeManager.CurrentMaxLaserRange) { abilityController.laserRange = resourceAndUpgradeManager.CurrentMaxLaserRange; } } if (abilityController.jumpRange < resourceAndUpgradeManager.CurrentMaxJumpRange) { abilityController.jumpRange += resourceAndUpgradeManager.CurrentMaxJumpRecharge; if (abilityController.jumpRange > resourceAndUpgradeManager.CurrentMaxJumpRange) { abilityController.jumpRange = resourceAndUpgradeManager.CurrentMaxJumpRange; } } if (abilityController.currentRocketReloadAmount < abilityController.rocketReloadTime) { abilityController.currentRocketReloadAmount++; } if (abilityController.currentShieldBoostCharge < abilityController.shieldBoostRechargeTime) { abilityController.currentShieldBoostCharge++; } GameObject[] rockets = GameObject.FindGameObjectsWithTag("Rocket"); foreach (GameObject rocket in rockets) { rocket.GetComponent <RocketController>().turnsAlive++; } playerTurn = false; enemyTurn = true; //Debug.Log("Update UI. Reset player controls"); //Debug.Log("TM 74"); // movementController.HasMoved = false; abilityController.AbilityUsed = false; abilityController.HasFired = false; StartCoroutine("OrderEnemyTurns"); } else if (enemyTurn) { //Debug.Log("Order enemy turns. Update UI"); enemyTurn = false; playerTurn = true; //uiController.SetEndTurnButtonState(); } } else { //Debug.Log("Reset all combat stats"); abilityController.laserRange = abilityController.maxLaserRange; abilityController.jumpRange = resourceAndUpgradeManager.CurrentMaxJumpRange; abilityController.currentRocketReloadAmount = abilityController.rocketReloadTime; abilityController.currentShieldBoostCharge = abilityController.shieldBoostRechargeTime; uiController.SetLaserCharge(abilityController.laserRange, abilityController.maxLaserRange); uiController.SetJumpCharge(abilityController.jumpRange, resourceAndUpgradeManager.CurrentMaxJumpRange); uiController.SetRocketReloadState(abilityController.currentRocketReloadAmount, abilityController.rocketReloadTime); uiController.SetShieldBoostRechargeState(abilityController.currentShieldBoostCharge, abilityController.shieldBoostRechargeTime); movementController.HasMoved = false; abilityController.AbilityUsed = false; playerHealthControl.RestoreShields(); mapManager.ClearHighlighting(); if (mapManager.saveName == "TutorialFile") { tutorialManager.PlayerWon(); } } uiController.SetEndTurnButtonState(); }
public void JumpActive() { //Debug.Log("Jump"); if (laserState) { LaserActive(); } else if (shieldState) { ShieldActive(); } else if (rocketState) { RocketsActive(); } //Debug.Log("ability checkpoints: Player turn -"+ turnManager.playerTurn +"; Weapon state - "+ weaponState + "; Ability used - " + abilityUsed + "; Combat active - " + turnManager.combatActive); if (turnManager.playerTurn && weaponState && !abilityUsed && turnManager.combatActive) { jumpState = !jumpState; abilityActive = jumpState; jumpCells.Clear(); //player.GetComponent<MovementController>().abilityActive = jumpState; GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); //create a list of any enemies that are currently in the scene for (int x = -jumpRange; x <= jumpRange; x++) //iterate through the range of the laser to generate the x coordinates { for (int y = -jumpRange; y <= jumpRange; y++) //iterate through the range of the laser to generate the y coordindates { Vector3Int tempCell = movementController.playerCellPosition + new Vector3Int(x, y, 0); float hexCellDistance = mapManager.HexCellDistance(mapManager.evenq2cube(gridLayout.WorldToCell(player.transform.position)), mapManager.evenq2cube(tempCell)); bool cellUnavailable = false; //Debug.Log("hex cell distance " + hexCellDistance); if (hexCellDistance <= jumpRange) { foreach (GameObject enemy in enemies) { if (tempCell == gridLayout.WorldToCell(enemy.transform.position)) { cellUnavailable = true; } } if (tempCell.x > mapManager.mapXMax || tempCell.x < mapManager.mapXMin || tempCell.y > mapManager.mapYMax || tempCell.y < mapManager.mapYMin) { cellUnavailable = true; } if (!cellUnavailable) { jumpCells.Add(tempCell); } } } } mapManager.HighlightSet(jumpCells, jumpState); //Debug.Log("Jump cell count is " + jumpCells.Count); //Debug.Log("jump range is " + jumpRange); //foreach (Vector3Int cell in jumpCells) //{ // Debug.Log(cell); //} if (!jumpState) { mapManager.ClearHighlighting(); } } }