void loadDTL(int stage) { string path = stage < 10 ? "0" + stage.ToString() : stage.ToString(); string pathDir = Application.dataPath + "/Objects/DAT/Rpg/Rpg" + path + "/"; string pathDTL = pathDir + "map" + path + ".dtl"; FileStream fs = File.OpenRead(pathDTL); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, (int)fs.Length); fs.Close(); GameRPGDTL dtl = data[stage].DTL; int index = 3; dtl.Unknow0 = bytes[index]; index += 1; dtl.Unknow1 = bytes[index]; index += 1; dtl.Unknow2 = bytes[index]; index += 1; dtl.Unknow3 = bytes[index]; index += 1; dtl.Width = BitConverter.ToInt16(bytes, index); index += 2; dtl.Height = BitConverter.ToInt16(bytes, index); index += 2; for (int i = 0; i < dtl.Unknow.Length; i++) { dtl.Unknow[i] = bytes[index]; index += 1; } dtl.Points = new GameRPGDTL.Point[dtl.Height * dtl.Width]; int ii = 0; for (int i = 0; i < dtl.Height; i++) { for (int j = 0; j < dtl.Width; j++) { dtl.Points[ii] = new GameRPGDTL.Point(); dtl.Points[ii].Move = bytes[index]; index += 1; dtl.Points[ii].MapEvent = bytes[index]; index += 1; dtl.Points[ii].RPGEvent = BitConverter.ToInt16(bytes, index); index += 2; ii++; } } }
public void active(int id) { activeID = id; activeRPGStage = GameRPGData.instance.getData(activeID); activeDTL = activeRPGStage.DTL; activeInfo = activeRPGStage.Info; byte[] block = new byte[activeDTL.Width * activeDTL.Height]; for (int i = 0; i < activeDTL.Width * activeDTL.Height; i++) { block[i] = (activeDTL.Points[i].Move == 0 ? (byte)0 : GameRPGPathFinder.BLOCK); } GameRPGPathFinder.instance.initMap(activeDTL.Width, activeDTL.Height, block); isVisibleLayer = true; }
public void clear() { visibleLayer(true); clearStage(); activeID = GameDefine.INVALID_ID; activeDTL = null; activeRPGStage = null; activeInfo = null; objsLayer1 = null; objsLayer0 = null; movement = null; gameAnimation = null; animations.Clear(); }
public void showLayer(int id) { string path = GameDefine.getString2(activeID); if (objsLayer0 == null || objsLayer0.Length != activeRPGStage.Layer.L0.Length) { objsLayer0 = new GameObject[activeRPGStage.Layer.L0.Length]; } for (int j = 0; j < activeRPGStage.Layer.L0.Length; j++) { if (activeRPGStage.Layer.L0[j].ID == id) { if (objsLayer0[j] != null) { continue; } if (activeRPGStage.Layer.L0[j].Unknow4 == 10 && activeRPGStage.Layer.L0[j].Unknow5 == 8) { layerHeight = id * 5000; } if (activeRPGStage.Layer.L0[j].Name.Contains(".saf")) { string pathDir = "Prefab/RPG/RPG" + path + "/"; string pathTexture = pathDir + activeRPGStage.Layer.L0[j].Name.Replace(".saf", ""); GameObject imgObject = Resources.Load <GameObject>(pathTexture); GameObject obj = Instantiate(imgObject, transBackground); obj.name = activeRPGStage.Layer.L0[j].Name; float z = GameDefine.getZ(activeRPGStage.Layer.L0[j].Unknow0); Transform trans = obj.transform; trans.localPosition = new Vector3(0.0f, layerHeight, z); trans.localScale = new Vector3(5.0f, 5.0f, 5.0f); GameAnimation animation = obj.GetComponent <GameAnimation>(); animation.playAnimation(); objsLayer0[j] = obj; } else { string pathDir = "Texture/RPG/"; string pathTexture = pathDir + activeRPGStage.Layer.L0[j].Name; GameObject imgObject = Resources.Load <GameObject>("Prefab/Sprite"); GameObject obj = Instantiate(imgObject, transBackground); obj.name = activeRPGStage.Layer.L0[j].Name; float z = GameDefine.getZ(activeRPGStage.Layer.L0[j].Unknow0); Transform trans = obj.transform; trans.localPosition = new Vector3(0.0f, layerHeight, z); trans.localScale = new Vector3(1.0f, 1.0f, 1.0f); if (activeRPGStage.Layer.L0[j].Unknow4 != 10 && activeRPGStage.Layer.L0[j].Unknow5 != 8) { trans.localScale = new Vector3(2.0f, 2.0f, 1.0f); } transUnit.localPosition = new Vector3(0.0f, 0.0f, -1100); SpriteRenderer sprite = obj.GetComponent <SpriteRenderer>(); sprite.sprite = Resources.Load <Sprite>(pathTexture); float w = activeRPGStage.DTL.Width * GameDefine.TEXTURE_WIDTH; float h = activeRPGStage.DTL.Height * GameDefine.TEXTURE_HEIGHT; if (w == 4096 || h == 4096) { w = w / activeRPGStage.DTL.Width * GameDefine.TEXTURE_WIDTH; h = w / activeRPGStage.DTL.Height * GameDefine.TEXTURE_HEIGHT; trans.localScale = new Vector3(w, h, 1.0f); } objsLayer0[j] = obj; } } } if (objsLayer1 == null || objsLayer1.Length != activeRPGStage.Layer.L1.Length) { objsLayer1 = new GameObject[activeRPGStage.Layer.L1.Length]; } for (int j = 0; j < activeRPGStage.Layer.L1.Length; j++) { if (activeRPGStage.Layer.L1[j].ID == id) { string pathDir = "Prefab/RPG/RPG" + path + "/"; string pathTexture = pathDir + activeRPGStage.Layer.L1[j].Name; GameObject imgObject = Resources.Load <GameObject>(pathTexture); GameObject obj = Instantiate(imgObject, transBackground); obj.name = activeRPGStage.Layer.L1[j].Name; Transform trans = obj.transform; trans.localPosition = new Vector3(activeRPGStage.Layer.L1[j].OffsetX, -activeRPGStage.Layer.L1[j].OffsetY + layerHeight, -1000 - j); trans.localScale = new Vector3(1.0f, 1.0f, 1.0f); GameAnimation animation = obj.GetComponent <GameAnimation>(); if (activeRPGStage.Layer.L1[j].Unknow5 == 0) { if (activeRPGStage.Layer.L1[j].Unknow3 == GameDefine.INVALID_ID) { animation.playAnimation(); } else { } } else { } objsLayer1[j] = obj; } } #if UNITY_EDITOR if (id == 1) { GameRPGDTL dtl = activeRPGStage.DTL; int ii = 0; Sprite spriteObject = Resources.Load <Sprite>("White"); for (int i = 0; i < dtl.Height; i++) { for (int j = 0; j < dtl.Width; j++) { // editor test GameObject imgObject = Resources.Load <GameObject>("Prefab/Sprite"); GameObject obj = Instantiate(imgObject, transCell); obj.name = i + "-" + j; Transform trans = obj.transform; trans.localPosition = new Vector3(j * 30, -i * 24 + layerHeight, 0.0f); // trans.localScale = new Vector3( 1.0f , 1.0f , 1.0f ); SpriteRenderer sprite = obj.GetComponent <SpriteRenderer>(); sprite.color = new Color(1.0f, 1.0f, 1.0f, (dtl.Points[ii].Move == 1 ? 0.2f : 0.0f)); sprite.sprite = spriteObject; GamePointTset test = obj.AddComponent <GamePointTset>(); test.Value0 = dtl.Points[ii].Move; test.Value1 = dtl.Points[ii].MapEvent; test.Value2 = dtl.Points[ii].RPGEvent; if (dtl.Points[ii].MapEvent > 0) { sprite.color = new Color(0.0f, 1.0f, 0.0f, 0.25f); } else if (dtl.Points[ii].RPGEvent > 0) { sprite.color = new Color(1.0f, 0.0f, 0.0f, 0.25f); } ii++; } } } #endif }