예제 #1
0
        public override bool Update(TerraSpirit spirit, Rectangle bounds)
        {
            Vector2 offset = endPos - position;

            if (offset.Length() < speed)
            {
                position = endPos;
                if (timer % 30 == 0)
                {
                    var bullet = new BulletRingExpand(position, 6f);
                    if (timer == 30)
                    {
                        bullet.Rotation(MathHelper.Pi / 16f);
                    }
                    spirit.bullets.Add(bullet);
                }
                if (timer >= 60)
                {
                    return(false);
                }
                timer++;
                return(true);
            }
            offset.Normalize();
            position += speed * offset;
            return(true);
        }
예제 #2
0
        public override bool Update(TerraSpirit spirit, Rectangle bounds)
        {
            Vector2 offset = endPos - position;

            if (offset.Length() < speed)
            {
                position = endPos;
                if (timer % 30 == 0)
                {
                    Vector2 target   = spirit.GetTarget().Center;
                    Vector2 shootVel = target - position;
                    if (shootVel == Vector2.Zero)
                    {
                        shootVel = new Vector2(0f, -1f);
                    }
                    shootVel.Normalize();
                    shootVel *= 12f;
                    var bullet = new BulletSingleMove(position, shootVel);
                    spirit.bullets.Add(bullet);
                }
                if (timer >= 120)
                {
                    return(false);
                }
                timer++;
                return(true);
            }
            offset.Normalize();
            position += speed * offset;
            return(true);
        }
        public override bool Update(TerraSpirit spirit, Rectangle bounds)
        {
            if (timer >= 0 && timer % 120 == 0)
            {
                Vector2 position  = spirit.GetTarget().Center - origin;
                int     i         = (int)position.X / interval;
                int     j         = (int)position.Y / interval;
                Vector2 bulletPos = origin + interval * new Vector2(i + 0.5f, j + 0.5f);
                if (timer % 360 == 0)
                {
                    spirit.bullets.Add(new BulletBeamBig(bulletPos, interval, MathHelper.PiOver2, 120));
                }
                else if (timer % 360 == 120)
                {
                    spirit.bullets.Add(new BulletBeamBig(bulletPos, interval, 0f, 120));
                }
                else if (timer % 360 == 240)
                {
                    spirit.bullets.Add(new BulletBeamBig(bulletPos, interval, MathHelper.PiOver2, 120));
                    spirit.bullets.Add(new BulletBeamBig(bulletPos, interval, 0f, 120));
                }
            }

            rotation += rotSpeed;
            timer++;
            return(timer < maxTime);
        }
 public override void Behavior()
 {
     Timer++;
     if (Timer >= 90)
     {
         Timer = 0;
         TerraSpirit spirit = (TerraSpirit)Spirit.modNPC;
         Player      target = spirit.GetTarget();
         spirit.bullets.Add(new BulletExplode(npc.Center, target.Center));
     }
 }
예제 #5
0
 public override void Behavior()
 {
     Timer++;
     if (Timer >= 90)
     {
         Timer = 0;
         TerraSpirit spirit = (TerraSpirit)Spirit.modNPC;
         Vector2     center = npc.Center;
         spirit.bullets.Add(new BulletExplode(center, center + new Vector2(-320f, -320f)));
         spirit.bullets.Add(new BulletExplode(center, center + new Vector2(320f, -320f)));
         spirit.bullets.Add(new BulletExplode(center, center + new Vector2(-320f, 320f)));
         spirit.bullets.Add(new BulletExplode(center, center + new Vector2(320f, 320f)));
     }
 }
예제 #6
0
 public override void Behavior()
 {
     Timer++;
     if (Timer % 60 == 0)
     {
         TerraSpirit spirit = (TerraSpirit)Spirit.modNPC;
         Vector2     center = npc.Center;
         spirit.bullets.Add(new BulletPortal2(center, center + new Vector2(-320f, -320f)));
         spirit.bullets.Add(new BulletPortal2(center, center + new Vector2(320f, -320f)));
         spirit.bullets.Add(new BulletPortal2(center, center + new Vector2(-320f, 320f)));
         spirit.bullets.Add(new BulletPortal2(center, center + new Vector2(320f, 320f)));
         Timer = 0;
     }
 }
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     delay--;
     alpha += 0.05f * alphaDir;
     if (alpha >= 0.5f)
     {
         alphaDir = -1f;
     }
     if (alpha <= 0f)
     {
         alphaDir = 1f;
     }
     return(delay > -life);
 }
        public override bool Update(TerraSpirit spirit, Rectangle bounds)
        {
            int numUpdates = timer / 20;

            if (numUpdates > 5)
            {
                numUpdates = 5;
            }
            for (int k = 0; k < numUpdates; k++)
            {
                for (int i = 0; i < bulletPos.Count; i++)
                {
                    foreach (Vector2 blackHole in blackHoles)
                    {
                        Vector2 offset   = blackHole - bulletPos[i];
                        float   distance = offset.Length();
                        if (distance != 0f)
                        {
                            if (distance < 20f)
                            {
                                distance = 20f;
                            }
                            offset.Normalize();
                            bulletVel[i] += gravity * offset / distance / distance;
                        }
                    }
                    if (bulletPos[i].X < -TerraSpirit.arenaWidth / 2 && bulletVel[i].X < 0f)
                    {
                        bulletVel[i] = new Vector2(-bulletVel[i].X, bulletVel[i].Y);
                    }
                    if (bulletPos[i].X > TerraSpirit.arenaWidth / 2 && bulletVel[i].X > 0f)
                    {
                        bulletVel[i] = new Vector2(-bulletVel[i].X, bulletVel[i].Y);
                    }
                    if (bulletPos[i].Y < -TerraSpirit.arenaHeight / 2 && bulletVel[i].Y < 0f)
                    {
                        bulletVel[i] = new Vector2(bulletVel[i].X, -bulletVel[i].Y);
                    }
                    if (bulletPos[i].Y > TerraSpirit.arenaHeight / 2 && bulletVel[i].Y > 0f)
                    {
                        bulletVel[i] = new Vector2(bulletVel[i].X, -bulletVel[i].Y);
                    }
                    bulletPos[i] += bulletVel[i];
                }
            }
            timer++;
            return(timer < 720);
        }
예제 #9
0
        public override bool Update(TerraSpirit spirit, Rectangle bounds)
        {
            Vector2 target = spirit.GetTarget().Center;

            position += (target - position) * speed;
            timer++;
            if (timer % interval == 0)
            {
                Bullet newBullet = action(position, spirit);
                if (newBullet != null)
                {
                    spirit.bullets.Add(newBullet);
                }
            }
            return(timer < life);
        }
예제 #10
0
        public override bool PreNPCLoot()
        {
            NPC spirit = Spirit;

            if (spirit.active && spirit.modNPC is TerraSpirit)
            {
                TerraSpirit modSpirit = (TerraSpirit)spirit.modNPC;
                modSpirit.Stage   += 2;
                modSpirit.Progress = 0;
                if (Main.netMode == 2)
                {
                    NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, spirit.whoAmI);
                }
            }
            return(false);
        }
예제 #11
0
 public override void Behavior()
 {
     Timer++;
     if (Timer % 30 == 0)
     {
         TerraSpirit spirit = (TerraSpirit)Spirit.modNPC;
         var         bullet = new BulletRingExpand(npc.Center, 8f);
         if (Timer == 30)
         {
             bullet.Rotation(MathHelper.Pi / 16f);
         }
         spirit.bullets.Add(bullet);
     }
     if (Timer >= 60)
     {
         Timer = 0;
     }
 }
예제 #12
0
        public override bool Update(TerraSpirit spirit, Rectangle bounds)
        {
            for (int k = oldPos.Length - 1; k > 0; k--)
            {
                oldPos[k] = oldPos[k - 1];
            }
            oldPos[0] = position;
            Vector2 offset = endPos - position;

            if (offset.Length() < speed)
            {
                spirit.bullets.Add(new BulletRingExpand(endPos, 6f));
                return(false);
            }
            offset.Normalize();
            position += speed * offset;
            return(true);
        }
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     if (position.X - size / 2 <= bounds.Left && velocity.X < 0f)
     {
         velocity.X *= -1f;
     }
     if (position.X + size / 2 >= bounds.Right && velocity.X > 0f)
     {
         velocity.X *= -1f;
     }
     if (position.Y - size / 2 <= bounds.Top && velocity.Y < 0f)
     {
         velocity.Y *= -1f;
     }
     if (position.Y + size / 2 >= bounds.Bottom && velocity.Y > 0f)
     {
         velocity.Y *= -1f;
     }
     position += velocity;
     return(true);
 }
예제 #14
0
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     position += velocity;
     if (position.X < bounds.X)
     {
         position.X += bounds.Width;
     }
     else if (position.X > bounds.Right)
     {
         position.X -= bounds.Width;
     }
     if (position.Y < bounds.Y)
     {
         position.Y += bounds.Height;
     }
     else if (position.Y > bounds.Bottom)
     {
         position.Y -= bounds.Height;
     }
     life--;
     return(life >= 0);
 }
예제 #15
0
        public override void Behavior()
        {
            TerraSpirit spirit = (TerraSpirit)Spirit.modNPC;
            Vector2     target = spirit.GetTarget().Center;

            Timer++;
            if (Timer % 8 == 4)
            {
                Vector2 offset = target - npc.Center;
                Vector2 normal = new Vector2(-offset.Y, offset.X);
                spirit.bullets.Insert(0, new BulletVoidWorld(target + offset));
                spirit.bullets.Insert(0, new BulletVoidWorld(target - offset));
                spirit.bullets.Insert(0, new BulletVoidWorld(target + normal));
                spirit.bullets.Insert(0, new BulletVoidWorld(target - normal));
            }
            else if (Timer % 8 == 0)
            {
                spirit.bullets.Insert(0, new BulletVoidWorld(target));
            }
            if (Timer % 90 == 0)
            {
                spirit.bullets.Add(new BulletExplode(npc.Center, target));
            }
        }
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     radius   -= speed;
     rotation += rotSpeed;
     return(radius >= 0f);
 }
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     timer++;
     return(timer < 80);
 }
예제 #18
0
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     rotation += speed;
     timer--;
     return(timer > 0);
 }
예제 #19
0
 public abstract bool Update(TerraSpirit spirit, Rectangle bounds);
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     rotation += rotSpeed;
     return(base.Update(spirit, bounds));
 }
예제 #21
0
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     delay--;
     return(delay > -30);
 }
예제 #22
0
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     speed    += acceleration;
     position += speed * direction;
     return(position.X + size / 2 >= bounds.X && position.X - size / 2 <= bounds.Right && position.Y + size / 2 >= bounds.Y && position.Y - size / 2 <= bounds.Bottom);
 }
예제 #23
0
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     rotation += rotSpeed;
     position  = origin + offset * rotation.ToRotationVector2();
     return(base.Update(spirit, bounds));
 }
예제 #24
0
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     progress++;
     return(progress <= 600);
 }
예제 #25
0
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            MessageType type = (MessageType)reader.ReadByte();

            if (type == MessageType.PuritySpirit)
            {
                PuritySpirit.PuritySpirit spirit = Main.npc[reader.ReadInt32()].modNPC as PuritySpirit.PuritySpirit;
                if (spirit != null && spirit.npc.active)
                {
                    spirit.HandlePacket(reader);
                }
            }
            else if (type == MessageType.HeroLives)
            {
                Player player = Main.player[reader.ReadInt32()];
                int    lives  = reader.ReadInt32();
                player.GetModPlayer <BluemagicPlayer>(this).heroLives = lives;
                if (lives > 0)
                {
                    NetworkText text;
                    if (lives == 1)
                    {
                        text = NetworkText.FromKey("Mods.Bluemagic.LifeLeft", player.name);
                    }
                    else
                    {
                        text = NetworkText.FromKey("Mods.Bluemagic.LivesLeft", player.name, lives);
                    }
                    NetMessage.BroadcastChatMessage(text, new Color(255, 25, 25));
                }
            }
            else if (type == MessageType.ChaosSpirit)
            {
                NPC npc = Main.npc[reader.ReadInt32()];
                if (npc.active)
                {
                    ChaosSpirit.ChaosSpirit spirit = npc.modNPC as ChaosSpirit.ChaosSpirit;
                    if (spirit != null)
                    {
                        spirit.HandlePacket(reader);
                    }
                    ChaosSpirit2 spirit2 = npc.modNPC as ChaosSpirit2;
                    if (spirit2 != null)
                    {
                        spirit2.HandlePacket(reader);
                    }
                    ChaosSpirit3 spirit3 = npc.modNPC as ChaosSpirit3;
                    if (spirit3 != null)
                    {
                        spirit3.HandlePacket(reader);
                    }
                }
            }
            else if (type == MessageType.PushChaosArm)
            {
                NPC     npc  = Main.npc[reader.ReadInt32()];
                Vector2 push = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                if (npc.active)
                {
                    ChaosSpiritArm arm = npc.modNPC as ChaosSpiritArm;
                    if (arm != null)
                    {
                        arm.offset += push;
                        if (Main.netMode == 2)
                        {
                            ModPacket packet = GetPacket();
                            packet.Write((byte)MessageType.PushChaosArm);
                            packet.Write(push.X);
                            packet.Write(push.Y);
                            packet.Send(-1, whoAmI);
                        }
                    }
                }
            }
            else if (type == MessageType.TerraSpirit)
            {
                NPC npc = Main.npc[reader.ReadInt32()];
                if (npc.active)
                {
                    TerraSpirit.TerraSpirit spirit = npc.modNPC as TerraSpirit.TerraSpirit;
                    if (spirit != null)
                    {
                        spirit.HandlePacket(reader);
                    }
                }
            }
            else if (type == MessageType.TerraLives)
            {
                Player player = Main.player[reader.ReadInt32()];
                int    lives  = reader.ReadInt32();
                player.GetModPlayer <BluemagicPlayer>().terraLives = lives;
                if (lives > 0)
                {
                    NetworkText text;
                    if (lives == 1)
                    {
                        text = NetworkText.FromKey("Mods.Bluemagic.LifeLeft", player.name);
                    }
                    else
                    {
                        text = NetworkText.FromKey("Mods.Bluemagic.LivesLeft", player.name, lives);
                    }
                    NetMessage.BroadcastChatMessage(text, new Color(255, 25, 25));
                }
            }
            else if (type == MessageType.GoldBlob)
            {
                NPC   npc   = Main.npc[reader.ReadByte()];
                float value = reader.ReadByte();
                if (npc.active && npc.type == NPCType("GoldBlob"))
                {
                    npc.localAI[0] = value;
                }
            }
            else if (type == MessageType.ExtraLives)
            {
                BluemagicPlayer player = Main.player[Main.myPlayer].GetModPlayer <BluemagicPlayer>();
                if (player.terraLives > 0)
                {
                    player.terraLives += 3;
                }
            }
            else if (type == MessageType.BulletNegative)
            {
                NPC npc = Main.npc[reader.ReadByte()];
                if (npc.active && npc.type == NPCType("TerraSpirit2") && npc.modNPC is TerraSpirit2)
                {
                    var bullets = ((TerraSpirit2)npc.modNPC).bullets;
                    int count   = reader.ReadByte();
                    for (int k = 0; k < count; k++)
                    {
                        bullets.Add(new BulletNegative(reader.ReadVector2(), reader.ReadVector2()));
                    }
                }
            }
            else if (type == MessageType.CustomStats)
            {
                byte            byte1     = reader.ReadByte();
                byte            byte2     = reader.ReadByte();
                Player          player    = Main.player[byte1];
                BluemagicPlayer modPlayer = player.GetModPlayer <BluemagicPlayer>();
                CustomStats     stats     = byte2 == 0 ? modPlayer.chaosStats : modPlayer.cataclysmStats;
                stats.NetReceive(reader);
                if (Main.netMode == 2)
                {
                    ModPacket packet = GetPacket(512);
                    packet.Write(byte1);
                    packet.Write(byte2);
                    stats.NetSend(packet);
                    packet.Send(-1, whoAmI);
                }
            }
        }
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     radius   += speed;
     rotation += rotSpeed;
     return(radius >= 0f && radius < Math.Sqrt(bounds.Width * bounds.Width + bounds.Height * bounds.Height));
 }
 public override bool Update(TerraSpirit spirit, Rectangle bounds)
 {
     position += velocity;
     return(position.X >= bounds.X && position.X <= bounds.Right && position.Y >= bounds.Y && position.Y <= bounds.Bottom);
 }