Example #1
0
 public override void SpecialUpdate()
 {
     if (partner != null && partner.team != team)
     {
         partner = null;
     }
 }
Example #2
0
 public override void ActionUpdate()
 {
     if (spinTime > 0)
     {
         Velocity = Vector2.Zero;
         spinTime--;
         if (partner == null)
         {
             foreach (BeamShip ship in Miasma.BeamShips)
             {
                 if ((!ship.IsActing() || Miasma.BeamShips.Count < 3) && ship.partner == null && ship != this)
                 {
                     partner      = ship;
                     ship.partner = this;
                     ship.Act(30);
                     break;
                 }
             }
         }
         rotation += (float)Math.PI / 15;
     }
     else
     {
         if (!Miasma.BeamShips.Contains(partner))
         {
             partner = null;
         }
         if (partner == null)
         {
             acting = -1;
         }
         else if (readyToBeam && partner.readyToBeam)
         {
             Velocity = Vector2.UnitY * 4;
             if (canStrike && partner != null)
             {
                 Rectangle BeamBox = new Rectangle((int)Position.X, (int)Position.Y - 1, (int)partner.Position.X - (int)Position.X, 3);
                 new Particle(Position + Vector2.UnitX * Miasma.random.Next(BeamBox.Width), Vector2.Zero, 4 + Miasma.random.Next(2), 30);
                 if (BeamBox.Intersects(Miasma.player.Hitbox))
                 {
                     Miasma.player.Strike(10);
                     canStrike = false;
                 }
                 Sounds.beam.PlayContinuous();
             }
             if (Position.Y > 900)
             {
                 Position.Y = -100;
                 acting     = -1;
                 partner    = null;
             }
         }
         else
         {
             laserWarmup();
             if (Miasma.BeamShips.IndexOf(this) > Miasma.BeamShips.IndexOf(partner))
             {
                 canStrike = false;
                 if (startAt == new Vector2(-100, -100))
                 {
                     startAt         = new Vector2(340 + Miasma.random.Next(120), 30);
                     partner.startAt = startAt - Vector2.UnitX * 200 + Vector2.UnitY;
                 }
             }
             if (startAt != new Vector2(-100, -100))
             {
                 if (Position != startAt)
                 {
                     if ((Position - startAt).Length() < speed)
                     {
                         Position = startAt;
                         Velocity = Vector2.Zero;
                     }
                     else
                     {
                         Velocity = Functions.PolarVector(3, Functions.ToRotation(startAt - Position));
                         rotation = Functions.ToRotation(Velocity) - (float)Math.PI / 2;
                     }
                 }
                 else
                 {
                     Velocity = Vector2.Zero;
                     if (Align())
                     {
                         readyToBeam = true;
                     }
                 }
             }
         }
     }
 }
Example #3
0
        public override void InfectedUpdate()
        {
            acting = -1;

            if (!Miasma.InfectedBeamShips.Contains(this))
            {
                Miasma.InfectedBeamShips.Add(this);
            }
            if (infectedSpinTime > 0)
            {
                Velocity = Vector2.Zero;
                infectedSpinTime--;
                if (partner == null)
                {
                    foreach (BeamShip ship in Miasma.InfectedBeamShips)
                    {
                        if ((!ship.IsActing() || Miasma.InfectedBeamShips.Count < 3) && ship.partner == null && ship != this)
                        {
                            partner      = ship;
                            ship.partner = this;
                            break;
                        }
                    }
                }
                rotation += (float)Math.PI / 15;
            }
            else
            {
                if (!Miasma.InfectedBeamShips.Contains(partner))
                {
                    partner = null;
                }
                if (partner == null)
                {
                    health = 0;
                }
                else if (infectedReadyToBeam && partner.infectedReadyToBeam)
                {
                    /////////////////////////
                    Velocity = Vector2.UnitX * 4;
                    if (partner != null && Miasma.InfectedBeamShips.IndexOf(this) > Miasma.InfectedBeamShips.IndexOf(partner))
                    {
                        Rectangle BeamBox = new Rectangle((int)Position.X - 1, (int)Position.Y, 3, (int)partner.Position.Y - (int)Position.Y);
                        new Particle(Position + Vector2.UnitY * Miasma.random.Next(BeamBox.Height), Vector2.Zero, 4 + Miasma.random.Next(2), 30);
                        Sounds.beam.PlayContinuous();
                        foreach (Ship ship in Miasma.enemyFleet)
                        {
                            if (!strikedThese.Contains(ship) && BeamBox.Intersects(ship.Hitbox))
                            {
                                strikedThese.Add(ship);
                                ship.Strike(20);
                            }
                        }
                    }
                    if (Position.X > Miasma.rightSide + 100)
                    {
                        health  = 0;
                        partner = null;
                    }
                }
                else
                {
                    laserWarmup();
                    if (Miasma.InfectedBeamShips.IndexOf(this) > Miasma.InfectedBeamShips.IndexOf(partner))
                    {
                        if (infectedStartAt == new Vector2(-100, -100))
                        {
                            infectedStartAt         = new Vector2(Miasma.leftSide + 30, 30);
                            partner.infectedStartAt = new Vector2(infectedStartAt.X, Miasma.lowerBoundry);
                        }
                    }
                    if (infectedStartAt != new Vector2(-100, -100))
                    {
                        if (Position != infectedStartAt)
                        {
                            if ((Position - infectedStartAt).Length() < speed)
                            {
                                Position = infectedStartAt;
                                Velocity = Vector2.Zero;
                            }
                            else
                            {
                                Velocity = Functions.PolarVector(3, Functions.ToRotation(infectedStartAt - Position));
                                rotation = Functions.ToRotation(Velocity) - (float)Math.PI / 2;
                            }
                        }
                        else
                        {
                            Velocity = Vector2.Zero;
                            if (Align())
                            {
                                infectedReadyToBeam = true;
                            }
                        }
                    }
                }
            }
        }