Example #1
0
        protected bool CheckColision(ILocalizable localizable)
        {
            foreach (ILocalizable item in fruitsList)
            {
                if (item is Banana)
                {
                    if (Object.ReferenceEquals(item, this))
                    {
                        continue;
                    }
                }
                if (item.Bounds.Contains(localizable.Location) || localizable.Bounds.Contains(item.Location))
                {
                    return(true);
                }
            }

            foreach (ILocalizable item in obstacles)
            {
                if (item.Bounds.Contains(localizable.Location) || localizable.Bounds.Contains(item.Location))
                {
                    return(true);
                }
            }


            if (snake.CheckColsion(localizable))
            {
                return(true);
            }

            return(false);
        }
Example #2
0
        private bool CheckColision(ILocalizable localizable)
        {
            foreach (ILocalizable item in fruitsList)
            {
                if (item.Bounds.Contains(localizable.Location) || localizable.Bounds.Contains(item.Location))
                {
                    return(true);
                }
            }

            foreach (ILocalizable item in obstaclesList)
            {
                if (item.Bounds.Contains(localizable.Location) || localizable.Bounds.Contains(item.Location))
                {
                    return(true);
                }
            }


            if (snake.CheckColsion(localizable))
            {
                return(true);
            }

            return(false);
        }