private bool SimpleCollision(GameObjectBounds firstGameObjectBounds, GameObjectBounds secondGameObjectBounds)
 {
     return
         (((firstGameObjectBounds.Top <= secondGameObjectBounds.Top && secondGameObjectBounds.Top <= firstGameObjectBounds.Bottom) ||
           (firstGameObjectBounds.Top <= secondGameObjectBounds.Bottom && secondGameObjectBounds.Bottom <= firstGameObjectBounds.Bottom)) &&
          ((firstGameObjectBounds.Left <= secondGameObjectBounds.Left && secondGameObjectBounds.Left <= firstGameObjectBounds.Right) ||
           (firstGameObjectBounds.Left <= secondGameObjectBounds.Right && secondGameObjectBounds.Right <= firstGameObjectBounds.Right)));
 }
        protected GameObjectBounds GetObjectBounds(GameObject go1)
        {
            int go1Left   = go1.Position.Left;
            int go1Right  = go1.Position.Left + go1.Bounds.Width;
            int go1Top    = go1.Position.Top;
            int go1Bottom = go1.Position.Top + go1.Bounds.Height;
            GameObjectBounds go1Bounds = new GameObjectBounds(go1Left, go1Top, go1Right, go1Bottom);

            return(go1Bounds);
        }
        public virtual bool AreCollided(GameObject go1, GameObject go2)
        {
            GameObjectBounds go1Bounds = GetObjectBounds(go1);

            GameObjectBounds go2Bounds = GetObjectBounds(go2);

            bool shouldDie = SimpleCollision(go1Bounds, go2Bounds);

            return(shouldDie);
        }
        private GameObjectBounds GetObjectBounds(IGameObject gameObject)
        {
            int gameObjectLeft   = gameObject.Position.Left;
            int gameObjectRight  = gameObject.Position.Left + gameObject.Bounds.Width;
            int gameObjectTop    = gameObject.Position.Top + 50;
            int gameObjectBottom = gameObject.Position.Top + gameObject.Bounds.Height;
            GameObjectBounds gameObjectBounds = new GameObjectBounds(gameObjectLeft, gameObjectTop, gameObjectRight, gameObjectBottom);

            return(gameObjectBounds);
        }
        private bool AreCollided(IGameObject firstGameObject, IGameObject secondGameObject)
        {
            GameObjectBounds firstGameOnjectBounds = this.GetObjectBounds(firstGameObject);

            GameObjectBounds secondGameObjectBounds = this.GetObjectBounds(secondGameObject);

            bool shouldDie = this.SimpleCollision(firstGameOnjectBounds, secondGameObjectBounds);

            return(shouldDie);
        }
 public void AddTarget(GameObjectBounds target)
 {
     if (targets.Contains(target) == false)
     {
         targets.Add(target);
     }
     else
     {
         Debug.Log($"{target.name} already in follow list");
     }
 }
 public void RemoveTarget(GameObjectBounds target)
 {
     targets.Remove(target);
 }
 private bool SimpleCollision(GameObjectBounds go1Bounds, GameObjectBounds go2Bounds)
 {
     return(((go1Bounds.Top <= go2Bounds.Top && go2Bounds.Top <= go1Bounds.Bottom) || (go1Bounds.Top <= go2Bounds.Bottom && go2Bounds.Bottom <= go1Bounds.Bottom)) &&
            ((go1Bounds.Left <= go2Bounds.Left && go2Bounds.Left <= go1Bounds.Right) || (go1Bounds.Left <= go2Bounds.Right && go2Bounds.Right <= go1Bounds.Right)));
 }
Example #9
0
 private bool CheckforInsideCollision(GameObjectBounds go1Bounds, GameObjectBounds go2Bounds)
 {
     return(false);
 }