Exemple #1
0
        public override bool ActiveMovement()
        {
            if (timer % 300 == 0)
            {
                ai++;
            }
            switch (ai)
            {
            case 0:
                if (canSee() && OnGround())
                {
                    npc.velocity.X -= direction ? 0.25f * -1 : 0.25f;
                }
                if (timer > 90)
                {
                    ArchaeaNPC.VelClampX(npc, -3f, 3f);
                }
                break;

            case 1:
                ai = 0;
                return(true);
            }
            return(false);
        }
Exemple #2
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);
     }
 }
Exemple #3
0
 public override void AI()
 {
     if (!init)
     {
         pathing = 1;
         int i = (int)npc.position.X / 16;
         int j = (int)npc.position.Y / 16;
         if (ArchaeaWorld.Inbounds(i, j) && Main.tile[i, j].wall != ArchaeaWorld.skyBrickWall)
         {
             newPosition = ArchaeaNPC.FindAny(npc, target(), true, 800);
             if (newPosition != Vector2.Zero)
             {
                 npc.netUpdate = true;
                 if (Main.netMode == 0)
                 {
                     npc.position = newPosition;
                 }
             }
             else
             {
                 return;
             }
         }
         init = true;
     }
     if (!ArchaeaWorld.Inbounds((int)npc.position.X / 16, (int)npc.position.Y / 16))
     {
         return;
     }
     if (npc.alpha > 0)
     {
         npc.alpha -= 5;
     }
     if (timer++ > 600)
     {
         timer         = 0;
         redirectTimer = 0;
     }
     if (timer % 300 == 0 && timer != 0)
     {
         Attack();
     }
     if (timer % 180 == 0)
     {
         if (FacingWall())
         {
             npc.velocity.Y -= 5f;
         }
         else
         {
             npc.velocity.Y -= 3f;
         }
         SyncNPC();
     }
     if (canSee())
     {
         if (OnGround())
         {
             npc.velocity.X -= direction ? 0.25f * -1 : 0.25f;
         }
         else
         {
             npc.velocity.X -= direction ? 8f * -1 : 8f;
         }
     }
     else
     {
         npc.velocity.X += pathing * 1f;
         if (FacingWall() && redirectTimer++ % 180 == 0)
         {
             pathing *= -1;
         }
     }
     if (BottomLeftTile() && !TopLeftTile() && npc.velocity.X < 0f)
     {
         npc.position.X -= 2f;
         npc.position.Y -= 8f;
     }
     if (BottomRightTile() && !TopRightTile() && npc.velocity.X > 0f)
     {
         npc.position.X += 2f;
         npc.position.Y -= 8f;
     }
     ArchaeaNPC.VelClampX(npc, -3f, 3f);
     if (npc.velocity.X < 0f && npc.oldVelocity.X >= 0f || npc.velocity.X > 0f && npc.oldVelocity.X <= 0f || npc.velocity.Y < 0f && npc.oldVelocity.Y >= 0f || npc.velocity.Y > 0f && npc.oldVelocity.Y <= 0f)
     {
         SyncNPC();
     }
 }