protected void Awake() { // Build the Finite State Machine characterController = this.GetComponent <CharacterController>(); //target = GameObject.FindGameObjectWithTag(Tags.FriendlyAI); ttm = this.gameObject.GetComponent <TargetTrackingManager>(); senses = this.gameObject.GetComponent <Senses>(); animator = this.GetComponent <Animator>(); aiGunLogic = AIGun.GetComponent <AIGunLogic>(); health = this.GetComponent <Health>(); imageBehaviour = this.GetComponent <ImageBehaviour>(); alertImage = imageBehaviour.alertImage.gameObject; chaseImage = imageBehaviour.chaseImage.gameObject; tacticalStateMachine = new FSM <TacticalStates>(displayFSMTransitions); tacticalStateMachine.AddState(new Goto <TacticalStates>(TacticalStates.Goto, this, 0f)); tacticalStateMachine.AddState(new Animate <TacticalStates>(TacticalStates.Animate, this, 0f)); tacticalStateMachine.AddState(new UseSmartObject <TacticalStates>(TacticalStates.UseSmartObject, this, 0f)); tacticalStateMachine.AddTransition(TacticalStates.Goto, TacticalStates.Animate); tacticalStateMachine.AddTransition(TacticalStates.Goto, TacticalStates.UseSmartObject); tacticalStateMachine.AddTransition(TacticalStates.Goto, TacticalStates.Goto); tacticalStateMachine.AddTransition(TacticalStates.Animate, TacticalStates.Goto); tacticalStateMachine.AddTransition(TacticalStates.Animate, TacticalStates.UseSmartObject); tacticalStateMachine.AddTransition(TacticalStates.Animate, TacticalStates.Animate); tacticalStateMachine.AddTransition(TacticalStates.UseSmartObject, TacticalStates.Goto); tacticalStateMachine.AddTransition(TacticalStates.UseSmartObject, TacticalStates.Animate); tacticalStateMachine.AddTransition(TacticalStates.UseSmartObject, TacticalStates.UseSmartObject); actions = new List <Action>(); Action idle = new Idle("idle", 1, this, TacticalStates.Goto); idle.SetEffect(Atom.OnGuard, true); idle.destination = patrolPoints[destinationPoint]; actions.Add(idle); Action GetInRangeOfPlayer = new getInRangeOfPlayer("Get in range of the player", 1, this, TacticalStates.Goto); GetInRangeOfPlayer.SetPreCondition(Atom.KnowledgeOfPlayer, true); GetInRangeOfPlayer.SetEffect(Atom.CanSeePlayer, true); GetInRangeOfPlayer.SetEffect(Atom.InRange, true); GetInRangeOfPlayer.destination = GameObject.FindGameObjectWithTag(Tags.Player).transform; actions.Add(GetInRangeOfPlayer); Action attackWithGun = new AttackWithGun("Attack with gun", 1, this, TacticalStates.Goto); attackWithGun.SetPreCondition(Atom.InRange, true); attackWithGun.SetPreCondition(Atom.CanSeePlayer, true); attackWithGun.SetEffect(Atom.PlayerDead, true); attackWithGun.destination = searchPos.transform; actions.Add(attackWithGun); // set the current world state startWS = new WorldState(); // what the ai knows about the enviornment startWS.SetValue(Atom.KnowledgeOfPlayer, false); startWS.SetValue(Atom.CanSeePlayer, false); goals = new List <Goal>(); Goal idleGoal = new Goal(1); idleGoal.condition.SetValue(Atom.OnGuard, true); goals.Add(idleGoal); Goal combatGoal = new Goal(10); //combatGoal.condition.SetValue(Atom.HaveGun, true); //combatGoal.condition.SetValue(Atom.HaveAmmo, true); combatGoal.condition.SetValue(Atom.PlayerDead, true); goals.Add(combatGoal); // Goal getInRangeGoal = new Goal(20); // getInRangeGoal.condition.SetValue(Atom.InRange, true); // goals.Add(getInRangeGoal); /*Goal findTargetGoal = new Goal(5); * //combatGoal.condition.SetValue(Atom.HaveGun, true); * //combatGoal.condition.SetValue(Atom.HaveAmmo, true); * findTargetGoal.condition.SetValue(Atom.CanSeePlayer, true); * goals.Add(findTargetGoal);*/ }