public override void Perform() { WSU = target.GetComponent <WorldStateUpdater>(); SceneBuilder scene = WSU.scene; Debug.Log("SceneBuilder" + scene); foreach (GameObject ally in WSU.allyTroops) { if (ally.GetComponent <TroopScript>() != null) { bool targetSet = false; Unit unitScript = ally.GetComponent <TroopScript>(); Debug.Log("GOAP Tree Closest Enemies : " + unitScript.getClosestEnemyTroop().Count); foreach (GameObject enemyGO in unitScript.getClosestEnemyTroop()) { Unit enemyUnitScript = enemyGO.GetComponent <Unit>(); Debug.Log("Enemy Script: " + enemyUnitScript); if ((enemyUnitScript.CurrentTroopClass == scene.getMatchups()[unitScript.CurrentTroopClass]) || (enemyUnitScript.CurrentTroopClass == TroopClass.Gatherer)) { //unitScript.updateClosestEnemyTroopsList(); Debug.Log("Unit about to move!"); unitScript.moveToGoal(enemyGO); targetSet = true; break; } } if (targetSet == false) { unitScript.moveToGoal(unitScript.getClosestEnemyTroop().First()); targetSet = true; } } } }
void Start() { WSU = gameObject.GetComponent <WorldStateUpdater>(); Debug.Log("World State Updater" + WSU); teamNumber = WSU.thisTeamNumber; scene = GameObject.FindWithTag("GameManager").GetComponent <SceneBuilder>(); spawner = scene.base2.GetComponent <Spawner>(); }
public override void Perform() { taskExecutor = target.GetComponent <TaskExecutor>(); WSU = target.GetComponent <WorldStateUpdater>(); int enemyTroopCount = WSU.enemyTroops.Count * 2; int enemyCloseToBaseCost = WSU.enemiesCloseToBase.Count * 5; cost = taskExecutor.scene.troopCosts[troopClass] - enemyTroopCount - enemyCloseToBaseCost; taskExecutor.tryPurchaseUnit(troopClass); }
void Start() { scene = GameObject.FindWithTag("GameManger").GetComponent <SceneBuilder>(); GameObject player2 = GameObject.FindWithTag("Player2"); player2ScriptAI = player2.GetComponent <PlayerGOAPAI>(); spawner = scene.base2.GetComponent <Spawner>(); WSU = player2.GetComponent <WorldStateUpdater>(); costToApply = scene.troopCosts[troopClass] - WSU.classCounts[(int)troopClass]; }
public override void Perform() { Debug.Log("CommandTroopAttackBase called"); WSU = target.GetComponent <WorldStateUpdater>(); foreach (GameObject ally in WSU.allyTroops) { Unit unitScript = ally.GetComponent <Unit>(); Debug.Log("CTAB - unitScript : " + unitScript); unitScript.moveToGoal(unitScript.EnemySpawner.gameObject); } }
public override void Perform() { Debug.Log("CommandTroopDefendBase called"); WSU = target.GetComponent <WorldStateUpdater>(); foreach (GameObject ally in WSU.allyTroops) { Unit unitScript = ally.GetComponent <Unit>(); Debug.Log("CTAB - unitScript : " + unitScript); unitScript.moveToGoal(WSU.enemiesCloseToBase.First()); } }
public override void Awake() { base.Awake(); TeamNumber teamNumber = TeamNumber.t2; WSU = GetComponent <WorldStateUpdater>(); // create goals goals.Add(GoapGoal.Goals.DEFEND_HOME_BASE, new DefendBaseGoal(GoapGoal.Goals.DEFEND_HOME_BASE, 1f)); goals.Add(GoapGoal.Goals.KILL_ENEMY_BASE, new KillEnemyBaseGoal(GoapGoal.Goals.KILL_ENEMY_BASE, 1f)); goals.Add(GoapGoal.Goals.SPAWN_TROOPS, new SpawnTroops(GoapGoal.Goals.SPAWN_TROOPS, 0.5f)); // create Actions dataSet.SetData(GoapAction.Effects.HAS_SUFFICIENT_GOLD_WARRIOR, false); dataSet.SetData(GoapAction.Effects.HAS_SUFFICIENT_GOLD_ARCHER, false); dataSet.SetData(GoapAction.Effects.HAS_SUFFICIENT_GOLD_MAGE, false); dataSet.SetData(GoapAction.Effects.HAS_SUFFICIENT_GOLD_GATHERER, false); dataSet.SetData(GoapAction.Effects.ALLIES_ALIVE, false); dataSet.SetData(GoapAction.Effects.ENEMIES_ALIVE, false); dataSet.SetData(GoapAction.Effects.RESOURCES_TO_GATHER, false); dataSet.SetData(GoapAction.Effects.ENEMIES_NEAR_BASE, false); possibleActions.Add(new SpawnTroopAction(this)); //possibleActions.Add(new WaitForGoldAction(this)); possibleActions.Add(new SpawnWarrior(this)); possibleActions.Add(new SpawnArcher(this)); possibleActions.Add(new SpawnMage(this)); possibleActions.Add(new SpawnGatherer(this)); possibleActions.Add(new CommandTroopAttackEnemyTroops(this)); possibleActions.Add(new CommandTroopAttackEnemyBase(this)); possibleActions.Add(new CommandTroopDefendHomeBase(this)); }