public void ReadFromFile(BinaryReader reader) { if (reader.ReadInt16() != Magic) { return; } ushort animalInsCount = reader.ReadUInt16(); instances = new AnimalTrafficInstance[animalInsCount]; if (reader.ReadInt32() != Version) { return; } for (int i = 0; i < animalInsCount; i++) { AnimalTrafficInstance instance = new AnimalTrafficInstance(); instance.Name = new HashName(); instance.Name.ReadFromFile(reader); instances[i] = instance; } ushort pathCount = reader.ReadUInt16(); paths = new AnimalTrafficPath[pathCount]; for (int i = 0; i < pathCount; i++) { AnimalTrafficPath path = new AnimalTrafficPath(); byte pathSize = reader.ReadByte(); byte count1 = reader.ReadByte(); byte count2 = reader.ReadByte(); byte count3 = reader.ReadByte(); path.Data0 = reader.ReadBytes(count1); path.Data1 = reader.ReadBytes(count2); path.Data2 = reader.ReadBytes(count3); path.BoundingBox = BoundingBoxExtenders.ReadFromFile(reader); path.Hash = new HashName(); path.Hash.ReadFromFile(reader); //decompiled exe says this is a hash but its always empty path.Unk0 = reader.ReadSingle(); //5 path.Unk1 = reader.ReadSingle(); //15 path.Unk2 = reader.ReadByte(); //1 257 or 513. path.Unk3 = reader.ReadBytes(path.Unk2); path.Vectors = new PathVectors[pathSize]; for (int x = 0; x < pathSize; x++) { PathVectors vector = new PathVectors(); vector.Position = Vector3Utils.ReadFromFile(reader); //Very large differences between these two vector.Rotation = Vector3Utils.ReadFromFile(reader); //2nd one could be rotation, in radians. vector.Unk0 = reader.ReadByte(); //7 or 4 path.Vectors[x] = vector; } paths[i] = path; } }
private void MarkAsPath(int i, int j) { grids[i, j].GetComponent <Renderer>().material.color = pathColor; grids[i, j].GetComponent <GameGrid>().structure = structureType.PATH; grids[i, j].transform.position = new Vector3(grids[i, j].transform.position.x, grids[i, j].transform.position.y - 1, grids[i, j].transform.position.z); Vector3 trans = new Vector3(grids[i, j].transform.position.x, -1, grids[i, j].transform.position.y); PathVectors.Add(grids[i, j].transform.position); }
private void GeneratePath() { Debug.Log($"A tömb: {grids.GetLength(0)},{grids.GetLength(1)}"); int startX = 0, startY = 0; int endX = grids.GetLength(0) - 1, endY = grids.GetLength(1) - 1; Debug.Log($"startX: {startX}, startY: {startY}, endX: {endX}, endY: {endY}"); MarkAsPath(startX, startY); PathVectors.Add(new Vector3(startX, -1, startY)); int xDiff = (int)Mathf.Abs(startX - endX); int yDiff = (int)Mathf.Abs(endY - startY); int currentX = startX, currentY = startY; Debug.Log($"xDiff: {xDiff}, yDiff: {yDiff}"); Debug.Log($"currentX: {currentX}, currentY: {currentY}"); while ((currentX != endX) || (currentY != endY)) { int random = UnityEngine.Random.Range(0, 2); Debug.Log("Erre megy a random: " + random); if (random == 0) { // tehát x-et sorsoltuk if (xDiff > 0) { //ha mehetünk még x irányába, akkor menjünk: xDiff--; currentX++; MarkAsPath(currentX, currentY); } } else { if (yDiff > 0) { //ha mehetünk még x irányába, akkor menjünk: yDiff--; currentY++; MarkAsPath(currentX, currentY); } } } GameObject portalInstantiated = Instantiate(portal, grids[wideness - 1, depth - 1].transform.position + new Vector3(0f, 1.25f, 0f), Quaternion.identity); portalInstantiated.transform.position = new Vector3(portalInstantiated.transform.position.x - 32, portalInstantiated.transform.position.y, portalInstantiated.transform.position.z); grids[wideness - 1, depth - 1].GetComponent <GameGrid>().structure = structureType.PORTAL; portalInstantiated.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); portalInstantiated.transform.GetChild(2).localScale = new Vector3(0.3f, 0.3f, 0.3f); if (grids[wideness - 2, depth - 1].transform.position.y == 0) { portalInstantiated.transform.rotation = Quaternion.Euler(new Vector3(0f, 90f, 0f)); } grids[wideness - 1, depth - 1].GetComponent <GameGrid>().objectsHeld[1] = portalInstantiated; }
public void ReadFromFile(BinaryReader reader) { if (reader.ReadInt16() != 21569) { return; } ushort animalInsCount = reader.ReadUInt16(); instances = new AnimalTrafficInstance[animalInsCount]; if (reader.ReadInt32() != 1595612873) { return; } for (int i = 0; i < animalInsCount; i++) { AnimalTrafficInstance instance = new AnimalTrafficInstance(); instance.Name = new Hash(); instance.Name.ReadFromFile(reader); instances[i] = instance; } ushort pathCount = reader.ReadUInt16(); paths = new AnimalTrafficPath[pathCount]; for (int i = 0; i < pathCount; i++) { AnimalTrafficPath path = new AnimalTrafficPath(); path.numPaths = reader.ReadByte(); byte count1 = reader.ReadByte(); byte count2 = reader.ReadByte(); byte count3 = reader.ReadByte(); path.unkSet0 = reader.ReadBytes(count1); path.unkSet1 = reader.ReadBytes(count2); path.unkSet2 = reader.ReadBytes(count3); path.bbox = BoundingBoxExtenders.ReadFromFile(reader); path.unkHash = new Hash(); path.unkHash.ReadFromFile(reader); //decompiled exe says this is a hash but its always empty path.Unk0 = reader.ReadSingle(); //5 path.Unk1 = reader.ReadSingle(); //15 path.Unk2 = reader.ReadInt16(); //1 257 or 513. path.vectors = new PathVectors[path.numPaths]; for (int x = 0; x < path.numPaths; x++) { PathVectors vector = new PathVectors(); vector.vectors = new Vector3[2]; vector.vectors[0] = Vector3Extenders.ReadFromFile(reader); //Very large differences between these two vector.vectors[1] = Vector3Extenders.ReadFromFile(reader); //2nd one could be rotation, in radians. vector.unk0 = reader.ReadByte(); //7 or 4 path.vectors[x] = vector; } if (path.Unk2 == 2) { path.unk3 = reader.ReadByte(); } paths[i] = path; } }