/// <summary>
        /// ProcessEvents, overide method.
        /// </summary>
        public override void ProcessEvents()
        {
            //process item collisions
            if (GameObjects.Items != null)
            {
                for (int i = 0; i < GameObjects.Items.Count; ++i)
                {
                    if (GameObjects.Items[i].Colides(this))
                    {
                        switch (GameObjects.Items[i].ItemType.ToString())
                        {
                        case "BigPower":
                            for (int j = 0; j < 5; ++j)
                            {
                                GameScores.IncrementPower();
                            }
                            if (GameScores.Power < 128)
                            {
                                GameScores.Score += GameScores.Points[0];
                            }
                            else
                            {
                                GameScores.Score += GameScores.Points[GameScores.iterator];
                                for (int k = 0; k < 8; ++k)
                                {
                                    if (GameScores.iterator < 30)
                                    {
                                        GameScores.iterator++;
                                    }
                                }
                            }
                            break;

                        case "Bomb":
                            GameScores.Bomb++;
                            break;

                        case "FullPower":
                            for (int l = 0; l < 128; ++l)
                            {
                                GameScores.IncrementPower();
                            }
                            break;

                        case "Life":
                            GameScores.Player++;
                            break;

                        case "Point":
                            GameScores.Bonus++;
                            break;

                        case "Power":
                            GameScores.IncrementPower();
                            if (GameScores.Power < 128)
                            {
                                GameScores.Score += GameScores.Points[0];
                            }
                            else
                            {
                                GameScores.Score += GameScores.Points[GameScores.iterator];
                                if (GameScores.iterator < 30)
                                {
                                    GameScores.iterator++;
                                }
                            }
                            break;

                        case "Star":
                            GameScores.Score += 500 + (10 * (GameScores.Graze / 3));
                            break;
                        }
                        GameObjects.RemoveItem(GameObjects.Items[i]);
                    }
                }
            }

            PowerLevel();

            if (SwinGame.KeyDown(GameKeys.SHOOT))
            {
                MainCannon();
                AuxCannon();
            }

            ProcessMovement();

            foreach (BulletEntity bullet in _bullets)
            {
                bullet.ProcessEvents();
            }

            for (int i = 0; i < _bullets.Count; ++i)
            {
                if (_bullets[i].Y < 0)
                {
                    _bullets.Remove(_bullets[i]);
                }
            }

            DrawEntity();

            if (_auxLevel > 0)
            {
                SwinGame.DrawBitmap(GameResources.GameImage("YingYang" + (Tick % 64) / 8), (float)(X + 30) - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Width / 2), (float)Y - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Height / 2));
                SwinGame.DrawBitmap(GameResources.GameImage("YingYang" + (Tick % 64) / 8), (float)(X - 30) - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Width / 2), (float)Y - (GameResources.GameImage("YingYang" + (Tick % 64) / 8).Height / 2));
            }

            Tick++;
        }
        //constructor
        /// <summary>
        /// PlayerEntity, constructor.
        /// </summary>
        public PlayerEntity(PlayerType playerType) : base(270.0, 430.0, new HitBox[] { new HitBox(270.0 - (GameResources.GameImage("Player").Width / 2.0), 430.0 - (GameResources.GameImage("Player").Height / 2.0), GameResources.GameImage("Player").Width / 2.0, GameResources.GameImage("Player").Height / 2.0) }, 1, "Player")
        {
            HitBox[] grazeBoxes = new HitBox[] { new HitBox(270.0 - (GameResources.GameImage("Player").Width / 2.0), 430.0 - (GameResources.GameImage("Player").Height / 2.0), GameResources.GameImage("Player").Width, GameResources.GameImage("Player").Height) };

            foreach (HitBox grazeBox in grazeBoxes)
            {
                _grazeBoxes.Add(grazeBox);
            }

            _mainLevel = 0;
            _auxLevel  = 0;
        }
Esempio n. 3
0
        public static List <Bounding> InitaliseBounding(Point2D point, BulletColour bulletColour, BulletType bulletType)
        {
            List <Bounding> result = new List <Bounding>();

            result.Add(new Bounding(new Point2D[]
            {
                new Point2D(point.X + (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Width / 2), point.Y - (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Height / 2)),
                new Point2D(point.X - (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Width / 2), point.Y - (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Height / 2)),
                new Point2D(point.X - (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Width / 2), point.Y + (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Height / 2)),
                new Point2D(point.X + (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Width / 2), point.Y + (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Height / 2))
            }));

            return(result);
        }
        /// <summary>
        /// ProcessMovement, overide method, determines player movement.
        /// </summary>
        public override void ProcessMovement()
        {
            //left movement
            if (SwinGame.KeyDown(GameKeys.LEFT) && SwinGame.KeyDown(GameKeys.FOCUS))
            {
                if (X > 40.0 + GameResources.GameImage("Player").Width / 2.0)
                {
                    X -= _delta;

                    foreach (HitBox grazeBox in _grazeBoxes)
                    {
                        grazeBox.X -= _delta;
                    }

                    foreach (HitBox hitBox in HitBoxes)
                    {
                        hitBox.X -= _delta;
                    }

                    Bitmap = "PlayerLeft";
                }
            }
            else if (SwinGame.KeyDown(GameKeys.LEFT))
            {
                if (X > 40.0 + GameResources.GameImage("Player").Width / 2.0)
                {
                    X -= _delta * 2;

                    foreach (HitBox grazeBox in _grazeBoxes)
                    {
                        grazeBox.X -= _delta * 2;
                    }

                    foreach (HitBox hitBox in HitBoxes)
                    {
                        hitBox.X -= _delta * 2;
                    }

                    Bitmap = "PlayerLeft";
                }
            }
            //right movement
            else if (SwinGame.KeyDown(GameKeys.RIGHT) && SwinGame.KeyDown(GameKeys.FOCUS))
            {
                if (X < 500.0 - GameResources.GameImage("Player").Width / 2.0)
                {
                    X += _delta;

                    foreach (HitBox grazeBox in _grazeBoxes)
                    {
                        grazeBox.X += _delta;
                    }

                    foreach (HitBox hitBox in HitBoxes)
                    {
                        hitBox.X += _delta;
                    }

                    Bitmap = "PlayerRight";
                }
            }
            else if (SwinGame.KeyDown(GameKeys.RIGHT))
            {
                if (X < 500.0 - GameResources.GameImage("Player").Width / 2.0)
                {
                    X += _delta * 2;

                    foreach (HitBox grazeBox in _grazeBoxes)
                    {
                        grazeBox.X += _delta * 2;
                    }

                    foreach (HitBox hitBox in HitBoxes)
                    {
                        hitBox.X += _delta * 2;
                    }

                    Bitmap = "PlayerRight";
                }
            }
            else
            {
                Bitmap = "Player";
            }

            //up movement
            if (SwinGame.KeyDown(GameKeys.UP) && SwinGame.KeyDown(GameKeys.FOCUS))
            {
                if (Y > 20.0 + GameResources.GameImage("Player").Height / 2.0)
                {
                    Y -= _delta;

                    foreach (HitBox grazeBox in _grazeBoxes)
                    {
                        grazeBox.Y -= _delta;
                    }

                    foreach (HitBox hitBox in HitBoxes)
                    {
                        hitBox.Y -= _delta;
                    }
                }
            }
            else if (SwinGame.KeyDown(GameKeys.UP))
            {
                if (Y > 20.0 + GameResources.GameImage("Player").Height / 2.0)
                {
                    Y -= _delta * 2;

                    foreach (HitBox grazeBox in _grazeBoxes)
                    {
                        grazeBox.Y -= _delta * 2;
                    }

                    foreach (HitBox hitBox in HitBoxes)
                    {
                        hitBox.Y -= _delta * 2;
                    }
                }
            }

            //down movement
            if (SwinGame.KeyDown(GameKeys.DOWN) && SwinGame.KeyDown(GameKeys.FOCUS))
            {
                if (Y < 580.0 - GameResources.GameImage("Player").Height / 2.0)
                {
                    Y += _delta;

                    foreach (HitBox grazeBox in _grazeBoxes)
                    {
                        grazeBox.Y += _delta;
                    }

                    foreach (HitBox hitBox in HitBoxes)
                    {
                        hitBox.Y += _delta;
                    }
                }
            }
            else if (SwinGame.KeyDown(GameKeys.DOWN))
            {
                if (Y < 580.0 - GameResources.GameImage("Player").Height / 2.0)
                {
                    Y += _delta * 2;

                    foreach (HitBox grazeBox in _grazeBoxes)
                    {
                        grazeBox.Y += _delta * 2;
                    }

                    foreach (HitBox hitBox in HitBoxes)
                    {
                        hitBox.Y += _delta * 2;
                    }
                }
            }
        }
        //constructor
        /// <summary>
        /// BulletEntity, class constructor.
        /// </summary>
        /// <param name="x">X position of the bullet.</param>
        /// <param name="y">Y position of the bullet.</param>
        /// <param name="direction">Movement Direction of the bullet.</param>
        /// <param name="drawDirection">Draw Direction of the bullet.</param>
        /// <param name="colour">Colour of the bullet.</param>
        /// <param name="bulletType">Type of the bullet.</param>
        public BulletEntity(double x, double y, double direction, double drawDirection, Colours colour, BulletType bulletType) : base(x, y, new HitBox[] { new HitBox(x - (GameResources.GameImage(bulletType + colour.ToString()).Width / 2.0), y - (GameResources.GameImage(bulletType + colour.ToString()).Height / 2), GameResources.GameImage(bulletType + colour.ToString()).Width, GameResources.GameImage(bulletType + colour.ToString()).Height) }, 1, bulletType + colour.ToString())
        {
            _drawDirection = drawDirection;
            _bulletColour  = colour;
            _bulletType    = bulletType;

            _movement = new VectorMovement(direction, 1.0);

            switch (bulletType)
            {
            case BulletType.Beam:
                _movement.Delta = 16.0;
                break;

            case BulletType.BigStar:
                _movement.Delta = 4.0;
                break;

            case BulletType.Crystal:
                _movement.Delta = 8.0;
                break;

            case BulletType.Dart:
                _movement.Delta = 8.0;
                break;

            case BulletType.HugeSphere:
                _movement.Delta = 5.0;
                break;

            case BulletType.LargeSphere:
                _movement.Delta = 6.0;
                break;

            case BulletType.Palse:
                _movement.Delta = 8.0;
                break;

            case BulletType.Ring:
                _movement.Delta = 8.0;
                break;

            case BulletType.Seed:
                _movement.Delta = 8.0;
                break;

            case BulletType.Shere:
                _movement.Delta = 7.0;
                break;

            case BulletType.SmallRing:
                _movement.Delta = 8.0;
                break;

            case BulletType.SmallSphere:
                _movement.Delta = 8.0;
                break;

            case BulletType.Star:
                _movement.Delta = 6.0;
                break;
            }
        }