private Dictionary <IntVector2, IMapTileInfo> UploadNewSectorByIndex(int x, int y) { _mapTilesInfo = _mapInfoStoreController.UploadSectorData(new IntVector2(x, y)); _sectorInfo = _mapInfoStoreController.UploadSectorInfo(new IntVector2(x, y)); _mapInfoInitializer.InitializeSector(_mapTilesInfo, _sectorInfo); return(_mapInfoInitializer.MapTilesInfo); }
private IntVector2 GetPositionVisibleProgression(IntVector2 position, ISectorInfo sectorInfo) { int xProgression, yProgression; xProgression = GetVisibleDimantionProgression(GetSectorRange(sectorInfo, true), GetPositionVisibleRange(position, true)); yProgression = GetVisibleDimantionProgression(GetSectorRange(sectorInfo, false), GetPositionVisibleRange(position, false)); return(new IntVector2(xProgression, yProgression)); }
private IntVector2 GetPositionSectorProgression(IntVector2 position, ISectorInfo sectorInfo) { int xProgression, yProgression; xProgression = GetSectorDimantionProgression(GetSectorRange(sectorInfo, true), position.x); yProgression = GetSectorDimantionProgression(GetSectorRange(sectorInfo, false), position.y); return(new IntVector2(xProgression, yProgression)); }
private void InitializeCurrentSector() { IntVector2 index = new IntVector2(0, 0); _currentSector = _mapInfoStoreController.UploadSectorInfo(index); if (_currentSector == null) { throw new SystemException(); } _sectorLifecycleController.AddActiveSector(_currentSector.index); _sectorLifecycleController.UpdateSectors(); }
private bool IsPositionInSector(ISectorInfo sectorInfo, IntVector2 position) { IntVector2 result = GetPositionSectorProgression(position, sectorInfo); if (result.x == 0 && result.y == 0) { return(true); } else { return(false); } }
private ISectorInfo GetSectorOfPosition(IntVector2 position, ISectorInfo sectorInfo) { if (IsPositionInSector(sectorInfo, position)) { return(sectorInfo); } else { IntVector2 progression; progression = GetPositionSectorProgression(position, sectorInfo); IntVector2 newPosition = new IntVector2(sectorInfo.index.x + progression.x, sectorInfo.index.y + progression.y); sectorInfo = GetCashedSectorInfo(newPosition); return(GetSectorOfPosition(position, sectorInfo)); } }
public void SaveSector(ISectorInfo info, Dictionary <IntVector2, IMapTileInfo> data) { string sectorInfo = JsonMapper.ToJson(info); File.WriteAllText( _settings.MapsResourcesLocation + GetSectorInfoName(info.index), sectorInfo ); string sectorData = SectorDataToJson(data); File.WriteAllText( _settings.MapsResourcesLocation + GetSectorDataName(info.index), sectorData ); }
private void RemoveTilesInSection(ISectorInfo sectionInfo) { IntVector2 index; for (int i = sectionInfo.startPoint.x; i < sectionInfo.startPoint.x + sectionInfo.size.x; i++) { for (int j = sectionInfo.startPoint.y; j < sectionInfo.startPoint.y + sectionInfo.size.y; j++) { index = new IntVector2(i, j); if (_activeTiles.ContainsKey(index)) { _activeTiles.Remove(index); } } } }
private IntVector2 GetSectorRange(ISectorInfo sectorInfo, bool xDimention) { int startValue, endValue; if (xDimention) { startValue = sectorInfo.startPoint.x; endValue = sectorInfo.startPoint.x + sectorInfo.size.x - 1; return(new IntVector2(startValue, endValue)); } else { startValue = sectorInfo.startPoint.y; endValue = sectorInfo.startPoint.y + sectorInfo.size.y - 1; return(new IntVector2(startValue, endValue)); } }
public void CreateSector(IntVector2 index, IntVector2 startPoint, IntVector2 size) { _sectorInfo = new SectorInfo(); _sectorInfo.startPoint = new IntVector2(startPoint.x, startPoint.y); _sectorInfo.size = new IntVector2(size.x, size.y); _sectorInfo.index = index; MapTileInfo mapTileInfo; for (int i = startPoint.x; i < startPoint.x + size.x; i += 2 /*MainEditorController.SCALE*/) { for (int j = startPoint.y; j < startPoint.y + size.y; j += 2 /*MainEditorController.SCALE*/) { InitializePlane(new IntVector2(i, j)); /* * mapTileInfo = new MapTileInfo(); * mapTileInfo.Initialize(MapTileType.Square, new IntVector2(i, j), new IntVector2(i, j)); * _sectorTilesInfo[new IntVector2(i, j)] = mapTileInfo; */ } } }
public NodeInformation(int layer, int row, int column, ISectorInfo sector, IPlayer owner) : base(layer, row, column) { this.Init(); this.Sector = sector; this.Owner = owner; }
public void InitializeSector(Dictionary <IntVector2, IMapTileInfo> mapTilesInfo, ISectorInfo sectorInfo) { _sectorTilesInfo = mapTilesInfo; _sectorInfo = sectorInfo; }
private void UpdateCurrentSector(IntVector2 position) { _currentSector = GetSectorOfPosition(position, _currentSector); _sectorLifecycleController.AddActiveSector(_currentSector.index); }