示例#1
0
 public override void AI()
 {
     if (timer > interval)
     {
         timer = 0;
     }
     foreach (Projectile a in bombs)
     {
         if (a != null && a.active)
         {
             if (a.Hitbox.Intersects(target().Hitbox))
             {
                 a.timeLeft = 1;
             }
         }
     }
     if (pattern != Pattern.Attack)
     {
         if (npc.alpha > 0)
         {
             npc.alpha--;
         }
     }
     npc.direction = direction ? 1 : -1;
     if (target().Distance(npc.position) < range && canSee())
     {
         if (npc.velocity.Y == 0f && (timer % 150 == 0 || ArchaeaNPC.OnHurt(npc.life, oldLife, out oldLife)))
         {
             velX            = npc.velocity.X;
             npc.velocity.Y -= randY;
         }
     }
     if (!OnGround())
     {
         npc.velocity.X = velX;
     }
     if (!canSee() || !target().active || target().dead)
     {
         if (FacingWall())
         {
             isBlind = !isBlind;
         }
         if (OnGround())
         {
             npc.velocity.X -= isBlind ? -0.2f : 0.2f;
         }
         ArchaeaNPC.VelClampX(npc, -2f, 2f);
     }
 }