/// <summary>
        /// Gets OnHexTileObject with given type and HexTileCoord.
        /// </summary>
        /// <returns>Returns null if given type is not in the dict.</returns>
        public T GetTileObject <T>(HexTileCoord coord) where T : IOnHexTileObject
        {
            var type = typeof(T);

            if (!_onTileMapObjects.TryGetValue(coord, out var coordObjectDict))
            {
                return(default);
Beispiel #2
0
        public HexTile(HexTileCoord coord, Neuron tilemapNeuron)
        {
            Coord = coord;

            tilemapNeuron.Subscribe <ModifierSignal>(OnModifierSignal);
            tilemapNeuron.Subscribe <GameCommandSignal>(OnGameCommandSignal);
        }
        public HexTile GetHexTile(HexTileCoord coord)
        {
            if (!IsValidCoord(coord))
            {
                return(null);
            }

            var q = coord.Q;
            var r = coord.R;

            if (r < Radius)
            {
                q = q - Radius + r;
            }

            return(_tileMap[r][q]);
        }
Beispiel #4
0
 private void OnClickTile(HexTileCoord coord)
 {
 }
 /// <summary>
 /// Is it valid coordinate on this tile map?
 /// </summary>
 public bool IsValidCoord(HexTileCoord coord)
 {
     return(coord.Q + coord.R >= Radius && coord.Q + coord.R <= 3 * Radius);
 }
 public IReadOnlyList <IOnHexTileObject> this[HexTileCoord coord] =>
 IsValidCoord(coord) ? GetAllTileObjects(coord) : null;
 public void Init(HexTile t, Action <HexTileCoord> onClicked)
 {
     _coord   = t.Coord;
     OnClick += onClicked;
     name     = $"Tile ({_coord.Q}, {_coord.R})";
 }