void AttempToMove(Vector2 position) { MDTile tile = MapManager.shared.map.GetTileAt((int)position.x, (int)position.y); MDObject obj = MapManager.shared.map.GetObjectAt(position); MDUnit unit = MapManager.shared.map.GetUnitAt(position); if (tile == null || tile.solid || (tile.liquid && !onBoat)) { Debug.Log("Solid surface!"); } else if (obj != null && obj.solid) { Interact(obj); } else if (unit != null) { if (unit.friendly) { Talk(unit); } else { Attack(unit); } } else { _transform.position = position; MapManager.shared.UpdateChunks(); } }
public bool SetTileAt(int x, int y, MDTile tile) { if (x < 0 || x >= width || y < 0 || y >= height) { return(false); } tiles[y * width + x] = tile; return(true); }
public MDTile[] GetTilesAt(int x, int y, int width, int height) { MDTile[] result = new MDTile[this.size]; for (int i = 0, xi = 0; xi < width; xi++) { for (int yi = 0; yi < height; yi++, i++) { result[i] = GetTileAt(x + xi, y + yi); } } return(result); }