Пример #1
0
        /// <summary>
        /// Processes entity events.
        /// </summary>
        public override void ProcessEvents()
        {
            ProcessMovement();

            if (PolygonCollisions.Collides(Hitbox, GameObjects.Player.Grazebox))
            {
                Remove = true;
                switch (_itemType)
                {
                case ItemType.BigPower:
                    GameScores.IncrementPower(5);
                    GameScores.SCORE += GameScores.POINTS[GameScores.ITERATOR];
                    break;

                case ItemType.Bomb:
                    GameScores.BOMB++;
                    break;

                case ItemType.FullPower:
                    GameScores.POWER  = 128;
                    GameScores.SCORE += GameScores.POINTS[GameScores.ITERATOR];
                    break;

                case ItemType.Life:
                    GameScores.PLAYER++;
                    break;

                case ItemType.Point:
                    GameScores.BONUS++;
                    break;

                case ItemType.Power:
                    GameScores.IncrementPower(1);
                    GameScores.SCORE += GameScores.POINTS[GameScores.ITERATOR];
                    break;

                case ItemType.Star:
                    GameScores.SCORE += 500 + (10 * (GameScores.GRAZE / 3));
                    break;
                }
            }

            //TODO: Fire
        }
        public override void ProcessEvents()
        {
            ProcessMovement();

            Level();

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

            foreach (BulletEntity bullet in GameObjects.Bullets)
            {
                if (bullet.Owner != this)
                {
                    if (PolygonCollisions.Collides(_grazebox, bullet.Hitbox))
                    {
                        if (PolygonCollisions.Collides(Hitbox, bullet.Hitbox))
                        {
                            Hitpoints    -= bullet.Hitpoints;
                            bullet.Remove = true;
                            break;
                        }
                        if (!bullet.Grazed)
                        {
                            GameScores.GRAZE++;
                            bullet.Grazed = true;
                            break;
                        }
                    }
                }
            }

            if (SwinGame.KeyDown(Settings.BOMB) && GameScores.BOMB > 0 && _cooldown == 0)
            {
                foreach (BulletEntity bullet in GameObjects.Bullets)
                {
                    if (bullet.Owner != this)
                    {
                        GameObjects.AddItem(new ItemEntity(bullet.Hitbox.Middle, ItemType.Star));
                        bullet.Remove = true;
                    }
                }

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

                GameScores.BOMB--;
                _cooldown = 60;
            }

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

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

            Tick++;
        }