public void Execute(Actions action) { switch (action) { case Actions.Wait: default: return; case Actions.Heal: HealMyPlanets(); return; case Actions.Upgrade: LevelUpMyPlanets(); return; case Actions.AttackNeutral: //print("Hay neutrales"); EventEntity objective = GetNearestPlanet(map, myPlayer, true); Attack(objective, Random.value > 0.25f); return; case Actions.AttackEnemy: objective = Effector.GetNearestPlanet(map, myPlayer); Attack(objective, Random.value > 0.25f); return; } }
public Actions Decide() { bool attack = false; bool attackNeutal = false; if (PlanetsNeedHealing()) { return(Actions.Heal); } if (PlanetsNotAtMaximmumLevel() && Random.value > 0.5f) { return(Actions.Upgrade); } if (Random.value > 0.4f) { if (Random.value > 0.5f) { attack = true; } else { attackNeutal = true; } } EventEntity objective; if (ThereAreNeutralPlanets() && !attack) { objective = Effector.GetNearestPlanet(map, myPlayer, true); if (myPlayer.GetCurrentUnitsNumber() > Effector.CountNecessaryUnitsToConquer(objective, myPlayer) * 1.5f || attackNeutal) { return(Actions.AttackNeutral); } } else { objective = Effector.GetNearestPlanet(map, myPlayer); if (myPlayer.GetCurrentUnitsNumber() > Effector.CountNecessaryUnitsToConquer(objective, myPlayer) * 1.5f || attack) { return(Actions.AttackEnemy); } } return(Actions.Wait); }