Exemplo n.º 1
0
        /// <summary>
        /// Method for firing projectiles from a star, for Boss mode.
        /// Generates 2 lines of projectiles rotating around each star, with direction changing at various intervals.
        /// TODO: need to modify fire counter and fire delay to be star properties so that boss mode works with multiple stars.
        /// </summary>
        /// <param name="currentStar">Star firing this projectile.</param>
        public void bossFireMode3(Star currentStar)
        {
            if (starFireCounter % starFireDelay == 0)
            {
                if ((starFireDir.ToAngle() >= 0 && starFireDir.ToAngle() < 2.0))
                {
                    clockwise = !clockwise;
                }

                if (clockwise)
                {
                    starFireDir.Rotate(2.0);
                }
                else
                {
                    starFireDir.Rotate(-2.0);
                }

                SpawnProjectile(currentStar, this.starFireDir);

                starFireDir.Rotate(180.0);
                SpawnProjectile(currentStar, this.starFireDir);

                starFireDir.Rotate(180.0); // reset orientation for next iteration.
            }
            starFireCounter++;
        }
        /// <summary>
        /// This method is invoked when the DrawingPanel needs to be re-drawn
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (theWorld != null)
            {
                lock (this.theWorld)
                {
                    // Draw the ships
                    foreach (Ship ship in this.theWorld.GetShips().Values)
                    {
                        Vector2D shipLoc = ship.GetLocation();
                        Vector2D shipDir = ship.GetDirection();

                        if (shipDir == null)
                        {
                            DrawObjectWithTransform(e, ship, this.Size.Width, shipLoc.GetX(), shipLoc.GetY(), 0, new ObjectDrawer(ShipDrawer));
                            DrawObjectWithTransform(e, ship, this.Size.Width, shipLoc.GetX(), shipLoc.GetY(), 0, ShipInfoDrawer);
                        }
                        else
                        {
                            if (ship.GetHealth() == 0)
                            {
                                DrawObjectWithTransform(e, ship, this.Size.Width, shipLoc.GetX(), shipLoc.GetY(), 0, ShipDrawer);
                            }
                            else
                            {
                                DrawObjectWithTransform(e, ship, this.Size.Width, shipLoc.GetX(), shipLoc.GetY(), shipDir.ToAngle(), ShipDrawer);
                            }


                            DrawObjectWithTransform(e, ship, this.Size.Width, shipLoc.GetX(), shipLoc.GetY(), 0, ShipInfoDrawer);
                        }
                    }

                    // Draw the projectiles
                    foreach (Projectile projectile in this.theWorld.GetProjectile().Values)
                    {
                        Vector2D proLoc = projectile.GetLocation();
                        Vector2D proDir = projectile.GetDirection();

                        if (proDir == null)
                        {
                            DrawObjectWithTransform(e, projectile, this.Size.Width, proLoc.GetX(), proLoc.GetY(), 0, new ObjectDrawer(this.ProjectileDrawer));
                        }
                        else
                        {
                            DrawObjectWithTransform(e, projectile, this.Size.Width, proLoc.GetX(), proLoc.GetY(), proDir.ToAngle(), new ObjectDrawer(this.ProjectileDrawer));
                        }
                    }

                    // Draw the projectiles
                    foreach (Star star in this.theWorld.GetStar().Values)
                    {
                        Vector2D proLoc = star.GetLoc();


                        DrawObjectWithTransform(e, star, this.Size.Width, proLoc.GetX(), proLoc.GetY(), 0, new ObjectDrawer(this.StarDrawer));
                    }
                }
            }
            // Do anything that Panel (from which we inherit) needs to do
            base.OnPaint(e);
        }