예제 #1
0
        /// <summary>
        /// Checks for collision with a object.
        /// A collision with a unfriendly laser or another enemy ship will not cause its destruction.
        /// </summary>
        /// <param name="anotherObserver">Another observer.</param>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public override bool CheckForCollisionWith(IGameObjectObserver anotherObserver, TimeSpan elapsedGameTime)
        {
            GAME_OBJECT_TYPE otherType = anotherObserver.GetObserved().ObjectType;

            if (otherType == GAME_OBJECT_TYPE.UNFRIENDLY_LASER || otherType == GAME_OBJECT_TYPE.ENEMY_SHIP) return false;
            return collisionSphere.Intersects(anotherObserver.GetObserved().CollisionSphere);
        }
예제 #2
0
        /// <summary>
        /// Checks for collision with another object. Only activate the power up if the hitter is a player or a friendly bullet
        /// </summary>
        /// <param name="anotherObserver">Another observer.</param>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public override bool CheckForCollisionWith(IGameObjectObserver anotherObserver, TimeSpan elapsedGameTime)
        {
            GAME_OBJECT_TYPE otherType = anotherObserver.GetObserved().ObjectType;
            if (otherType == GAME_OBJECT_TYPE.PLAYER || otherType == GAME_OBJECT_TYPE.FRIENDLY_LASER)
            {
                ActivatePowerUp(elapsedGameTime);
                return collisionSphere.Intersects(anotherObserver.GetObserved().CollisionSphere);

            }
            return false;
        }
예제 #3
0
        /// <summary>
        /// Adds points to the score, depending on what was destroyed and if the x2 multiplier is activated.
        /// </summary>
        /// <param name="destroyedObjectObserver">The destroyed object observer.</param>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        public override void AddPoints(IGameObjectObserver destroyedObjectObserver, TimeSpan elapsedGameTime)
        {
            if (doublePoints)
            {
                if (lastTimePowerUpActivated == null || elapsedGameTime - lastTimePowerUpActivated >= X2_DURRATION)
                    doublePoints = false;
            }

            scoreBoard.AddPoints(destroyedObjectObserver.GetObserved(), doublePoints);
        }
예제 #4
0
        public override bool CheckForCollisionWith(IGameObjectObserver anotherObserver, TimeSpan elapsedGameTime)
        {
            if (anotherObserver.GetObserved().ObjectType == GAME_OBJECT_TYPE.POWER_UP) return false;

            if (anotherObserver.GetObserved().ObjectType == GAME_OBJECT_TYPE.ASTEROID)
            {
                if (currentSize != Size.LARGE && ((Asteroid)anotherObserver.GetObserved()).CurrentSize == currentSize && anotherObserver != this && CanMerge(elapsedGameTime))
                {
                    return collisionSphere.Intersects(anotherObserver.GetObserved().CollisionSphere);
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return collisionSphere.Intersects(anotherObserver.GetObserved().CollisionSphere);
            }
        }
예제 #5
0
 /// <summary>
 /// Checks for collision with a object.
 /// </summary>
 /// <param name="anotherGameObject">Another game object.</param>
 /// <param name="elapsedGameTime">The elapsed game time.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public override bool CheckForCollisionWith(IGameObjectObserver anotherGameObject, TimeSpan elapsedGameTime)
 {
     return collisionSphere.Intersects(anotherGameObject.GetObserved().CollisionSphere);
 }
예제 #6
0
        /// <summary>
        /// Checks for collision with a object.
        /// </summary>
        /// <param name="anotherObserver">Another observer.</param>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public override bool CheckForCollisionWith(IGameObjectObserver anotherObserver, TimeSpan elapsedGameTime)
        {
            GAME_OBJECT_TYPE anotherObjectType = anotherObserver.GetObserved().ObjectType;

            if (anotherObjectType != GAME_OBJECT_TYPE.FRIENDLY_LASER &&
                anotherObjectType != GAME_OBJECT_TYPE.POWER_UP &&
                anotherObjectType != GAME_OBJECT_TYPE.PLAYER)
            {
                if (collisionSphere.Intersects(anotherObserver.GetObserved().CollisionSphere)) return true;

            }
            return false;
        }