public static void RandomPlacementOfItems()
        {
            Random rand = new Random();

            ItemType[] items = new ItemType[]
            {
                ItemType.BigPower,
                ItemType.Bomb,
                ItemType.FullPower,
                ItemType.Life,
                ItemType.Point,
                ItemType.Power,
                ItemType.Star
            };

            int[] trigger = new int[]
            {
                rand.Next() % 240 + 600,
                  rand.Next() % 240 + 40,
                  rand.Next() % 240 + 6000,
                  rand.Next() % 240 + 60,
                  rand.Next() % 40 + 40,
                  rand.Next() % 40 + 20,
                  rand.Next() % 40 + 40
            };

            for (int i = 0; i < 7; ++i)
            {
                if (tick % trigger[i] == 0)
                {
                    GameObjects.AddItem(new ItemEntity((rand.Next() % (460 - GameResources.GameImage("Item" + items[i].ToString()).Width)) + 40, 50, items[i]));
                }
            }
        }
Exemple #2
0
        public static void RandomPlacementOfItems()
        {
            Random rand = new Random();

            ItemType[] items = new ItemType[]
            {
                ItemType.BigPower,
                ItemType.Bomb,
                ItemType.FullPower,
                ItemType.Life,
                ItemType.Point,
                ItemType.Power,
                ItemType.Star
            };

            int[] trigger = new int[]
            {
                rand.Next() % 340 + 600,
                  rand.Next() % 340 + 40,
                  rand.Next() % 340 + 6000,
                  rand.Next() % 340 + 60,
                  rand.Next() % 140 + 40,
                  rand.Next() % 140 + 20,
                  rand.Next() % 140 + 40
            };

            for (int i = 0; i < 7; ++i)
            {
                if (tick % (trigger[i]) == 0 && tick > 0)
                {
                    GameObjects.AddItem(new ItemEntity(new Point2D((rand.Next() % (460 - GameResources.GameImage("Item" + items[i].ToString()).Width)) + 40, 50), items[i]));
                }
            }

            if (tick % (rand.Next() % 80 + 50) == 0 && tick > 0)
            {
                double x = rand.Next() % 460 + 40;
                double y = rand.Next() % 460 + 40;
                int    n = rand.Next() % 24;
                for (int j = 0; j < n; ++j)
                {
                    GameObjects.AddBullet(new BulletEntity(new Point2D(x, y), new Velocity2D(2.8, 360 / n * j), 360 / n * j, BulletColour.Red, BulletType.Ring, null));
                }
            }
        }
Exemple #3
0
        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.Items[i].Hitpoints = 0;
                    }
                }
            }

            foreach (BulletEntity bullet in GameObjects.Bullets)
            {
                if (bullet.Owner != this && bullet.Colides(this))
                {
                    Hitpoints       -= bullet.Hitpoints;
                    bullet.Hitpoints = 0;
                }
            }

            Level();

            if (SwinGame.KeyDown(GameKeys.SHOOT))
            {
                Cannon();
            }

            if (SwinGame.KeyDown(GameKeys.BOMB) && GameScores.Bomb > 0 && _coolDown == 0)
            {
                foreach (BulletEntity bullet in GameObjects.Bullets)
                {
                    if (bullet.Owner != this)
                    {
                        GameObjects.AddItem(new ItemEntity(bullet.Position, ItemType.Star));
                        bullet.Hitpoints = 0;
                    }
                }

                foreach (ItemEntity item in GameObjects.Items)
                {
                    item.Flag = true;
                }

                GameScores.Bomb--;
                _coolDown = 60;
            }

            if (Y < 160)
            {
                foreach (ItemEntity item in GameObjects.Items)
                {
                    item.Flag = true;
                }
            }

            ProcessMovement();

            DrawEntity();

            if (_cannonAux > 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++;

            if (_coolDown > 0)
            {
                _coolDown--;
            }
        }