示例#1
0
 public bool EatAt(BaseSerpent other)
 {
     _isLonger = _serpentLength >= other._serpentLength;
     if (SerpentStatus != SerpentStatus.Alive)
     {
         return(false);
     }
     if (Vector3.DistanceSquared(GetPosition(), other.GetPosition()) < 0.8f)
     {
         if (other._serpentLength > _serpentLength)
         {
             return(false);
         }
         grow(other._serpentLength + 1);
         return(true);
     }
     for (var tail = other._tail; tail != null; tail = tail.Next)
     {
         if (Vector3.DistanceSquared(GetPosition(), tail.GetPosition()) < 0.2f)
         {
             if (tail == other._tail)
             {
                 grow(other._serpentLength + 1);
                 return(true);
             }
             grow(other.removeTail(tail));
             return(false);
         }
     }
     return(false);
 }
示例#2
0
 public bool EatAt(BaseSerpent other)
 {
     _isLonger = _serpentLength >= other._serpentLength;
     if (SerpentStatus != SerpentStatus.Alive)
         return false;
     if (Vector3.DistanceSquared(GetPosition(), other.GetPosition()) < 0.8f)
     {
         if (other._serpentLength > _serpentLength)
             return false;
         grow(other._serpentLength + 1);
         return true;
     }
     for (var tail = other._tail; tail != null; tail = tail.Next)
         if (Vector3.DistanceSquared(GetPosition(), tail.GetPosition()) < 0.2f)
         {
             if (tail == other._tail)
             {
                 grow(other._serpentLength + 1);
                 return true;
             }
             grow(other.removeTail(tail));
             return false;
         }
     return false;
 }