protected override void writeForGrid() { int xNum = _gridShows.GetLength(0); int zNum = _gridShows.GetLength(1); BytesWriteStream stream = new BytesWriteStream(xNum * zNum + 8); stream.writeLen(xNum); stream.writeLen(zNum); for (int i = 0; i < xNum; i++) { for (int j = 0; j < zNum; j++) { stream.writeByte(_grids[i, j]); } } FileUtils.writeFileForBytesWriteStream(getMapGridFilePath(_currentSceneData.config.mapID), stream); }
/// <summary> /// 写入字节流(简版) /// </summary> protected override void toWriteBytesSimple(BytesWriteStream stream) { base.toWriteBytesSimple(stream); stream.writeInt(this.id); stream.writeByte(this.step); stream.writeShort(this.level); if (this.frameActions != null) { int[][] frameActionsT = this.frameActions; stream.writeLen(frameActionsT.Length); for (int frameActionsVI = 0, frameActionsVLen = frameActionsT.Length; frameActionsVI < frameActionsVLen; ++frameActionsVI) { int[] frameActionsV = frameActionsT[frameActionsVI]; if (frameActionsV != null) { int[] frameActionsVT = frameActionsV; stream.writeLen(frameActionsVT.Length); for (int frameActionsVVI = 0, frameActionsVVLen = frameActionsVT.Length; frameActionsVVI < frameActionsVVLen; ++frameActionsVVI) { int frameActionsVV = frameActionsVT[frameActionsVVI]; stream.writeInt(frameActionsVV); } } else { nullObjError("frameActionsV"); } } } else { nullObjError("frameActions"); } }
protected virtual void writeForGrid() { float gridSize = Global.mapBlockSize; float halfGridSize = _halfGridSize = gridSize / 2; int mapID = _currentSceneData.config.mapID; PosData originPos = _originPos; PosData sizePos = _sizePos; int xNum = (int)Math.Ceiling((sizePos.x - originPos.x) / gridSize); int zNum = (int)Math.Ceiling((sizePos.z - originPos.z) / gridSize); BytesWriteStream stream = new BytesWriteStream(xNum * zNum + 8); stream.writeLen(xNum); stream.writeLen(zNum); _grids = new byte[xNum, zNum]; if (CommonSetting.serverMapNeedSecondGrid) { _secondGrids = new byte[xNum, zNum]; } //0 1 //2 3 //4在中心 int[] gs = new int[5]; int[] rs = new int[2]; int[] temp = new int[MapBlockType.size]; float x0; float x1 = originPos.x; for (int i = 1; i <= xNum; i++) { x0 = x1; x1 = originPos.x + (gridSize * i); gs[2] = getBlockType(x0, originPos.z); gs[3] = getBlockType(x1, originPos.z); for (int j = 1; j <= zNum; j++) { gs[0] = gs[2]; gs[1] = gs[3]; float gz = originPos.z + (gridSize * j); gs[2] = getBlockType(x0, gz); gs[3] = getBlockType(x1, gz); gs[4] = getBlockType(x0 + halfGridSize, gz - halfGridSize); calculate(gs, rs, temp); //main stream.writeByte(rs[0]); //second stream.writeByte(rs[1]); _grids[i - 1, j - 1] = (byte)rs[0]; if (CommonSetting.serverMapNeedSecondGrid) { _secondGrids[i - 1, j - 1] = (byte)rs[1]; } } } FileUtils.writeFileForBytesWriteStream(getMapGridFilePath(mapID), stream); }
/// <summary> /// 写入字节流(简版) /// </summary> protected override void toWriteBytesSimple(BytesWriteStream stream) { base.toWriteBytesSimple(stream); stream.writeInt(this.id); stream.writeByte(this.step); if (this.attacks != null) { DIntData[] attacksT = this.attacks; stream.writeLen(attacksT.Length); for (int attacksVI = 0, attacksVLen = attacksT.Length; attacksVI < attacksVLen; ++attacksVI) { DIntData attacksV = attacksT[attacksVI]; if (attacksV != null) { attacksV.writeBytesSimple(stream); } else { nullObjError("attacksV"); } } } else { nullObjError("attacks"); } if (this.bullets != null) { DIntData[] bulletsT = this.bullets; stream.writeLen(bulletsT.Length); for (int bulletsVI = 0, bulletsVLen = bulletsT.Length; bulletsVI < bulletsVLen; ++bulletsVI) { DIntData bulletsV = bulletsT[bulletsVI]; if (bulletsV != null) { bulletsV.writeBytesSimple(stream); } else { nullObjError("bulletsV"); } } } else { nullObjError("bullets"); } stream.writeInt(this.time); if (this.switchType != null) { int[] switchTypeT = this.switchType; stream.writeLen(switchTypeT.Length); for (int switchTypeVI = 0, switchTypeVLen = switchTypeT.Length; switchTypeVI < switchTypeVLen; ++switchTypeVI) { int switchTypeV = switchTypeT[switchTypeVI]; stream.writeInt(switchTypeV); } } else { nullObjError("switchType"); } stream.writeInt(this.motionID); stream.writeBoolean(this.isStayAir); }