Exemple #1
0
        public override void Update()
        {
            base.Update();

            BaseUnit[] baseUnits = new BaseUnit[Units.Count];
            Units.CopyTo(baseUnits);

            IEnumerable <CollisionPair> collidedUnits = CollisionChecker.GetAllCollisions(baseUnits);

            foreach (CollisionPair tuple in collidedUnits)
            {
                if (_lastCollided.All(prevoiseTuple => !prevoiseTuple.Equals(tuple)))
                {
                    tuple.Collided();
                }
            }

            bool ballOutside = _player.Ball.Position.Y > PlayingSize.Height;

            if (ballOutside && !testPhysic())
            {
                Failed = true;
            }

            //has no blocks
            if (baseUnits.All(unit => unit.UnitType != UnitType.Block))
            {
                Success = true;
            }
        }