Exemple #1
0
        /// <summary>
        /// Confirm that this object is a neighbor and is still active in the game.
        /// </summary>
        /// <param name="gameObject">Object to check</param>
        /// <returns>Whether or not this object is a neighbor.</returns>
        public bool ValidateAsNeighbor(GameObject gameObject)
        {
            if (Game.Components.Contains(gameObject))
            {
                if (NeighborBoundary.Intersects(gameObject.Boundary))
                {
                    if (!NeighboringObjects.Contains(gameObject))
                    {
                        NeighboringObjects.Add(gameObject);
                    }

                    return(true);
                }
                else
                {
                    if (NeighboringObjects.Contains(gameObject))
                    {
                        NeighboringObjects.Remove(gameObject);
                    }
                }
            }
            else
            {
                if (NeighboringObjects.Contains(gameObject))
                {
                    NeighboringObjects.Remove(gameObject);
                }

                if (gameObject == Anchor)
                {
                    Anchor = null;
                }
            }
            return(false);
        }
Exemple #2
0
 /// <summary>
 /// Method called when player has landed on another game object.
 /// </summary>
 /// <param name="sender">Game object collided with.</param>
 /// <param name="args">Collision event arguments.</param>
 private void Landed(GameObject sender, CollisionEventArgs args)
 {
     if (sender.GetType() == typeof(Monster))
     {
         var monster = sender as Monster;
         NeighboringObjects.Remove(monster);
         monster.IsDead = true;
         ApplyForce(0, -10);
     }
 }