Esempio n. 1
0
    public void AddOccupant(IntVector3 position, ITileOccupant occupant)
    {
        if (!IsWithinMap(position))
        {
            CustomLogger.Error(nameof(LevelDataManager), $"Position {position} is out of bounds!");
            return;
        }
        ITileInfo tileInfo = _tiles[position.x][position.y];

        tileInfo.AddOccupant(occupant);
    }
Esempio n. 2
0
    protected virtual void UpdateMapSpacePosition(IntVector3 position)
    {
        ITileInfo oldTileInfo = LevelDataManager.Instance.GetTileAt(_mapPosition.x, _mapPosition.y);

        if (oldTileInfo != null)
        {
            oldTileInfo.RemoveOccupant(_unit);
        }
        _mapPosition = position;
        ITileInfo newTileInfo = LevelDataManager.Instance.GetTileAt(_mapPosition.x, _mapPosition.y);

        if (newTileInfo != null)
        {
            newTileInfo.AddOccupant(_unit);
        }
        OnMapPositionUpdated?.Invoke(MapPosition);
    }