public PathSearch(World world, MobileInfo mobileInfo, Player owner) { this.world = world; cellInfo = InitCellInfo(); this.mobileInfo = mobileInfo; this.owner = owner; queue = new PriorityQueue<PathDistance>(); }
public PathSearch(World world) { cellInfo = InitCellInfo(); queue = new PriorityQueue<PathDistance>(); buildingInfluence = world.WorldActor.traits.Get<BuildingInfluence>(); unitInfluence = world.WorldActor.traits.Get<UnitInfluence>(); }
public PathSearch(World world, MobileInfo mobileInfo) { this.world = world; uim = world.WorldActor.Trait<UnitInfluence>(); cellInfo = InitCellInfo(); this.mobileInfo = mobileInfo; queue = new PriorityQueue<PathDistance>(); }
public PathSearch(Actor self) { this.self = self; world = self.World; cellInfo = InitCellInfo(); mobile = self.Trait<Mobile>(); queue = new PriorityQueue<PathDistance>(); }
public PathSearch(World world, MobileInfo mobileInfo, Actor self) { this.world = world; cellInfo = InitCellInfo(); this.mobileInfo = mobileInfo; this.self = self; customCost = null; queue = new PriorityQueue<PathDistance>(); }
private void LoadMapType1() { try { int offSet = 21; int w = BitConverter.ToInt16(Bytes, offSet); offSet += 2; int xor = BitConverter.ToInt16(Bytes, offSet); offSet += 2; int h = BitConverter.ToInt16(Bytes, offSet); Width = w ^ xor; Height = h ^ xor; MapCells = new CellInfo[Width, Height]; offSet = 54; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { MapCells[x, y] = new CellInfo { BackIndex = 0, BackImage = (int)(BitConverter.ToInt32(Bytes, offSet) ^ 0xAA38AA38), MiddleIndex = 1, MiddleImage = (short)(BitConverter.ToInt16(Bytes, offSet += 4) ^ xor), FrontImage = (short)(BitConverter.ToInt16(Bytes, offSet += 2) ^ xor), DoorIndex = (byte)(Bytes[offSet += 2] & 0x7F), DoorOffset = Bytes[++offSet], FrontAnimationFrame = Bytes[++offSet], FrontAnimationTick = Bytes[++offSet], FrontIndex = (short)(Bytes[++offSet] + 2), Light = Bytes[++offSet], Unknown = Bytes[++offSet], }; offSet++; if (MapCells[x, y].Light >= 100 && MapCells[x, y].Light <= 119) { MapCells[x, y].FishingCell = true; } } } } catch (Exception ex) { if (Settings.LogErrors) { CMain.SaveError(ex.ToString()); } } }
public PathSearch(World world, MobileInfo mobileInfo, Actor self) { this.world = world; cellInfo = InitCellInfo(); this.mobileInfo = mobileInfo; this.self = self; customCost = null; queue = new PriorityQueue <PathDistance>(); considered = new HashSet <CPos>(); maxCost = 0; nextDirections = directions.Select(d => new Pair <CVec, int>(d, 0)).ToArray(); }
public void Dispose() { if (disposed) { return; } disposed = true; GC.SuppressFinalize(this); PutBackIntoPool(cellInfo); cellInfo = null; }
private void LoadMapType4() { try { int offset = 31; int w = BitConverter.ToInt16(Bytes, offset); offset += 2; int xor = BitConverter.ToInt16(Bytes, offset); offset += 2; int h = BitConverter.ToInt16(Bytes, offset); Width = w ^ xor; Height = h ^ xor; MapCells = new CellInfo[Width, Height]; offset = 64; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) {//12 MapCells[x, y] = new CellInfo(); MapCells[x, y].BackIndex = 0; MapCells[x, y].MiddleIndex = 1; MapCells[x, y].BackImage = (short)(BitConverter.ToInt16(Bytes, offset) ^ xor); offset += 2; MapCells[x, y].MiddleImage = (short)(BitConverter.ToInt16(Bytes, offset) ^ xor); offset += 2; MapCells[x, y].FrontImage = (short)(BitConverter.ToInt16(Bytes, offset) ^ xor); offset += 2; MapCells[x, y].DoorIndex = (byte)(Bytes[offset++] & 0x7F); MapCells[x, y].DoorOffset = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationTick = Bytes[offset++]; MapCells[x, y].FrontIndex = (short)(Bytes[offset++] + 2); MapCells[x, y].Light = Bytes[offset++]; if ((MapCells[x, y].BackImage & 0x8000) != 0) { MapCells[x, y].BackImage = (MapCells[x, y].BackImage & 0x7FFF) | 0x20000000; } if (MapCells[x, y].Light >= 100 && MapCells[x, y].Light <= 119) { MapCells[x, y].FishingCell = true; } } } } catch (Exception ex) { if (Settings.LogErrors) { CMain.SaveError(ex.ToString()); } } }
public void SaveGridState(Cell[,] cells1) { cells = new CellInfo[cells1.GetLength(0), cells1.GetLength(1)]; for (int x = 0; x < cells1.GetLength(0); x++) { for (int y = 0; y < cells1.GetLength(1); y++) { cells[x, y].isFree = cells1[x, y].IsFree(); cells[x, y].cubeIndex = cells1[x, y].cubeIndex; } } }
public PathSearch(World world, MobileInfo mobileInfo, Actor self) { this.world = world; cellInfo = InitCellInfo(); this.mobileInfo = mobileInfo; this.self = self; customCost = null; queue = new PriorityQueue<PathDistance>(); considered = new HashSet<CPos>(); maxCost = 0; nextDirections = directions.Select(d => new Pair<CVec, int>(d, 0)).ToArray(); }
private void LoadMapType7() { try { int offset = 21; Width = BitConverter.ToInt16(Bytes, offset); offset += 4; Height = BitConverter.ToInt16(Bytes, offset); MapCells = new CellInfo[Width, Height]; offset = 54; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) {//total 15 MapCells[x, y] = new CellInfo { BackIndex = 0, BackImage = (int)BitConverter.ToInt32(Bytes, offset), MiddleIndex = 1, MiddleImage = (short)BitConverter.ToInt16(Bytes, offset += 4), FrontImage = (short)BitConverter.ToInt16(Bytes, offset += 2), DoorIndex = (byte)(Bytes[offset += 2] & 0x7F), DoorOffset = Bytes[++offset], FrontAnimationFrame = Bytes[++offset], FrontAnimationTick = Bytes[++offset], FrontIndex = (short)(Bytes[++offset] + 2), Light = Bytes[++offset], Unknown = Bytes[++offset], }; if ((MapCells[x, y].BackImage & 0x8000) != 0) { MapCells[x, y].BackImage = (MapCells[x, y].BackImage & 0x7FFF) | 0x20000000; } offset++; if (MapCells[x, y].Light >= 100 && MapCells[x, y].Light <= 119) { MapCells[x, y].FishingCell = true; } } } } catch (Exception ex) { if (Settings.LogErrors) { CMain.SaveError(ex.ToString()); } } }
public FieldData(int fieldWidth, int fieldHeight, float lockedRatio) { cells = new CellInfo[fieldWidth, fieldHeight]; for (int x = 0; x < fieldWidth; ++x) { for (int y = 0; y < fieldHeight; ++y) { cells[x, y] = new CellInfo { state = (Random.value < lockedRatio) ? CellState.Locked : CellState.Free }; } } }
private void LoadMapType3() { try { int offset = 0; Width = BitConverter.ToInt16(Bytes, offset); offset += 2; Height = BitConverter.ToInt16(Bytes, offset); MapCells = new CellInfo[Width, Height]; offset = 52; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) {//36 MapCells[x, y] = new CellInfo(); MapCells[x, y].BackImage = BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].MiddleImage = BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].FrontImage = BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].DoorIndex = Bytes[offset++]; MapCells[x, y].DoorOffset = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationTick = Bytes[offset++]; MapCells[x, y].FrontIndex = (short)(Bytes[offset++] + 120); MapCells[x, y].Light = Bytes[offset++]; MapCells[x, y].BackIndex = (short)(Bytes[offset++] + 100); MapCells[x, y].MiddleIndex = (short)(Bytes[offset++] + 110); MapCells[x, y].TileAnimationImage = BitConverter.ToInt16(Bytes, offset); offset += 7;//2bytes from tileanimframe, 2 bytes always blank?, 2bytes potentialy 'backtiles index', 1byte fileindex for the backtiles? MapCells[x, y].TileAnimationFrames = Bytes[offset++]; MapCells[x, y].TileAnimationOffset = BitConverter.ToInt16(Bytes, offset); offset += 14; //tons of light, blending, .. related options i hope if ((MapCells[x, y].BackImage & 0x8000) != 0) { MapCells[x, y].BackImage = (MapCells[x, y].BackImage & 0x7FFF) | 0x20000000; } if (MapCells[x, y].Light == 100 || MapCells[x, y].Light == 101) { MapCells[x, y].FishingCell = true; } } } } catch (Exception ex) { // if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
private void LoadMapType2() { try { int offset = 0; Width = BitConverter.ToInt16(Bytes, offset); offset += 2; Height = BitConverter.ToInt16(Bytes, offset); MapCells = new CellInfo[Width, Height]; offset = 52; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) {//14 MapCells[x, y] = new CellInfo(); MapCells[x, y].BackImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].MiddleImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].FrontImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].DoorIndex = Bytes[offset++]; MapCells[x, y].DoorOffset = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationTick = Bytes[offset++]; MapCells[x, y].FrontIndex = (short)(Bytes[offset++] + 120); MapCells[x, y].Light = Bytes[offset++]; MapCells[x, y].BackIndex = (short)(Bytes[offset++] + 100); MapCells[x, y].MiddleIndex = (short)(Bytes[offset++] + 110); if ((MapCells[x, y].BackImage & 0x8000) != 0) { MapCells[x, y].BackImage = (MapCells[x, y].BackImage & 0x7FFF) | 0x20000000; } if (MapCells[x, y].Light == 100 || MapCells[x, y].Light == 101) { MapCells[x, y].FishingCell = true; } } } } catch (Exception ex) { if (Settings.LogErrors) { CMain.SaveError(ex.ToString()); } } }
// Start is called before the first frame update private void Start() { m_GridWidth = GetComponent <GridCreator>().GridWidth; m_GridHeight = GetComponent <GridCreator>().GridHeight; Cells = GetComponentsInChildren <CellInfo>().ToList(); CellsArray = new CellInfo[m_GridWidth, m_GridHeight]; foreach (CellInfo cell in Cells) { CellsArray[cell.X, cell.Y] = cell; cell.InitCell(SelectCell); } }
static List <CPos> MakePath(CellInfo[,] cellInfo, CPos destination) { var ret = new List <CPos>(); CPos pathNode = destination; while (cellInfo[pathNode.X, pathNode.Y].Path != pathNode) { ret.Add(pathNode); pathNode = cellInfo[pathNode.X, pathNode.Y].Path; } ret.Add(pathNode); CheckSanePath(ret); return(ret); }
static List <int2> MakePath(CellInfo[ , ] cellInfo, int2 destination) { List <int2> ret = new List <int2>(); int2 pathNode = destination; while (cellInfo[pathNode.X, pathNode.Y].Path != pathNode) { ret.Add(pathNode); pathNode = cellInfo[pathNode.X, pathNode.Y].Path; } ret.Add(pathNode); CheckSanePath(ret); return(ret); }
public override void _Ready() { _map = (TileMap)FindNode("TileMap"); var cellPositions = _map.GetUsedCells().OfType <Vector2>() .Select(t => new Point((int)t.x, (int)t.y)) .ToArray(); var minX = cellPositions.Min(t => t.X); var maxX = cellPositions.Max(t => t.X); var minY = cellPositions.Min(t => t.Y); var maxY = cellPositions.Max(t => t.Y); _grid = new CellInfo[maxX - minX + 1, maxY - minY + 1]; for (int x = 0; x < _grid.GetLength(0); x++) { for (int y = 0; y < _grid.GetLength(1); y++) { _grid[x, y] = new CellInfo { CellType = CellTypes.Empty, HasFire = false, Heat = 0 }; } } foreach (var cellPos in cellPositions) { var p = new Point(cellPos.X - minX, cellPos.Y - minY); _grid[p.X, p.Y].LocalCoords = cellPos; _grid[p.X, p.Y].CellType = (CellTypes)_map.GetCell(cellPos.X, cellPos.Y); _grid[p.X, p.Y].WorldCoords = _map.MapToWorld(cellPos.ToVector()) + new Vector2(0, _map.CellSize.y / 2); _grid[p.X, p.Y].GridCoords = p; if (_grid[p.X, p.Y].CellType == CellTypes.Heater) { _grid[p.X, p.Y].Heat = 100; } } _player = (AudioStreamPlayer)FindNode("FireSound"); _player.Play(); }
private static void ApplyVerticalMerges(CellInfo[,] cellInfos) { for (int r = 0; r < cellInfos.GetLength(0); r++) { for (int c = 0; c < cellInfos.GetLength(1); c++) { var cellInfo = cellInfos[r, c]; var vmerge = cellInfo.XmlCell?.Descendants().FirstOrDefault(d => d.Name.LocalName == "vmerge"); if (vmerge != null) { var isParent = (vmerge.Attributes().FirstOrDefault(a => a.Name.LocalName == "val")?.Value ?? string.Empty) == "restart"; if (isParent) { MarkCellsBelow(cellInfos, r, c); } } } } }
private static void MarkCellsBelow(CellInfo[,] cells, int parentR, int parentC) { var parentCell = cells[parentR, parentC]; for (int r = parentR + 1; r < cells.GetLength(1); r++) { var cell = cells[r, parentC]; var vmerge = cell.XmlCell?.Descendants().FirstOrDefault(d => d.Name.LocalName == "vmerge"); if (vmerge == null) { break; } var isParent = (vmerge?.Attributes().FirstOrDefault(a => a.Name.LocalName == "val")?.Value ?? string.Empty) == "restart"; if (isParent) { break; } cell.MergedVerticallyWith = parentCell.XmlCell; } }
public void setup() { /* Initial generation of the board where all cells are dead */ board = new CellInfo[sizeX, sizeY]; timer = 0; for (int i = 0; i < sizeX; i++) { for (int j = 0; j < sizeY; j++) { board[i, j] = new CellInfo(); board[i, j].setLocation(new Vector2(i, j)); board[i, j].setup(cellPrefab); } } for (int i = 0; i < sizeX; i++) { for (int j = 0; j < sizeY; j++) { board[i, j].setNeighbours(genNeighbourList(i, j)); } } }
/// <summary> /// Initializes this instance from a table. /// </summary> private void Init(Table table) { Table = table; RowCount = Table.Rows.Count; ColCount = Table.Columns.Count; CellIndex = new Hashtable(); CellInfos = new CellInfo[RowCount, ColCount]; for (int rwIdx = 0; rwIdx < RowCount; rwIdx++) { for (int clmIdx = 0; clmIdx < ColCount; clmIdx++) { Cell cell = table[rwIdx, clmIdx]; if (CellInfos[rwIdx, clmIdx] == null) { for (int mx = 0; mx <= cell.MergeRight; mx++) { for (int my = 0; my <= cell.MergeDown; my++) { bool isMergedCell = mx > 0 || my > 0; CellInfo cellInfo = new CellInfo(); cellInfo.TableCell = table[rwIdx + my, clmIdx + mx]; cellInfo.Cell = cell; cellInfo.IsMergedCell = isMergedCell; cellInfo.MergedWith = isMergedCell ? CellInfos[rwIdx, clmIdx] : null; cellInfo.Row = rwIdx; cellInfo.Col = clmIdx; CellInfos[rwIdx + my, clmIdx + mx] = cellInfo; CellIndex[cellInfo.TableCell] = CellInfos[rwIdx, clmIdx]; } } } } } }
private void initiate() { if (File.Exists(FileName)) { Bytes = File.ReadAllBytes(FileName); } else { Width = 1000; Height = 1000; MapCells = new CellInfo[Width, Height]; for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) { MapCells[x, y] = new CellInfo(); } return; } //c# custom map format if ((Bytes[2] == 0x43) && (Bytes[3] == 0x23)) { LoadMapType100(); return; } //wemade mir3 maps have no title they just start with blank bytes if (Bytes[0] == 0) { LoadMapType5(); return; } //shanda mir3 maps start with title: (C) SNDA, MIR3. if ((Bytes[0] == 0x0F) && (Bytes[5] == 0x53) && (Bytes[14] == 0x33)) { LoadMapType6(); return; } //wemades antihack map (laby maps) title start with: Mir2 AntiHack if ((Bytes[0] == 0x15) && (Bytes[4] == 0x32) && (Bytes[6] == 0x41) && (Bytes[19] == 0x31)) { LoadMapType4(); return; } //wemades 2010 map format i guess title starts with: Map 2010 Ver 1.0 if ((Bytes[0] == 0x10) && (Bytes[2] == 0x61) && (Bytes[7] == 0x31) && (Bytes[14] == 0x31)) { LoadMapType1(); return; } //shanda's 2012 format and one of shandas(wemades) older formats share same header info, only difference is the filesize if ((Bytes[4] == 0x0F) || (Bytes[4] == 0x03) && (Bytes[18] == 0x0D) && (Bytes[19] == 0x0A)) { int W = Bytes[0] + (Bytes[1] << 8); int H = Bytes[2] + (Bytes[3] << 8); if (Bytes.Length > (52 + (W*H*14))) { LoadMapType3(); return; } else { LoadMapType2(); return; } } //3/4 heroes map format (myth/lifcos i guess) if ((Bytes[0] == 0x0D) && (Bytes[1] == 0x4C) && (Bytes[7] == 0x20) && (Bytes[11] == 0x6D)) { LoadMapType7(); return; } //if it's none of the above load the default old school format LoadMapType0(); }
protected override void Dispose(bool disposing) { if (disposing) { Objects.Clear(); MapButtons = 0; MouseLocation = Point.Empty; InputDelay = 0; NextAction = 0; M2CellInfo = null; Width = 0; Height = 0; FileName = String.Empty; Title = String.Empty; MiniMap = 0; BigMap = 0; Lights = 0; FloorValid = false; LightsValid = false; MapDarkLight = 0; Music = 0; if (_floorSurface != null && !_floorSurface.Disposed) _floorSurface.Dispose(); if (_lightSurface != null && !_lightSurface.Disposed) _lightSurface.Dispose(); AnimationCount = 0; Effects.Clear(); } base.Dispose(disposing); }
public void LoadMap() { GameScene.Scene.NPCDialog.Hide(); Objects.Clear(); Effects.Clear(); if (User != null) Objects.Add(User); MapObject.MouseObject = null; MapObject.TargetObject = null; MapObject.MagicObject = null; MapReader Map = new MapReader(FileName); M2CellInfo = Map.MapCells; Width = Map.Width; Height = Map.Height; try { if (SetMusic != Music) { SoundManager.Device.Dispose(); SoundManager.Create(); SoundManager.PlayMusic(Music, true); } } catch (Exception) { // Do nothing. index was not valid. } SetMusic = Music; SoundList.Music = Music; }
public void LoadMap() { GameScene.Scene.NPCDialog.Hide(); Objects.Clear(); Effects.Clear(); if (User != null) Objects.Add(User); MapObject.MouseObject = null; MapObject.TargetObject = null; MapObject.MagicObject = null; MapReader Map = new MapReader(FileName); M2CellInfo = Map.MapCells; Width = Map.Width; Height = Map.Height; }
private void LoadMapType100() { try { int offset = 4; if ((Bytes[0] != 1) || (Bytes[1] != 0)) { return; //only support version 1 atm } Width = BitConverter.ToInt16(Bytes, offset); offset += 2; Height = BitConverter.ToInt16(Bytes, offset); MapCells = new CellInfo[Width, Height]; offset = 8; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { MapCells[x, y] = new CellInfo(); MapCells[x, y].BackIndex = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; //-------------------------------------------------------------------------- //old //MapCells[x, y].BackImage = (short)BitConverter.ToInt16(Bytes, offset); //new MapCells[x, y].BackImage = BitConverter.ToInt32(Bytes, offset); //---------------------------------------------------------------------------- offset += 4; MapCells[x, y].MiddleIndex = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].MiddleImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].FrontIndex = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].FrontImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].DoorIndex = Bytes[offset++]; MapCells[x, y].DoorOffset = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationTick = Bytes[offset++]; MapCells[x, y].MiddleAnimationFrame = Bytes[offset++]; MapCells[x, y].MiddleAnimationTick = Bytes[offset++]; MapCells[x, y].TileAnimationImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].TileAnimationOffset = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].TileAnimationFrames = Bytes[offset++]; MapCells[x, y].Light = Bytes[offset++]; if (MapCells[x, y].Light == 100 || MapCells[x, y].Light == 101) { MapCells[x, y].FishingCell = true; } } } } catch (Exception) { //if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
private void LoadMapType5() { try { byte flag = 0; int offset = 20; short Attribute = (short)(BitConverter.ToInt16(Bytes, offset)); Width = (int)(BitConverter.ToInt16(Bytes, offset += 2)); Height = (int)(BitConverter.ToInt16(Bytes, offset += 2)); //ignoring eventfile and fogcolor for now (seems unused in maps i checked) offset = 28; //initiate all cells MapCells = new CellInfo[Width, Height]; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { MapCells[x, y] = new CellInfo(); } } //read all back tiles for (int x = 0; x < (Width / 2); x++) { for (int y = 0; y < (Height / 2); y++) { for (int i = 0; i < 4; i++) { MapCells[(x * 2) + (i % 2), (y * 2) + (i / 2)].BackIndex = (short)(Bytes[offset] != 255 ? Bytes[offset] + 200 : -1); MapCells[(x * 2) + (i % 2), (y * 2) + (i / 2)].BackImage = (int)(BitConverter.ToUInt16(Bytes, offset + 1) + 1); } offset += 3; } } //read rest of data offset = 28 + (3 * ((Width / 2) + (Width % 2)) * (Height / 2)); for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { flag = Bytes[offset++]; MapCells[x, y].MiddleAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset] == 255 ? (byte)0 : Bytes[offset]; MapCells[x, y].FrontAnimationFrame &= 0x8F; offset++; MapCells[x, y].MiddleAnimationTick = 0; MapCells[x, y].FrontAnimationTick = 0; MapCells[x, y].FrontIndex = (short)(Bytes[offset] != 255 ? Bytes[offset] + 200 : -1); offset++; MapCells[x, y].MiddleIndex = (short)(Bytes[offset] != 255 ? Bytes[offset] + 200 : -1); offset++; MapCells[x, y].MiddleImage = (ushort)(BitConverter.ToUInt16(Bytes, offset) + 1); offset += 2; MapCells[x, y].FrontImage = (ushort)(BitConverter.ToUInt16(Bytes, offset) + 1); if ((MapCells[x, y].FrontImage == 1) && (MapCells[x, y].FrontIndex == 200)) { MapCells[x, y].FrontIndex = -1; } offset += 2; offset += 3;//mir3 maps dont have doors so dont bother reading the info MapCells[x, y].Light = (byte)(Bytes[offset] & 0x0F); offset += 2; if ((flag & 0x01) != 1) { MapCells[x, y].BackImage |= 0x20000000; } if ((flag & 0x02) != 2) { MapCells[x, y].FrontImage = (ushort)((UInt16)MapCells[x, y].FrontImage | 0x8000); } if (MapCells[x, y].Light >= 100 && MapCells[x, y].Light <= 119) { MapCells[x, y].FishingCell = true; } else { MapCells[x, y].Light *= 2;//expand general mir3 lighting as default range is small. Might break new colour lights. } } } } catch (Exception ex) { // if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
private void LoadMapType4() { try { int offset = 31; int w = BitConverter.ToInt16(Bytes, offset); offset += 2; int xor = BitConverter.ToInt16(Bytes, offset); offset += 2; int h = BitConverter.ToInt16(Bytes, offset); Width = w ^ xor; Height = h ^ xor; MapCells = new CellInfo[Width, Height]; offset = 64; for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) {//12 MapCells[x, y] = new CellInfo(); MapCells[x, y].BackIndex = 0; MapCells[x, y].MiddleIndex = 1; MapCells[x, y].BackImage = (short)(BitConverter.ToInt16(Bytes, offset) ^ xor); offset += 2; MapCells[x, y].MiddleImage = (short)(BitConverter.ToInt16(Bytes, offset) ^ xor); offset += 2; MapCells[x, y].FrontImage = (short)(BitConverter.ToInt16(Bytes, offset) ^xor); offset += 2; MapCells[x, y].DoorIndex = Bytes[offset++]; MapCells[x, y].DoorOffset = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationTick = Bytes[offset++]; MapCells[x, y].FrontIndex = (short)(Bytes[offset++] + 2); MapCells[x, y].Light = Bytes[offset++]; if ((MapCells[x, y].BackImage & 0x8000) != 0) MapCells[x, y].BackImage = (MapCells[x, y].BackImage & 0x7FFF) | 0x20000000; if (MapCells[x, y].Light >= 100 && MapCells[x, y].Light <= 119) MapCells[x, y].FishingCell = true; } } catch (Exception ex) { if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
private void LoadMapType2() { try { int offset = 0; Width = BitConverter.ToInt16(Bytes, offset); offset += 2; Height = BitConverter.ToInt16(Bytes, offset); MapCells = new CellInfo[Width, Height]; offset = 52; for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) {//14 MapCells[x, y] = new CellInfo(); MapCells[x, y].BackImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].MiddleImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].FrontImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].DoorIndex = Bytes[offset++]; MapCells[x, y].DoorOffset = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationTick = Bytes[offset++]; MapCells[x, y].FrontIndex = (short)(Bytes[offset++] + 120); MapCells[x, y].Light = Bytes[offset++]; MapCells[x, y].BackIndex = (short)(Bytes[offset++] + 100); MapCells[x, y].MiddleIndex = (short)(Bytes[offset++] + 110); if ((MapCells[x, y].BackImage & 0x8000) != 0) MapCells[x, y].BackImage = (MapCells[x, y].BackImage & 0x7FFF) | 0x20000000; if (MapCells[x, y].Light == 100 || MapCells[x, y].Light == 101) MapCells[x, y].FishingCell = true; } } catch (Exception ex) { if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
public CellInfo2DArray(CellInfo[,] array) : base(array) { }
private void LoadMapType6() { try { byte flag = 0; int offset = 16; Width = BitConverter.ToInt16(Bytes, offset); offset += 2; Height = BitConverter.ToInt16(Bytes, offset); MapCells = new CellInfo[Width, Height]; offset = 40; for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) { MapCells[x, y] = new CellInfo(); flag = Bytes[offset++]; MapCells[x,y].BackIndex = (short)(Bytes[offset] != 255 ? Bytes[offset]+ 300 : -1); offset++; MapCells[x, y].MiddleIndex = (short)(Bytes[offset] != 255 ? Bytes[offset] + 300 : -1); offset++; MapCells[x, y].FrontIndex = (short)(Bytes[offset] != 255 ? Bytes[offset] + 300 : -1); offset++; MapCells[x, y].BackImage = (short)(BitConverter.ToInt16(Bytes, offset) + 1); offset += 2; MapCells[x, y].MiddleImage = (short)(BitConverter.ToInt16(Bytes, offset) + 1); offset += 2; MapCells[x, y].FrontImage = (short)(BitConverter.ToInt16(Bytes, offset) + 1); offset += 2; if ((MapCells[x, y].FrontImage == 1) && (MapCells[x, y].FrontIndex == 200)) MapCells[x, y].FrontIndex = -1; MapCells[x, y].MiddleAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset] == 255 ? (byte)0 : Bytes[offset]; if (MapCells[x, y].FrontAnimationFrame > 0x0F)//assuming shanda used same value not sure MapCells[x, y].FrontAnimationFrame = (byte)(/*0x80 ^*/ (MapCells[x, y].FrontAnimationFrame & 0x0F)); offset++; MapCells[x, y].MiddleAnimationTick = 1; MapCells[x, y].FrontAnimationTick = 1; MapCells[x, y].Light = (byte)(Bytes[offset] & 0x0F); MapCells[x, y].Light *= 4;//far wants all light on mir3 maps to be maxed :p offset += 8; if ((flag & 0x01) != 1) MapCells[x, y].BackImage |= 0x20000000; if ((flag & 0x02) != 2) MapCells[x, y].FrontImage = (short)((UInt16)MapCells[x, y].FrontImage | 0x8000); } } catch (Exception ex) { if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
public void Dispose() { if (disposed) return; disposed = true; GC.SuppressFinalize(this); PutBackIntoPool(cellInfo); cellInfo = null; }
private void initiate() { if (File.Exists(FileName)) { Bytes = File.ReadAllBytes(FileName); } else { Width = 1000; Height = 1000; MapCells = new CellInfo[Width, Height]; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { MapCells[x, y] = new CellInfo(); } } return; } //c# custom map format if ((Bytes[2] == 0x43) && (Bytes[3] == 0x23)) { LoadMapType100(); return; } //wemade mir3 maps have no title they just start with blank bytes if (Bytes[0] == 0) { LoadMapType5(); return; } //shanda mir3 maps start with title: (C) SNDA, MIR3. if ((Bytes[0] == 0x0F) && (Bytes[5] == 0x53) && (Bytes[14] == 0x33)) { LoadMapType6(); return; } //wemades antihack map (laby maps) title start with: Mir2 AntiHack if ((Bytes[0] == 0x15) && (Bytes[4] == 0x32) && (Bytes[6] == 0x41) && (Bytes[19] == 0x31)) { LoadMapType4(); return; } //wemades 2010 map format i guess title starts with: Map 2010 Ver 1.0 if ((Bytes[0] == 0x10) && (Bytes[2] == 0x61) && (Bytes[7] == 0x31) && (Bytes[14] == 0x31)) { LoadMapType1(); return; } //shanda's 2012 format and one of shandas(wemades) older formats share same header info, only difference is the filesize if ((Bytes[4] == 0x0F) && (Bytes[18] == 0x0D) && (Bytes[19] == 0x0A)) { int W = Bytes[0] + (Bytes[1] << 8); int H = Bytes[2] + (Bytes[3] << 8); if (Bytes.Length > (52 + (W * H * 14))) { LoadMapType3(); return; } else { LoadMapType2(); return; } } //3/4 heroes map format (myth/lifcos i guess) if ((Bytes[0] == 0x0D) && (Bytes[1] == 0x4C) && (Bytes[7] == 0x20) && (Bytes[11] == 0x6D)) { LoadMapType7(); return; } //if it's none of the above load the default old school format LoadMapType0(); }
private void LoadMapType1() { try { int offSet = 21; int w = BitConverter.ToInt16(Bytes, offSet); offSet += 2; int xor = BitConverter.ToInt16(Bytes, offSet); offSet += 2; int h = BitConverter.ToInt16(Bytes, offSet); Width = w ^ xor; Height = h ^ xor; MapCells = new CellInfo[Width, Height]; offSet = 54; for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) { MapCells[x, y] = new CellInfo { BackIndex = 0, BackImage = (int)(BitConverter.ToInt32(Bytes, offSet) ^ 0xAA38AA38), MiddleIndex = 1, MiddleImage = (short)(BitConverter.ToInt16(Bytes, offSet += 4) ^ xor), FrontImage = (short)(BitConverter.ToInt16(Bytes, offSet += 2) ^ xor), DoorIndex = Bytes[offSet += 2], DoorOffset = Bytes[++offSet], FrontAnimationFrame = Bytes[++offSet], FrontAnimationTick = Bytes[++offSet], FrontIndex = (short)(Bytes[++offSet] + 2), Light = Bytes[++offSet], Unknown = Bytes[++offSet], }; offSet++; if (MapCells[x, y].Light >= 100 && MapCells[x, y].Light <= 119) MapCells[x, y].FishingCell = true; } } catch (Exception ex) { if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
private void LoadMapType6() { try { byte flag = 0; int offset = 16; Width = BitConverter.ToInt16(Bytes, offset); offset += 2; Height = BitConverter.ToInt16(Bytes, offset); MapCells = new CellInfo[Width, Height]; offset = 40; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { MapCells[x, y] = new CellInfo(); flag = Bytes[offset++]; MapCells[x, y].BackIndex = (short)(Bytes[offset] != 255 ? Bytes[offset] + 300 : -1); offset++; MapCells[x, y].MiddleIndex = (short)(Bytes[offset] != 255 ? Bytes[offset] + 300 : -1); offset++; MapCells[x, y].FrontIndex = (short)(Bytes[offset] != 255 ? Bytes[offset] + 300 : -1); offset++; MapCells[x, y].BackImage = (short)(BitConverter.ToInt16(Bytes, offset) + 1); offset += 2; MapCells[x, y].MiddleImage = (short)(BitConverter.ToInt16(Bytes, offset) + 1); offset += 2; MapCells[x, y].FrontImage = (short)(BitConverter.ToInt16(Bytes, offset) + 1); offset += 2; if ((MapCells[x, y].FrontImage == 1) && (MapCells[x, y].FrontIndex == 200)) { MapCells[x, y].FrontIndex = -1; } MapCells[x, y].MiddleAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset] == 255 ? (byte)0 : Bytes[offset]; if (MapCells[x, y].FrontAnimationFrame > 0x0F)//assuming shanda used same value not sure { MapCells[x, y].FrontAnimationFrame = (byte)(/*0x80 ^*/ (MapCells[x, y].FrontAnimationFrame & 0x0F)); } offset++; MapCells[x, y].MiddleAnimationTick = 1; MapCells[x, y].FrontAnimationTick = 1; MapCells[x, y].Light = (byte)(Bytes[offset] & 0x0F); MapCells[x, y].Light *= 4;//far wants all light on mir3 maps to be maxed :p offset += 8; if ((flag & 0x01) != 1) { MapCells[x, y].BackImage |= 0x20000000; } if ((flag & 0x02) != 2) { MapCells[x, y].FrontImage = (short)((UInt16)MapCells[x, y].FrontImage | 0x8000); } //Aka: fix errors in shanda mir3 1.map and others where a blue water tile will appear on top of everything if (MapCells[x, y].FrontIndex == 300) { MapCells[x, y].FrontIndex = -1; } } } } catch (Exception ex) { //if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
private void LoadMapType3() { try { int offset = 0; Width = BitConverter.ToInt16(Bytes, offset); offset += 2; Height = BitConverter.ToInt16(Bytes, offset); MapCells = new CellInfo[Width, Height]; offset = 52; for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) {//36 MapCells[x, y] = new CellInfo(); MapCells[x, y].BackImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].MiddleImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].FrontImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].DoorIndex = Bytes[offset++]; MapCells[x, y].DoorOffset = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationTick = Bytes[offset++]; MapCells[x, y].FrontIndex = (short)(Bytes[offset++] + 120); MapCells[x, y].Light = Bytes[offset++]; MapCells[x, y].BackIndex = (short)(Bytes[offset++] + 100); MapCells[x, y].MiddleIndex = (short)(Bytes[offset++] + 110); MapCells[x, y].TileAnimationImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 7;//2bytes from tileanimframe, 2 bytes always blank?, 2bytes potentialy 'backtiles index', 1byte fileindex for the backtiles? MapCells[x, y].TileAnimationFrames = Bytes[offset++]; MapCells[x, y].TileAnimationOffset = (short)BitConverter.ToInt16(Bytes, offset); offset += 14; //tons of light, blending, .. related options i hope if ((MapCells[x, y].BackImage & 0x8000) != 0) MapCells[x, y].BackImage = (MapCells[x, y].BackImage & 0x7FFF) | 0x20000000; if (MapCells[x, y].Light >= 100 && MapCells[x, y].Light <= 119) MapCells[x, y].FishingCell = true; } } catch (Exception ex) { if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
private void initiate() { if (File.Exists(FileName)) { Bytes = File.ReadAllBytes(FileName); } else { Width = 1000; Height = 1000; MapCells = new CellInfo[Width, Height]; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { MapCells[x, y] = new CellInfo(); } } return; } //c# custom map format if ((Bytes[2] == 0x43) && (Bytes[3] == 0x23)) { LoadMapType100(); //MessageBox.Show("MapType100"); MapType = "100"; return; } //wemade mir3 maps have no title they just start with blank bytes if (Bytes[0] == 0) { LoadMapType5(); //MessageBox.Show("MapType5"); MapType = "5"; return; } //shanda mir3 maps start with title: (C) SNDA, MIR3. if ((Bytes[0] == 0x0F) && (Bytes[5] == 0x53) && (Bytes[14] == 0x33)) { LoadMapType6(); //MessageBox.Show("MapType6"); MapType = "6"; return; } //wemades antihack map (laby maps) title start with: Mir2 AntiHack if ((Bytes[0] == 0x15) && (Bytes[4] == 0x32) && (Bytes[6] == 0x41) && (Bytes[19] == 0x31)) { LoadMapType4(); //MessageBox.Show("MapType4"); MapType = "4"; return; } //wemades 2010 map format i guess title starts with: Map 2010 Ver 1.0 if ((Bytes[0] == 0x10) && (Bytes[2] == 0x61) && (Bytes[7] == 0x31) && (Bytes[14] == 0x31)) { LoadMapType1(); //MessageBox.Show("MapType1"); MapType = "1"; return; } //shanda's 2012 format and one of shandas(wemades) older formats share same header info, only difference is the filesize if ((Bytes[4] == 0x0F) || (Bytes[4] == 0x03) && (Bytes[18] == 0x0D) && (Bytes[19] == 0x0A)) { int W = Bytes[0] + (Bytes[1] << 8); int H = Bytes[2] + (Bytes[3] << 8); if (Bytes.Length > (52 + (W * H * 14))) { LoadMapType3(); //MessageBox.Show("MapType3"); MapType = "3"; return; } LoadMapType2(); //MessageBox.Show("MapType2"); MapType = "2"; return; } //Aka: added to load shanda 0.map & 3~1.map which was loading as MapType0 // not sure if any other MapType would be more suitable but this works :) if ((Bytes[4] == 0x0D) && (Bytes[5] == 0x4C) && (Bytes[6] == 0x65)) { //load default for now LoadMapType8(); //MessageBox.Show("MapType8"); MapType = "8"; return; } //3/4 heroes map format (myth/lifcos i guess) if ((Bytes[0] == 0x0D) && (Bytes[1] == 0x4C) && (Bytes[7] == 0x20) && (Bytes[11] == 0x6D)) { LoadMapType7(); //MessageBox.Show("MapType7"); MapType = "7"; return; } //if it's none of the above load the default old school format LoadMapType0(); //MessageBox.Show("MapType0"); MapType = "0"; }
private void LoadMapType5() { try { byte flag = 0; int offset = 20; short Attribute = (short)(BitConverter.ToInt16(Bytes,offset)); Width = (int)(BitConverter.ToInt16(Bytes,offset+=2)); Height = (int)(BitConverter.ToInt16(Bytes, offset += 2)); //ignoring eventfile and fogcolor for now (seems unused in maps i checked) offset = 28; //initiate all cells MapCells = new CellInfo[Width, Height]; for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) MapCells[x, y] = new CellInfo(); //read all back tiles for (int x = 0; x < (Width/2); x++) for (int y = 0; y < (Height/2); y++) { for (int i = 0; i < 4; i++) { MapCells[(x * 2) + (i % 2), (y * 2) + (i / 2)].BackIndex = (short)(Bytes[offset] != 255? Bytes[offset]+200 : -1); MapCells[(x*2) + (i % 2), (y*2) + (i / 2)].BackImage = (int)(BitConverter.ToUInt16(Bytes, offset + 1)+1); } offset += 3; } //read rest of data offset = 28 + (3 * ((Width /2) + (Width %2)) * (Height / 2)); for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) { flag = Bytes[offset++]; MapCells[x, y].MiddleAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset] == 255? (byte)0 : Bytes[offset]; MapCells[x, y].FrontAnimationFrame &= 0x8F; offset++; MapCells[x, y].MiddleAnimationTick = 0; MapCells[x, y].FrontAnimationTick = 0; MapCells[x,y].FrontIndex = (short)(Bytes[offset] != 255 ? Bytes[offset] + 200 : -1); offset++; MapCells[x,y].MiddleIndex = (short)(Bytes[offset] != 255 ? Bytes[offset] + 200 : -1); offset++; MapCells[x,y].MiddleImage = (ushort)(BitConverter.ToUInt16(Bytes,offset)+1); offset += 2; MapCells[x, y].FrontImage = (ushort)(BitConverter.ToUInt16(Bytes, offset)+1); if ((MapCells[x, y].FrontImage == 1) && (MapCells[x, y].FrontIndex == 200)) MapCells[x, y].FrontIndex = -1; offset += 2; offset += 3;//mir3 maps dont have doors so dont bother reading the info MapCells[x, y].Light = (byte)(Bytes[offset] & 0x0F); offset += 2; if ((flag & 0x01) != 1) MapCells[x, y].BackImage |= 0x20000000; if ((flag & 0x02) != 2) MapCells[x, y].FrontImage = (ushort)((UInt16)MapCells[x, y].FrontImage | 0x8000); if (MapCells[x, y].Light >= 100 && MapCells[x, y].Light <= 119) MapCells[x, y].FishingCell = true; else MapCells[x, y].Light *= 2;//expand general mir3 lighting as default range is small. Might break new colour lights. } } catch (Exception ex) { if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
private void LoadMapType100() { try { int offset = 4; if ((Bytes[0]!= 1) || (Bytes[1] != 0)) return;//only support version 1 atm Width = BitConverter.ToInt16(Bytes, offset); offset += 2; Height = BitConverter.ToInt16(Bytes, offset); MapCells = new CellInfo[Width, Height]; offset = 8; for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) { MapCells[x, y] = new CellInfo(); MapCells[x, y].BackIndex = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].BackImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 4; MapCells[x, y].MiddleIndex = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].MiddleImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].FrontIndex = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].FrontImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].DoorIndex = Bytes[offset++]; MapCells[x, y].DoorOffset = Bytes[offset++]; MapCells[x, y].FrontAnimationFrame = Bytes[offset++]; MapCells[x, y].FrontAnimationTick = Bytes[offset++]; MapCells[x, y].MiddleAnimationFrame = Bytes[offset++]; MapCells[x, y].MiddleAnimationTick = Bytes[offset++]; MapCells[x, y].TileAnimationImage = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].TileAnimationOffset = (short)BitConverter.ToInt16(Bytes, offset); offset += 2; MapCells[x, y].TileAnimationFrames = Bytes[offset++]; MapCells[x, y].Light = Bytes[offset++]; if (MapCells[x, y].Light >= 100 && MapCells[x, y].Light <= 119) MapCells[x, y].FishingCell = true; } } catch (Exception ex) { if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
private void LoadMapType7() { try { int offset = 21; Width = BitConverter.ToInt16(Bytes, offset); offset += 4; Height = BitConverter.ToInt16(Bytes, offset); MapCells = new CellInfo[Width, Height]; offset = 54; for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) {//total 15 MapCells[x, y] = new CellInfo { BackIndex = 0, BackImage = (int)BitConverter.ToInt32(Bytes, offset), MiddleIndex = 1, MiddleImage = (short)BitConverter.ToInt16(Bytes, offset += 4), FrontImage = (short)BitConverter.ToInt16(Bytes, offset += 2), DoorIndex = Bytes[offset += 2], DoorOffset = Bytes[++offset], FrontAnimationFrame = Bytes[++offset], FrontAnimationTick = Bytes[++offset], FrontIndex = (short)(Bytes[++offset] + 2), Light = Bytes[++offset], Unknown = Bytes[++offset], }; if ((MapCells[x, y].BackImage & 0x8000) != 0) MapCells[x, y].BackImage = (MapCells[x, y].BackImage & 0x7FFF) | 0x20000000; offset++; if (MapCells[x, y].Light >= 100 && MapCells[x, y].Light <= 119) MapCells[x, y].FishingCell = true; } } catch (Exception ex) { if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
public void LoadMap() { GameScene.Scene.NPCDialog.Hide(); Objects.Clear(); Effects.Clear(); if (User != null) Objects.Add(User); MapObject.MouseObject = null; MapObject.TargetObject = null; MapObject.MagicObject = null; try { if (File.Exists(FileName)) { int offSet = 21; byte[] fileBytes = File.ReadAllBytes(FileName); int w = BitConverter.ToInt16(fileBytes, offSet); offSet += 2; int xor = BitConverter.ToInt16(fileBytes, offSet); offSet += 2; int h = BitConverter.ToInt16(fileBytes, offSet); Width = w ^ xor; Height = h ^ xor; M2CellInfo = new CellInfo[Width,Height]; offSet = 54; for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) { M2CellInfo[x, y] = new CellInfo { BackImage = (int) (BitConverter.ToInt32(fileBytes, offSet) ^ 0xAA38AA38), MiddleImage = (short) (BitConverter.ToInt16(fileBytes, offSet += 4) ^ xor), FrontImage = (short) (BitConverter.ToInt16(fileBytes, offSet += 2) ^ xor), DoorIndex = fileBytes[offSet += 2], DoorOffset = fileBytes[++offSet], AnimationFrame = fileBytes[++offSet], AnimationTick = fileBytes[++offSet], FileIndex = fileBytes[++offSet], Light = fileBytes[++offSet], Unknown = fileBytes[++offSet], }; offSet++; } } else { Width = 1000; Height = 1000; M2CellInfo = new CellInfo[Width,Height]; for (int x = 0; x < Width; x++) for (int y = 0; y < Height; y++) { M2CellInfo[x, y] = new CellInfo(); } } } catch (Exception ex) { if (Settings.LogErrors) CMain.SaveError(ex.ToString()); } }
private IEnumerator BuildWorldFromCellInfoCoroutine(CellInfo[,] cellInfos) { // voir https://docs.unity3d.com/ScriptReference/Tilemaps.Tilemap.SetTiles.html // créer arrays de tile ensuite call setTiles ? Vector3Int pos = new Vector3Int(0, 0, 0); m_totalTiles = cellInfos.GetLength(0) * cellInfos.GetLength(1); List <Tile> wallCells = new List <Tile>(); List <Tile> floorCells = new List <Tile>(); List <Tile> doorCells = new List <Tile>(); List <Tile> doorButtonCells = new List <Tile>(); List <Tile> playerSpawnCells = new List <Tile>(); List <Vector3Int> wallPos = new List <Vector3Int>(); List <Vector3Int> floorPos = new List <Vector3Int>(); List <Vector3Int> doorPos = new List <Vector3Int>(); List <Vector3Int> doorButtonPos = new List <Vector3Int>(); List <Vector3Int> playerSpawnPos = new List <Vector3Int>(); for (int x = 0; x < cellInfos.GetLength(0); x++) { for (int y = 0; y < cellInfos.GetLength(1); y++) { LogicCell cell = cellInfos[x, y].CellFromBytes(); pos.x = x; pos.y = y; if (cell is WallCell) { wallCells.Add(m_defaultWallTile); wallPos.Add(pos); } else if (cell is FloorCell) { floorCells.Add(m_defaultFloorTile); floorPos.Add(pos); } else if (cell is DoorCell) { doorCells.Add(m_defaultDoorTile); doorPos.Add(pos); } else if (cell is DoorButtonCell) { doorButtonCells.Add(m_defaultInteractableTile); doorButtonPos.Add(pos); } else if (cell is PlayerSpawnCell) { playerSpawnCells.Add(m_defaultPlayerSpawnTile); playerSpawnPos.Add(pos); } m_loadedTiles++; } yield return(null); } m_walls.SetTiles(wallPos.ToArray(), wallCells.ToArray()); m_floor.SetTiles(floorPos.ToArray(), floorCells.ToArray()); m_doors.SetTiles(doorPos.ToArray(), doorCells.ToArray()); m_interactable.SetTiles(doorButtonPos.ToArray(), doorButtonCells.ToArray()); m_playerSpawn.SetTiles(playerSpawnPos.ToArray(), playerSpawnCells.ToArray()); IsRebuilt = true; m_onWorldBuilt.Invoke(); }
static void PutBackIntoPool(CellInfo[,] ci) { lock (cellInfoPool) cellInfoPool.Enqueue(ci); }