예제 #1
0
 /// <summary>
 /// Unregisters the specified <see cref="DynamicObstacle"/> from this grid.
 /// </summary>
 /// <param name="obstacle">The <see cref="DynamicObstacle"/> to unregister</param>
 public void unregisterObstacle(DynamicObstacle obstacle)
 {
     // Check all obstacles
     for (int i = 0; i < obstacles.Count; i++)
     {
         // Check for matching obstacle
         if (obstacles[i].obstacle == obstacle)
         {
             // Remove the obstacle
             obstacles.RemoveAt(i);
             return;
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Registers a <see cref="DynamicObstacle"/> with this grid.
        /// </summary>
        /// <param name="obstacle">The <see cref="DynamicObstacle"/> to register</param>
        public void registerObstacle(DynamicObstacle obstacle)
        {
            // Make sure it is not already registered
            foreach (DynamicObstacleData data in obstacles)
            {
                // We have foud the same obstacle already registered
                if (data.obstacle == obstacle)
                {
                    return;
                }
            }

            // Add the obstacle
            obstacles.Add(new DynamicObstacleData
            {
                lastUpdate        = 0,
                obstacle          = obstacle,
                obstructedIndexes = new List <Index>(),
            });
        }