Esempio n. 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;
        }
Esempio n. 2
0
        /// <summary>
        /// Notifies the specified subject. Tells the subject to activate the power up.
        /// </summary>
        /// <param name="subject">The subject.</param>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        public override void Notify(Subject subject, TimeSpan elapsedGameTime)
        {
            List<IGameObjectObserver> list = subject.GetObserverList();

            foreach (IGameObjectObserver observer in list)
            {
                if (observer.GetObserved().ObjectType == GAME_OBJECT_TYPE.ASTEROID)
                {
                    Asteroid currentAsteroid = (Asteroid) observer.GetObserved();
                    currentAsteroid.GetSlowMo(elapsedGameTime);
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Sets the hitter.
 /// </summary>
 /// <param name="subject">The subject.</param>
 /// <param name="hitter">The hitter.</param>
 public void SetHitter(Subject subject, IGameObjectObserver hitter)
 {
     subject.Hitter = hitter;
 }
Esempio n. 4
0
 /// <summary>
 /// Notifies the specified subject. not used since we do not implement this class
 /// </summary>
 /// <param name="subject">The subject.</param>
 /// <param name="elapsedGameTime">The elapsed game time.</param>
 public virtual void Notify(Subject subject, TimeSpan elapsedGameTime)
 {
     //throw new NotImplementedException();
 }
Esempio n. 5
0
 /// <summary>
 /// Gets the object that hits the object.
 /// </summary>
 /// <param name="subject">The subject.</param>
 /// <returns>IGameObjectObserver.</returns>
 public IGameObjectObserver GetHitter(Subject subject)
 {
     return subject.Hitter;
 }
Esempio n. 6
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 virtual bool CheckForCollisionWithListOfObserver(List<IGameObjectObserver> list, Subject subject, TimeSpan elapsedGameTime)
        {
            bool intersects = false;

            foreach (IGameObjectObserver observer in list)
            {
                intersects = CheckForCollisionWith(observer, elapsedGameTime);
                if (intersects)
                {
                    SetHitter(subject, observer);
                    Notify(subject, elapsedGameTime);
                    break;
                }
            }

            return intersects;
        }
Esempio n. 7
0
 /// <summary>
 /// Adds points to score by passing a observer that observe a game object.
 /// </summary>
 /// <param name="subject">The subject.</param>
 /// <param name="destroyedObjectObserver">The destroyed object observer.</param>
 /// <exception cref="NotImplementedException"></exception>
 public void AddPoints(Subject subject, IGameObjectObserver destroyedObjectObserver)
 {
     throw new NotImplementedException();
 }
Esempio n. 8
0
 /// <summary>
 /// Notifies the specified subject. this is used to add projectiles in the list of observer in the manager
 /// </summary>
 /// <param name="subject">The subject.</param>
 /// <param name="elapsedGameTime">The elapsed game time.</param>
 public override void Notify(Subject subject, TimeSpan elapsedGameTime)
 {
     subject.AddObserver(this);
 }
Esempio n. 9
0
 /// <summary>
 /// Notifies the specified subject. Tells the subject to activate the double points multiplier
 /// </summary>
 /// <param name="subject">The subject.</param>
 /// <param name="elapsedGameTime">The elapsed game time.</param>
 public override void Notify(Subject subject, TimeSpan elapsedGameTime)
 {
     subject.ActivateDoublePoints(elapsedGameTime);
 }
Esempio n. 10
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;
        }
Esempio n. 11
0
 /// <summary>
 /// Notifies the specified subject. Tells the subject to activate the fast fire power up
 /// </summary>
 /// <param name="subject">The subject.</param>
 /// <param name="elapsedGameTime">The elapsed game time.</param>
 public override void Notify(Subject subject, TimeSpan elapsedGameTime)
 {
     Player.GetInstance().ActivateFastFire(elapsedGameTime);
 }