Esempio n. 1
0
    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);
    }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        private bool IsPositionInSector(ISectorInfo sectorInfo, IntVector2 position)
        {
            IntVector2 result = GetPositionSectorProgression(position, sectorInfo);

            if (result.x == 0 && result.y == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 6
0
 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));
     }
 }
Esempio n. 7
0
        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
                );
        }
Esempio n. 8
0
        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);
                    }
                }
            }
        }
Esempio n. 9
0
        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));
            }
        }
Esempio n. 10
0
        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;
		}
Esempio n. 12
0
 public void InitializeSector(Dictionary <IntVector2, IMapTileInfo> mapTilesInfo, ISectorInfo sectorInfo)
 {
     _sectorTilesInfo = mapTilesInfo;
     _sectorInfo      = sectorInfo;
 }
Esempio n. 13
0
 private void UpdateCurrentSector(IntVector2 position)
 {
     _currentSector = GetSectorOfPosition(position, _currentSector);
     _sectorLifecycleController.AddActiveSector(_currentSector.index);
 }