コード例 #1
0
ファイル: AI.cs プロジェクト: tht5cs/Space-Truck-Defender
 /* Board constructor. This Constructor
  * is used once per actor. One actor only ever
  * has one AI, though they may go through multiple states
  * and triggers.
  */
 public AI(AI ai, Actor _body)
 {
     //IMP
     this.CurrentState = ai.CurrentState.Copy();
     this.Attach(_body);
     this.ActiveTriggers = new List<AITrigger>();
     this.ResetActiveTriggers();
 }
コード例 #2
0
 public void InitializeAIHoming()
 {
     AIState move = new AIState(true, false);
     AIState home = new AIState(true, true);
     CollisionCounter c = new CollisionCounter(40, 3, Device);
     var t1 = new TriggerCollision(home, c, 0, false);
     move.AddTrigger(t1);
     AIHoming = new AI(move);
 }
コード例 #3
0
 /* AI For enemy actors. When a friendly (player)
  * actor comes close, the actor will stop moving.
  */
 public void InitializeAICloseStop()
 {
     AIState move = new AIState(true, false);
     AIState stop = new AIState(false, false);
     CollisionCounter c = new CollisionCounter(30, 3, Device);//radius of 15, collides with Friendly Actors
     var t1 = new TriggerCollision(stop, c, 0, false); // trips when more than 1 friendly actor in radius
     var t2 = new TriggerCollision(move, c, 1, true); // trips when there are no friendly actors in radius
     move.AddTrigger(t1);
     stop.AddTrigger(t2);
     AICloseStop = new AI(move);
 }
コード例 #4
0
 //adds trigger  to the board, and attaches it to an actor
 private void AddTriggers(AI ai)
 {
     foreach (AITrigger ait in ai.GetActiveTriggers())
     {
         ait.Attach(ai.GetBody());
         if (ait is TriggerCollision)
         {
             var tc = (TriggerCollision)ait;
             var cCounter = tc.GetCollisionCounter();
             InsertCollidable(cCounter);
         }
         PieceList.Add(ait);
     }
 }
コード例 #5
0
 /* Whenever an AI gets added, we need to make sure that
  * their triggers and assorted addons are added as well.
  * this method managed that.
  */
 private void AddAI(AI ai)
 {
     AIList.Add(ai);
     AddTriggers(ai);
 }
コード例 #6
0
 public void NewEnemy()
 {
     Random r = new Random();
     int xpos = r.Next(50, 400);
     int ypos = r.Next(50, 400);
     Vector2 pos = new Vector2(xpos, ypos);
     Actor a = new Actor(Data.baseEnemyActor, pos);
     AI ai = new AI(Data.AIHoming, a);
     InsertCollidable(a);
     AddAI(ai);
 }
コード例 #7
0
 /* AI that sets the actor to move and shoot
  */
 public void InitializeAIStartStop()
 {
     //first, the two basic states: move or stop
     AIState move = new AIState(true, false);
     AIState stop = new AIState(false, false);
     //now, we connect them with the appropriate triggers
     var t1 = new TriggerTime(stop, 0.25f);
     var t2 = new TriggerTime(move, 0.25f);
     move.AddTrigger(t1);
     stop.AddTrigger(t2);
     AIStartStop = new AI(move);
 }