Monster GetNextMonsterOfTeam(string team) { Monster[] currentTeam = ((team == "A")?teamA:teamB); for (int i = 0; i < currentTeam.Length; i++) { if (currentTeam[i].state != Global.State.Dead) { return(currentTeam[i]); } } battlePhase = Global.BattlePhase.BattleEnds; return(null); }
void Start () { teamAChoices = new int[teamA.Length]; teamASkillChoices = new int[teamA.Length]; teamAItemChoices = new int[teamA.Length]; teamAAllyTargets = new int[teamA.Length]; teamAEnemyTargets = new int[teamA.Length]; teamBChoices = new int[teamB.Length]; teamBSkillChoices = new int[teamB.Length]; teamBItemChoices = new int[teamB.Length]; teamBAllyTargets = new int[teamB.Length]; teamBEnemyTargets = new int[teamB.Length]; InitChoices(); print("Battle Start!"); //battleGUIManager.DisplayMessage("Battle start!"); battlePhase = Global.BattlePhase.TeamASelection; }
void Start() { teamAChoices = new int[teamA.Length]; teamASkillChoices = new int[teamA.Length]; teamAItemChoices = new int[teamA.Length]; teamAAllyTargets = new int[teamA.Length]; teamAEnemyTargets = new int[teamA.Length]; teamBChoices = new int[teamB.Length]; teamBSkillChoices = new int[teamB.Length]; teamBItemChoices = new int[teamB.Length]; teamBAllyTargets = new int[teamB.Length]; teamBEnemyTargets = new int[teamB.Length]; InitChoices(); print("Battle Start!"); //battleGUIManager.DisplayMessage("Battle start!"); battlePhase = Global.BattlePhase.TeamASelection; }
void Update () { // Battle Ends if(battlePhase == Global.BattlePhase.BattleEnds) { print("Battle Ends!"); return; } // Team A Selection if(battlePhase == Global.BattlePhase.TeamASelection) { print("Select your action!"); if(teamAChoices[currentMonster] != 0 || teamA[currentMonster].state == Global.State.Dead) { if(teamA.Length > (currentMonster+1)) { currentMonster++; } else { battlePhase = Global.BattlePhase.TeamBSelection; currentMonster = 0; currentEnemy = 0; } } } // Team B Selection if(battlePhase == Global.BattlePhase.TeamBSelection) { print("The enemy is selecting his action!"); AIEnemySelection(); currentMonster = 0; currentEnemy = 0; battlePhase = Global.BattlePhase.ExecuteActions; OrderMonstersBySpeed(); } // Execute Actions if(battlePhase == Global.BattlePhase.ExecuteActions) { print("Executing actions!"); if(!waitingToNextExecution) { if(monsters[currentMonster].state != Global.State.Dead) { if(choices[currentMonster] == 1) { // Attack Monster currentMonsterTarget = ((teams[currentMonster] != "A")?teamA[enemyTargets[currentMonster]]:teamB[enemyTargets[currentMonster]]); if(currentMonsterTarget.state == Global.State.Dead) currentMonsterTarget = GetNextMonsterOfTeam( ((teams[currentMonster] != "A")?"A":"B") ); if(battlePhase != Global.BattlePhase.BattleEnds) monsters[currentMonster].Attack( currentMonsterTarget ); waitingToNextExecution = true; battleGUIManager.DisplayMessage(monsters[currentMonster].name + " attacks!"); } else if(choices[currentMonster] == 2) { // Use skill if(monsters[currentMonster].skills[skillChoices[currentMonster]].numberOfTargets == Global.NumberOfTargets.OneEnemy) { Monster currentMonsterTarget = ((teams[currentMonster] != "A")?teamA[enemyTargets[currentMonster]]:teamB[enemyTargets[currentMonster]]); if(currentMonsterTarget.state == Global.State.Dead) currentMonsterTarget = GetNextMonsterOfTeam( ((teams[currentMonster] != "A")?"A":"B") ); monsters[currentMonster].UseSkill(skillChoices[currentMonster], currentMonsterTarget); } else { monsters[currentMonster].UseSkill(skillChoices[currentMonster], teamA[allyTargets[currentMonster]]); } waitingToNextExecution = true; battleGUIManager.DisplayMessage(monsters[currentMonster].name + " use " + monsters[currentMonster].skills[skillChoices[currentMonster]].name + "!"); } else if(choices[currentMonster] == 4) { // Use item //if(teams[currentMonster] == "A") { Item item = teamAPlayer.items[itemChoices[currentMonster]]; //} else { // TODO: add this action to the team B //} if(item.numberOfTargets == Global.NumberOfTargets.OneAlly) { monsters[currentMonster].UseItem(teams[currentMonster], itemChoices[currentMonster], teamA[allyTargets[currentMonster]]); } else if(item.numberOfTargets == Global.NumberOfTargets.Himself) { monsters[currentMonster].UseItem(teams[currentMonster], itemChoices[currentMonster], monsters[currentMonster]); } else if(item.numberOfTargets == Global.NumberOfTargets.AllAlly) { monsters[currentMonster].UseItem(teams[currentMonster], itemChoices[currentMonster]); } waitingToNextExecution = true; battleGUIManager.DisplayMessage(monsters[currentMonster].name + " use a " + item.name + "!"); } } } if((!monsters[currentMonster].IsAttacking() && !monsters[currentMonster].IsUsingSkill() && !monsters[currentMonster].IsUsingItem()) && !monsters[currentMonster].IsMovingToInitialPosition()) { waitingToNextExecution = false; if(haveSurvivors("A") && haveSurvivors ("B")) { if(monsters.Length > (currentMonster+1)) { currentMonster++; } else { InitChoices(); battlePhase = Global.BattlePhase.TeamASelection; } } else { battleGUIManager.DisplayMessage(((haveSurvivors("A"))?"Victory":"Defeated"), -1.0f, true); battlePhase = Global.BattlePhase.BattleEnds; } } } }
Monster GetNextMonsterOfTeam(string team) { Monster[] currentTeam = ((team == "A")?teamA:teamB); for(int i=0; i < currentTeam.Length; i++) { if(currentTeam[i].state != Global.State.Dead) { return currentTeam[i]; } } battlePhase = Global.BattlePhase.BattleEnds; return null; }
void Update() { // Battle Ends if (battlePhase == Global.BattlePhase.BattleEnds) { print("Battle Ends!"); return; } // Team A Selection if (battlePhase == Global.BattlePhase.TeamASelection) { print("Select your action!"); if (teamAChoices[currentMonster] != 0 || teamA[currentMonster].state == Global.State.Dead) { if (teamA.Length > (currentMonster + 1)) { currentMonster++; } else { battlePhase = Global.BattlePhase.TeamBSelection; currentMonster = 0; currentEnemy = 0; } } } // Team B Selection if (battlePhase == Global.BattlePhase.TeamBSelection) { print("The enemy is selecting his action!"); AIEnemySelection(); currentMonster = 0; currentEnemy = 0; battlePhase = Global.BattlePhase.ExecuteActions; OrderMonstersBySpeed(); } // Execute Actions if (battlePhase == Global.BattlePhase.ExecuteActions) { print("Executing actions!"); if (!waitingToNextExecution) { if (monsters[currentMonster].state != Global.State.Dead) { if (choices[currentMonster] == 1) { // Attack Monster currentMonsterTarget = ((teams[currentMonster] != "A")?teamA[enemyTargets[currentMonster]]:teamB[enemyTargets[currentMonster]]); if (currentMonsterTarget.state == Global.State.Dead) { currentMonsterTarget = GetNextMonsterOfTeam(((teams[currentMonster] != "A")?"A":"B")); } if (battlePhase != Global.BattlePhase.BattleEnds) { monsters[currentMonster].Attack( currentMonsterTarget ); } waitingToNextExecution = true; battleGUIManager.DisplayMessage(monsters[currentMonster].name + " attacks!"); } else if (choices[currentMonster] == 2) { // Use skill if (monsters[currentMonster].skills[skillChoices[currentMonster]].numberOfTargets == Global.NumberOfTargets.OneEnemy) { Monster currentMonsterTarget = ((teams[currentMonster] != "A")?teamA[enemyTargets[currentMonster]]:teamB[enemyTargets[currentMonster]]); if (currentMonsterTarget.state == Global.State.Dead) { currentMonsterTarget = GetNextMonsterOfTeam(((teams[currentMonster] != "A")?"A":"B")); } monsters[currentMonster].UseSkill(skillChoices[currentMonster], currentMonsterTarget); } else { monsters[currentMonster].UseSkill(skillChoices[currentMonster], teamA[allyTargets[currentMonster]]); } waitingToNextExecution = true; battleGUIManager.DisplayMessage(monsters[currentMonster].name + " use " + monsters[currentMonster].skills[skillChoices[currentMonster]].name + "!"); } else if (choices[currentMonster] == 4) { // Use item //if(teams[currentMonster] == "A") { Item item = teamAPlayer.items[itemChoices[currentMonster]]; //} else { // TODO: add this action to the team B //} if (item.numberOfTargets == Global.NumberOfTargets.OneAlly) { monsters[currentMonster].UseItem(teams[currentMonster], itemChoices[currentMonster], teamA[allyTargets[currentMonster]]); } else if (item.numberOfTargets == Global.NumberOfTargets.Himself) { monsters[currentMonster].UseItem(teams[currentMonster], itemChoices[currentMonster], monsters[currentMonster]); } else if (item.numberOfTargets == Global.NumberOfTargets.AllAlly) { monsters[currentMonster].UseItem(teams[currentMonster], itemChoices[currentMonster]); } waitingToNextExecution = true; battleGUIManager.DisplayMessage(monsters[currentMonster].name + " use a " + item.name + "!"); } } } if ((!monsters[currentMonster].IsAttacking() && !monsters[currentMonster].IsUsingSkill() && !monsters[currentMonster].IsUsingItem()) && !monsters[currentMonster].IsMovingToInitialPosition()) { waitingToNextExecution = false; if (haveSurvivors("A") && haveSurvivors("B")) { if (monsters.Length > (currentMonster + 1)) { currentMonster++; } else { InitChoices(); battlePhase = Global.BattlePhase.TeamASelection; } } else { battleGUIManager.DisplayMessage(((haveSurvivors("A"))?"Victory":"Defeated"), -1.0f, true); battlePhase = Global.BattlePhase.BattleEnds; } } } }