public override Tile.Tile CreateInstance(PrefabGrid <Tile.Tile> grid, GridLocation location)
 {
     if (grid[location] == null)
     {
         return(null);
     }
     return(base.CreateInstance(grid, location));
 }
コード例 #2
0
 /// <summary>
 ///     Creates a new instance of a tile
 ///     if it's legal to place one there.
 /// </summary>
 /// <param name="grid"></param>
 /// <param name="location"></param>
 /// <returns></returns>
 public override Tile.Tile CreateInstance(PrefabGrid <Tile.Tile> grid, GridLocation location)
 {
     if (IsLocationExcluded(location))
     {
         return(null);
     }
     return(base.CreateInstance(grid, location));
 }
コード例 #3
0
        /// <summary>
        ///     Instantiates a new tile
        ///     This method will translate the location
        ///     in local grid space, into word space
        ///     coordinates and then instantiate a tile
        ///     there, after which it will initialize
        ///     all the tile's components with all the
        ///     data that they may need.
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="location"> the local grid space location </param>
        /// <returns> a newly instantiated tile </returns>
        public virtual Tile.Tile CreateInstance(PrefabGrid <Tile.Tile> grid, GridLocation location)
        {
            var spawnLoco = GridSpaceGlobalSpaceConverter.FromLocation(location, -0.15f);

            var currentTile = Object.Instantiate(grid.Prefab, spawnLoco, Quaternion.identity,
                                                 tileSelectionManager.transform);

            // initializing the components.
            currentTile.GetComponent <ITileSelectionInteractor>().Init(gameManager.GetEnergyCounter(),
                                                                       gameManager.GetTurretShop(), tileSelectionManager, tileFocusManager);
            currentTile.GetComponent <ITileFocusDisplay>().Init(gameManager.focus);
            currentTile.GetComponent <IPrefabGridPositionedItem>().SetLocation(location);
            currentTile.GetComponent <IExclusiveFocusInteractor>().SetManager(tileFocusManager);
            return(currentTile);
        }