public void StartABattle(int who) { if (humansInvolved[who]) { StartCoroutine(map.FIGHT(time, map, who)); } else { // calculate if AI even wants to battle OutputToBattle oB = OutputToBattle.CalculateOutput(fighter[who]); // if the result of oB is to battle, if (oB.toBattle) { StartCoroutine(map.FIGHT(time, map, who)); } else // otherwise we'll just entirely skip its turn { GM.turnSyncer++; fighter[who].CheckIfRanTooMuch(); } } }
void TakeTurn() { // At the start of the turn, do a checkup on the fighters for (int i = 0; i < fighter.Length; i++) { fighter[i].stateData.Update(turn); fighter[i].CheckUp(map); } // We must reset the tile renderings map.ResetAllTiles(); // if (humansInvolved[turn]) { // check if the 3 variables have changed since the last frame if (p_D != dist || p_aX != angleX || p_aY != angleY) { // Get the movement data outp[turn] = Map.OutputLocation(map, fighter[turn].expression, fighter[turn == 0 ? 1 : 0].expression, dist, angleX, angleY, humanUsing: true); // if (dist >= .5f) { fighter[turn].RanAway(); } // if (outp[turn] != null) { p_D = dist; p_aX = angleX; p_aY = angleY; } } // Set camera to turnee map.SetCamTo(Map.camMode, turn); // if (fighter[turn].isStunned) { StartCoroutine(map.FIGHT(time, map, turn)); // incriment the turn _turn++; p_D = -1; p_aY = -1; p_aX = -1; } else { if (Input.GetKeyDown(KeyCode.Space)) { // start our Coroutine of moving our fighter StartCoroutine(map.MoveFighter(time, outp[turn].loc.Count > 0, map, turn, outp[turn].path)); // incriment the turn _turn++; p_D = -1; p_aY = -1; p_aX = -1; } else if (Input.GetKeyDown(KeyCode.Backspace)) { StartCoroutine(map.FIGHT(time, map, turn)); // incriment the turn _turn++; p_D = -1; p_aY = -1; p_aX = -1; } } } else { // OutputMakeMove s = OutputMakeMove.CalculateNormal(fighter[turn]); // Calculate if moving if (s.stay || fighter[turn].isStunned) { // calculate if AI even wants to battle OutputToBattle oB = OutputToBattle.CalculateOutput(fighter[turn]); // if the result of oB is to battle, if (oB.toBattle) { // start the coroutine to start the fight StartCoroutine(map.FIGHT(time, map, turn)); } else // otherwise we'll just entirely skip its turn { GM.turnSyncer++; } // incriment the turn _turn++; } else { // Calculate the move output OutputMove m = OutputMove.CalculateOutput(fighter[turn]); // if (m.distance >= .5f) { fighter[turn].RanAway(); } // Get the movement data outp[turn] = Map.OutputLocation(map, fighter[turn].expression, fighter[turn == 0 ? 1 : 0].expression, m.distance, m.angleX, m.angleY); // start our Coroutine of moving our fighter StartCoroutine(map.MoveFighter(time, outp[turn].loc.Count > 0, map, turn, outp[turn].path)); // incriment the turn _turn++; } } // turnTxt.text = $"{GM.timer}"; }