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(); }
void loadInfo(int stage) { string path = stage < 10 ? "0" + stage.ToString() : stage.ToString(); string pathDir = Application.dataPath + "/Objects/DAT/Rpg/Rpg" + path + "/"; string pathLayer = pathDir + "RPG_" + path + ".DAT"; GameRPGInfo info = data[stage].Info; info.Shop = new GameRPGShopInfo[(int)GameRPGShopType.Count]; info.Pos = new GameRPGPosInfo[2]; FileStream fs = File.OpenRead(pathLayer); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, (int)fs.Length); fs.Close(); int index = 0; info.Pos[0] = new GameRPGPosInfo(); info.Pos[0].Music = BitConverter.ToInt16(bytes, index); index += 2; info.Pos[0].MapPosX = BitConverter.ToInt16(bytes, index); index += 2; info.Pos[0].MapPosY = BitConverter.ToInt16(bytes, index); index += 2; info.Pos[0].PosX = BitConverter.ToInt16(bytes, index); index += 2; info.Pos[0].PosY = BitConverter.ToInt16(bytes, index); index += 2; info.Pos[0].Direction = BitConverter.ToInt16(bytes, index); index += 2; if (bytes.Length <= index) { return; } info.Pos[1] = new GameRPGPosInfo(); info.Pos[1].Music = BitConverter.ToInt16(bytes, index); index += 2; info.Pos[1].MapPosX = BitConverter.ToInt16(bytes, index); index += 2; info.Pos[1].MapPosY = BitConverter.ToInt16(bytes, index); index += 2; info.Pos[1].PosX = BitConverter.ToInt16(bytes, index); index += 2; info.Pos[1].PosY = BitConverter.ToInt16(bytes, index); index += 2; info.Pos[1].Direction = BitConverter.ToInt16(bytes, index); index += 2; if (bytes.Length <= index) { return; } info.Shop[0] = new GameRPGShopInfo(); info.Shop[0].item = new short[GameDefine.MAX_RPG_SHOP_SLOT]; for (int j = 0; j < GameDefine.MAX_RPG_SHOP_SLOT; j++) { info.Shop[0].item[j] = GameDefine.INVALID_ID; } short type = BitConverter.ToInt16(bytes, index); index += 2; info.Shop[0].type = (GameRPGShopType)type; info.Shop[0].shop = BitConverter.ToInt16(bytes, index); index += 2; for (int i = 0; i < GameDefine.MAX_RPG_SHOP_SLOT; i++) { info.Shop[0].item[i] = BitConverter.ToInt16(bytes, index); index += 2; } if (bytes.Length <= index) { return; } info.Shop[1] = new GameRPGShopInfo(); info.Shop[1].item = new short[GameDefine.MAX_RPG_SHOP_SLOT]; for (int j = 0; j < GameDefine.MAX_RPG_SHOP_SLOT; j++) { info.Shop[1].item[j] = GameDefine.INVALID_ID; } type = BitConverter.ToInt16(bytes, index); index += 2; info.Shop[1].type = (GameRPGShopType)type; info.Shop[1].shop = BitConverter.ToInt16(bytes, index); index += 2; for (int i = 0; i < GameDefine.MAX_RPG_SHOP_SLOT; i++) { info.Shop[1].item[i] = BitConverter.ToInt16(bytes, index); index += 2; } if (bytes.Length <= index) { return; } info.Shop[2] = new GameRPGShopInfo(); info.Shop[2].item = new short[GameDefine.MAX_RPG_SHOP_SLOT]; for (int j = 0; j < GameDefine.MAX_RPG_SHOP_SLOT; j++) { info.Shop[2].item[j] = GameDefine.INVALID_ID; } type = BitConverter.ToInt16(bytes, index); index += 2; info.Shop[2].type = (GameRPGShopType)type; info.Shop[2].shop = BitConverter.ToInt16(bytes, index); index += 2; for (int i = 0; i < GameDefine.MAX_RPG_SHOP_SLOT; i++) { info.Shop[2].item[i] = BitConverter.ToInt16(bytes, index); index += 2; } if (bytes.Length <= index) { return; } Debug.Log(stage); }