/// <summary> /// Check if you have enough money to spawn the desired ship. /// </summary> /// <param name="money">money existing in bank</param> /// <param name="spawner">ship to spawn cost</param> /// <returns></returns> public bool checkmoney(int money, int spawner) { bool output = false; int pointstodeploy = unitcon.getshipbynumber(spawner).GetComponent <_Ship>().PointsToDeploy; if (pointstodeploy <= money) { output = true; } else { output = false; } int maxships = UnitMovementcommandcontroller.getmaxshipnumbers(); int currentships = unitcon.teammembersout(unitcon.team).Count; if (currentships >= (maxships - 1)) { output = false; } if (unitcon.running == false) { output = false; } if (output) { unitcon.takemoney(pointstodeploy); } if (unitcon.checkiffactiondead(unitcon.team) == true) { output = false; } return(output); }
/// <summary> /// checks if the bot has enough money and is allowed to spawn ship. /// </summary> /// <param name="spawner"> the unit number corresponding to the desired ship to spawn</param> /// <returns>do you have enough money?</returns> public bool checkmoney(int spawner) { bool output = false; GameObject temp = unitcontrol.getshipbynumber(actualshiptobuy); if (temp) { int pointstodeploy = temp.GetComponent <_Ship>().PointsToDeploy; if (pointstodeploy <= money) { output = true; } else { output = false; } int maxships = UnitMovementcommandcontroller.getmaxshipnumbers(); int currentships = unitcontrol.teammembersout(team).Count; if (currentships >= (maxships - 1)) { output = false; } if ((crosslevelvar.campaign == false || (crosslevelvar.campaign == true && crosslevelvar.campaignlevel.objective != MainMenuCampaignControlScript.eMissionObjective.Survive)) && unitcontrol.checkiffactiondead(team) == true) { output = false; } if (output) { money -= pointstodeploy; } } return(output); }