Пример #1
0
        /// <summary>
        /// Checks for collision with a list of observers.
        /// If it touches a enemy or a asteroid, it asks the subject to add points to the score.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <param name="subject">The subject.</param>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public override bool CheckForCollisionWithListOfObserver(List<IGameObjectObserver> list, Subject subject, TimeSpan elapsedGameTime)
        {
            foreach (IGameObjectObserver obj in list)
            {
                if (objectType == GAME_OBJECT_TYPE.FRIENDLY_LASER)
                {
                    if (obj.GetObserved().ObjectType != GAME_OBJECT_TYPE.FRIENDLY_LASER && obj.GetObserved().ObjectType != GAME_OBJECT_TYPE.PLAYER)
                    {
                        if (CheckForCollisionWith(obj, elapsedGameTime))
                        {
                            subject.Hitter = obj;
                            subject.AddPoints(obj, elapsedGameTime);
                            return true;
                        }
                    }
                }
                else
                {
                    if (obj.GetObserved().ObjectType != GAME_OBJECT_TYPE.UNFRIENDLY_LASER && obj.GetObserved().ObjectType != GAME_OBJECT_TYPE.ENEMY_SHIP && obj.GetObserved().ObjectType != GAME_OBJECT_TYPE.POWER_UP)
                    {
                        if (CheckForCollisionWith(obj, elapsedGameTime))
                        {
                            subject.Hitter = obj;
                            return true;
                        }
                    }
                }

            }
            return false;
        }
Пример #2
0
        /// <summary>
        /// Checks for collision with a list of observers.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <param name="subject">The subject.</param>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public override bool CheckForCollisionWithListOfObserver(List<IGameObjectObserver> list, Subject subject, TimeSpan elapsedGameTime)
        {
            foreach (IGameObjectObserver obj in list)
            {
                if (obj != this && obj.GetObserved().ObjectType != GAME_OBJECT_TYPE.PLAYER)
                {
                    if (CheckForCollisionWith(obj, elapsedGameTime))
                    {
                        subject.Hitter = obj;
                        subject.AddPoints(obj, elapsedGameTime);
                        return true;
                    }
                }
            }

            return false;
        }