/// <summary>
 ///     Assigns every location in the board, to the value
 ///     returned by the <c>CreateInstance</c> method of
 ///     the
 ///     <param name="instantiationCreator"></param>
 ///     .
 ///     This allows for population of the game board,
 ///     and for prefab objects to be instantiated.
 /// </summary>
 /// <param name="instantiationCreator"></param>
 protected void GridInstantiate(IGridInstantiationCreator <T> instantiationCreator)
 {
     foreach (var loc in RowMajorIEnumerator())
     {
         this[loc] = instantiationCreator.CreateInstance(this, loc);
     }
 }
Ejemplo n.º 2
0
        private void PopulateGrid()
        {
            var intermediateValues = path.GetExtrapolator().GetIntermediateValues();

            foreach (var enemyPathNode in intermediateValues)
            {
                // cache the location for later.
                var enemyPathNodeLocation = enemyPathNode.Location;
                var pathNodeInstance      = instantiator.CreateInstance(this, enemyPathNodeLocation);

                // see if we can enable either the input or the output constraints.
                if (enemyPathNode.IncomingDirection != null)
                {
                    pathNodeInstance.Enable(enemyPathNode.IncomingDirection.Value);
                }
                if (enemyPathNode.OutgoingDirection != null)
                {
                    pathNodeInstance.Enable(enemyPathNode.OutgoingDirection.Value);
                }


                this[enemyPathNodeLocation] = pathNodeInstance;
            }
        }