コード例 #1
0
ファイル: TheProbe.cs プロジェクト: Eldrazi/Gyrolite
 public override void AI()
 {
     ProjectileAI.ExtraAction action = delegate()
     {
         try
         {
             projectile.frameCounter++;
             if (projectile.frameCounter >= 15)
             {
                 projectile.frameCounter = 0;
                 float   rotation = (float)(Main.rand.Next(0, 361) * (Math.PI / 180));
                 Vector2 velocity = new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation));
                 int     proj     = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, velocity.X, velocity.Y, ProjectileID.PinkLaser, 68, 0f);
                 Main.projectile[proj].friendly  = true;
                 Main.projectile[proj].hostile   = false;
                 Main.projectile[proj].velocity *= 6f;
             }
         }
         catch (Exception e)
         {
             Main.NewText(e.Message);
         }
     };
     ProjectileAI.YoyoAI(projectile.whoAmI, 14, 256f, 13f, 0.39f, action);
 }
コード例 #2
0
ファイル: Treasure.cs プロジェクト: Eldrazi/Gyrolite
 public override void AI()
 {
     ProjectileAI.ExtraAction action = delegate()
     {
         if (projectile.localAI[0] % 30 == 0)
         {
             Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, Main.rand.Next(-4, 5), Main.rand.Next(-4, 5), 24, 10, 0, projectile.owner);
         }
     };
     ProjectileAI.YoyoAI(projectile.whoAmI, 10, 320f, 15f, 0.4f, action);
 }
コード例 #3
0
ファイル: Entruder.cs プロジェクト: Eldrazi/Gyrolite
 public override void AI()
 {
     ProjectileAI.ExtraAction action = delegate()
     {
         try
         {
             projectile.frameCounter++;
             if (projectile.frameCounter >= 30)
             {
                 projectile.frameCounter = 0;
                 float distance = 2000f;
                 int   index    = -1;
                 for (int i = 0; i < 200; i++)
                 {
                     float dist = Vector2.Distance(projectile.Center, Main.npc[i].Center);
                     if (dist < distance && dist < 640f && !Main.npc[i].friendly && Main.npc[i].lifeMax > 5 && !Main.npc[i].townNPC)
                     {
                         index    = i;
                         distance = dist;
                     }
                 }
                 if (index != -1)
                 {
                     bool check = Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height);
                     if (check)
                     {
                         Vector2 vector = Main.npc[index].Center - projectile.Center;
                         float   speed  = 9f;
                         float   mag    = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
                         if (mag > speed)
                         {
                             mag = speed / mag;
                         }
                         vector *= mag;
                         Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vector.X, vector.Y, 206, 16, 0.5f, projectile.owner);
                     }
                 }
             }
         }
         catch (Exception e)
         {
             Main.NewText(e.Message);
         }
     };
     ProjectileAI.YoyoAI(projectile.whoAmI, 14, 256f, 13f, 0.39f, action);
 }