示例#1
0
    private void CheckCollions()
    {
        List <Block> RemoveBlocks = new List <Block>();
        List <Laser> RemoveLaser  = new List <Laser>();
        List <Buff>  RemoveBuff   = new List <Buff>();

        foreach (Block BLOCK in _blocks)
        {
            if (_Player.Collidewith(BLOCK))
            {
                if (_Player.PowerUp == true)
                {
                    if (!BLOCK.SpawnNext)
                    {
                        RemoveBlocks.Add(BLOCK);
                    }
                }
                else
                {
                    _Player.LevelEnd = true;
                    AddScore();
                    GameTimer.Pause();
                    break;
                }
            }

            foreach (Laser LASER in _laser)
            {
                if (LASER.Collidewith(BLOCK))
                {
                    RemoveBlocks.Add(BLOCK);
                    RemoveLaser.Add(LASER);
                }
            }
        }
        foreach (Block BLOCK in RemoveBlocks)
        {
            _blocks.Remove(BLOCK);
        }
        foreach (Laser LASER in RemoveLaser)
        {
            _laser.Remove(LASER);
        }

        foreach (Buff BUFF in _buff)
        {
            if (_Player.Collidewith(BUFF))
            {
                if (BUFF.bufftype == Buff.BuffType.Rainbow)
                {
                    _Player.PowerUp = true;
                    BuffTimer.Start();
                    SplashKit.PauseMusic();
                    Star.Play();
                }
                if (BUFF.bufftype == Buff.BuffType.Ammo)
                {
                    _Player.Ammo = _Player.Ammo + 1;
                }

                RemoveBuff.Add(BUFF);
            }
            if (BUFF.IsOffScreen(_Window))
            {
                RemoveBuff.Add(BUFF);
            }
            BUFF.Update();
        }


        foreach (Buff BUFF in RemoveBuff)
        {
            _buff.Remove(BUFF);
        }
    }