public void initPos(int i) { GameRPGPosInfo info = activeInfo.Pos[i]; // GameRPGSceneMovement.instance.moveTo( info.MapPosX , info.MapPosY ); GameMusicManager.instance.playMusic(0, "Music/Music_" + GameDefine.getString2(info.Music)); string path = "Prefab/RPG/Rpgman"; GameObject obj = Instantiate <GameObject>(Resources.Load <GameObject>(path)); gameAnimation = obj.GetComponent <GameAnimation>(); obj.name = "Rpgman"; gameAnimation.playAnimationRPG(GameAnimationType.Stand, GameAnimationDirection.South, null); Transform trans = obj.transform; trans.SetParent(transUnit); trans.localScale = new Vector3(1.0f, 1.0f, 1.0f); movement = obj.AddComponent <GameRPGMovement>(); movement.setPos(info.PosX, info.PosY); movement.setDirection((GameAnimationDirection)info.Direction); GameRPGSceneMovement.instance.followPos(movement.PosBattleX, movement.PosBattleY); }
public void showTitle(int t, OnEventOver over) { show(); image.sprite = Resources.Load <Sprite>("Texture/Map/Stage" + GameDefine.getString2(t) + "/Tanm_" + GameDefine.getString2(t) + "_t0"); timeAll = 0.5f; time = 0.0f; black.color = new Color(0.0f, 0.0f, 0.0f, 0.0f); image.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); alpha = 0.0f; isShowBlack = true; alphaAdd = true; onEventOver = over; }
public void addAnimation(int id, int id2) { GameAnimation ani = null; string str = id + " " + id2; if (animations.ContainsKey(str)) { ani = animations[str]; ani.stopAnimation(); ani.clearAnimation(); Destroy(ani.gameObject); ani.transform.SetParent(null); animations.Remove(str); } for (int i = 0; i < activeRPGStage.Layer.L1.Length; i++) { if (activeRPGStage.Layer.L1[i].ID == id && activeRPGStage.Layer.L1[i].Parm == id2) { string path = "Prefab/RPG/RPG" + GameDefine.getString2(activeID) + "/"; path += activeRPGStage.Layer.L1[i].Name; GameObject obj = Instantiate <GameObject>(Resources.Load <GameObject>(path)); ani = obj.GetComponent <GameAnimation>(); Transform trans = obj.transform; trans.SetParent(transEvent); trans.localPosition = new Vector3(0.0f, layerHeight, 0.0f); trans.localScale = new Vector3(1.0f, 1.0f, 1.0f); animations.Add(str, ani); return; } } }
public void addAnimation(int id, int name) { GameAnimation ani = null; if (animations.ContainsKey(id)) { ani = animations[id]; ani.stopAnimation(); ani.clearAnimation(); ani.transform.SetParent(null); Destroy(ani.gameObject); animations.Remove(id); } // else // { string path = "Prefab/Stage/Stage" + GameDefine.getString2(GameUserData.instance.Stage) + "/Eanm_"; path += GameDefine.getString2(name); GameObject obj = Instantiate <GameObject>(Resources.Load <GameObject>(path)); ani = obj.GetComponent <GameAnimation>(); obj.name = "Eanm_" + GameDefine.getString2(name); Transform trans = obj.transform; trans.SetParent(transBackground); trans.localPosition = new Vector3(0.0f, layerHeight, 0.0f); trans.localScale = new Vector3(1.0f, 1.0f, 1.0f); ani.lastUnitID = LastUnitID; LastUnitID = GameDefine.INVALID_ID; animations.Add(id, ani); // } }
public void show(GameCampScript s) { script = s; show(); string path = "Prefab/Camp/Image/camp" + GameDefine.getString2(script.Camp); GameObject gameOjbect = Resources.Load <GameObject>(path); GameObject obj = Instantiate(gameOjbect, transBackground); Transform trans = obj.transform; trans.localPosition = new Vector3(0.0f, 0.0f, 0.0f); trans.localScale = new Vector3(1.0f, 1.0f, 1.0f); gameAnimation = obj.GetComponent <GameAnimation>(); gameAnimation.UI = true; gameAnimation.offsetX = -(int)(GameCameraManager.instance.sceneWidthHalf - GameCameraManager.instance.xOffset); gameAnimation.offsetY = (int)(GameCameraManager.instance.sceneHeightHalf); gameAnimation.playAnimation(); GameCampSelectUI.instance.show(0); GameCampSelectUI.instance.showFade(); }
public void show(GameRPGShopInfo i, OnEventOver over) { info = i; onEventOver = over; show(); shopUI.gameObject.SetActive(false); bagUI.gameObject.SetActive(false); moneyText.gameObject.SetActive(false); itemText.gameObject.SetActive(false); Background1.gameObject.SetActive(false); Background2.gameObject.SetActive(false); string path = "Prefab/Shop/Shop" + GameDefine.getString2(info.shop); GameObject gameOjbect = Resources.Load <GameObject>(path); GameObject obj = Instantiate(gameOjbect, transBackground); Transform trans = obj.transform; trans.localPosition = new Vector3(0.0f, 0.0f, 0.0f); trans.localScale = new Vector3(1.0f, 1.0f, 1.0f); gameAnimation = obj.GetComponent <GameAnimation>(); gameAnimation.UI = true; gameAnimation.offsetX = -(int)(GameCameraManager.instance.sceneWidthHalf - GameCameraManager.instance.xOffset); gameAnimation.offsetY = (int)(GameCameraManager.instance.sceneHeightHalf); gameAnimation.showFrame(0); obj = Instantiate(gameOjbect, transBackground); trans = obj.transform; trans.localPosition = new Vector3(0.0f, 0.0f, 0.0f); trans.localScale = new Vector3(1.0f, 1.0f, 1.0f); gameAnimation = obj.GetComponent <GameAnimation>(); gameAnimation.UI = true; gameAnimation.offsetX = -(int)(GameCameraManager.instance.sceneWidthHalf - GameCameraManager.instance.xOffset); gameAnimation.offsetY = (int)(GameCameraManager.instance.sceneHeightHalf); gameAnimation.playAnimation(0, gameAnimation.safHead.count3[0], false, onShowOver); shopUI.setType(GameItemBagUI.GameItemBagUIType.Shop); shopUI.setShopType(info.type); bagUI.setType(GameItemBagUI.GameItemBagUIType.User); bagUI.setUser(0); shopUI.setUser(0); shopUI.setItems(info.item); bagUI.setItems(GameUserData.instance.getUnitBase(0).Items); bagUI.select(0); shopUI.enable(true); bagUI.enable(false); shopUI.select(0); updateText(); }
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 }
public void showLayer(int id, bool b) { // clearAnimations(); layerList.Add(id); string path = GameDefine.getString2(GameUserData.instance.Stage); if (objsLayer0 == null || objsLayer0.Length != activeBattleStage.Layer.L0.Length) { objsLayer0 = new GameObject[activeBattleStage.Layer.L0.Length]; } int lastLayer = 0; float lastWidth = 0.0f; float lastHeight = 0.0f; for (int j = 0; j < activeBattleStage.Layer.L0.Length; j++) { if (activeBattleStage.Layer.L0[j].ID == id) { if (objsLayer0[j] != null) { continue; } lastLayer = activeBattleStage.Layer.L0[j].Lyaer; layerHeight = id * 5000; if (id > 1 && GameUserData.instance.Stage == 34) { // fix stage 34 bug. layerHeight = 5000; } if (layerList.Count == 1) { GameBattleSceneMovement.instance.moveToEvent(0, 0); } if (activeBattleStage.Layer.L0[j].Name.Contains(".saf")) { string pathDir = "Prefab/Stage/Stage" + path + "/"; string pathTexture = pathDir + activeBattleStage.Layer.L0[j].Name.Replace(".saf", ""); GameObject imgObject = Resources.Load <GameObject>(pathTexture); GameObject obj = Instantiate(imgObject, GameCameraManager.instance.transform); obj.name = activeBattleStage.Layer.L0[j].Name; float z = GameDefine.getZ(activeBattleStage.Layer.L0[j].Unknow0); Transform trans = obj.transform; trans.localPosition = new Vector3(-GameCameraManager.instance.sceneWidthHalf, GameCameraManager.instance.sceneHeightHalf , z + 20); trans.localScale = new Vector3(1.0f, 1.0f, 1.0f); GameAnimation animation = obj.GetComponent <GameAnimation>(); animation.playAnimation(); objsLayer0[j] = obj; } else { string pathDir = "Texture/Map/Stage" + path + "/"; string pathTexture = pathDir + activeBattleStage.Layer.L0[j].Name; GameObject imgObject = Resources.Load <GameObject>("Prefab/Map"); GameObject obj = Instantiate(imgObject, transBackground); obj.name = activeBattleStage.Layer.L0[j].Name; float z = GameDefine.getZ(activeBattleStage.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); SpriteRenderer sprite = obj.GetComponent <SpriteRenderer>(); sprite.sprite = Resources.Load <Sprite>(pathTexture); float w = activeBattleStage.Layer.L0[j].Width * GameDefine.TEXTURE_WIDTH; float h = activeBattleStage.Layer.L0[j].Height * GameDefine.TEXTURE_HEIGHT; if (w > 4096 || h > 4096) { w = w / activeBattleStage.DTL.Width * GameDefine.TEXTURE_WIDTH; h = w / activeBattleStage.DTL.Height * GameDefine.TEXTURE_HEIGHT; trans.localScale = new Vector3(w, h, 1.0f); } if (activeBattleStage.Layer.L0[j].Unknow4 != 10 && activeBattleStage.Layer.L0[j].Unknow5 != 8) { if (GameUserData.instance.Stage == 18) { // fix stage 18 bug trans.localPosition = new Vector3(0.0f, layerHeight, 10.0f); } trans.localScale = new Vector3(lastWidth / w, lastHeight / h, 1.0f); } else { lastWidth = w; lastHeight = h; } objsLayer0[j] = obj; } } } if (objsLayer1 == null || objsLayer1.Length != activeBattleStage.Layer.L1.Length) { objsLayer1 = new GameObject[activeBattleStage.Layer.L1.Length]; } for (int j = 0; j < activeBattleStage.Layer.L1.Length; j++) { if (activeBattleStage.Layer.L1[j].ID != id) { continue; } string pathDir = "Prefab/Stage/Stage" + path + "/"; string pathTexture = pathDir + activeBattleStage.Layer.L1[j].Name; GameObject imgObject = Resources.Load <GameObject>(pathTexture); GameObject obj = Instantiate(imgObject, transBackground); obj.name = activeBattleStage.Layer.L1[j].Name; Transform trans = obj.transform; trans.localPosition = new Vector3(activeBattleStage.Layer.L1[j].OffsetX, -activeBattleStage.Layer.L1[j].OffsetY + layerHeight, -1000 - j); trans.localScale = new Vector3(1.0f, 1.0f, 1.0f); GameAnimation animation = obj.GetComponent <GameAnimation>(); if (activeBattleStage.Layer.L1[j].VisibleBattle == 0) { bool bVisible = true; if (activeBattleStage.Layer.L1[j].ParmEffect != GameDefine.INVALID_ID) { bVisible = GameUserData.instance.getGameData(activeBattleStage.Layer.L1[j].ParmEffect) > 0; } if (bVisible) { switch (activeBattleStage.Layer.L1[j].Pause) { case 0: animation.playAnimation(); break; case 1: animation.playAnimation(); // Debug.LogError( "activeBattleStage.Layer.L1[ j ].Pause" + j ); break; case 2: animation.playSound = false; animation.showFrame(0); animation.playSound = true; break; } } } // // 夏侯婴加入? // if ( GameUserData.instance.Stage == 28 && // activeBattleStage.Layer.L1[ j ].Parm == 7 ) // 8 // { // continue; // } // if ( GameUserData.instance.Stage == 29 && // activeBattleStage.Layer.L1[ j ].Parm == 1 ) // 3 // { // continue; // } objsLayer1[j] = obj; } #if UNITY_EDITOR if (id == 1) { GameBattleDTL dtl = activeBattleStage.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 // return; 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>(); float c = (dtl.Points[ii].Move * 25) / 255.0f; sprite.color = new Color(c, c, c, (c > 0.25f ? 0.25f : c)); sprite.sprite = spriteObject; if (dtl.Points[ii].MapEvent != -1 && activeBattleStage.MEVT.Length > dtl.Points[ii].MapEvent) { if (activeBattleStage.MEVT[dtl.Points[ii].MapEvent].EventType == GameBattleMapEventType.Event) { sprite.color = new Color(0.0f, 1.0f, 0.0f, 0.25f); } else if (activeBattleStage.MEVT[dtl.Points[ii].MapEvent].EventType == GameBattleMapEventType.Item) { sprite.color = new Color(1.0f, 1.0f, 0.0f, 0.25f); } } GamePointTset test = obj.AddComponent <GamePointTset>(); test.Value0 = dtl.Points[ii].Move; test.Value1 = dtl.Points[ii].Floor; test.Value2 = dtl.Points[ii].MapEvent; // obj = Instantiate( imgObject , transUnit ); // obj.name = i + "-" + j; // // trans = obj.GetComponent<RectTransform>(); // trans.localPosition = new Vector3( j * 30 , -i * 24 , 0.0f ); // trans.localScale = new Vector3( 1.0f , 1.0f , 1.0f ); // trans.sizeDelta = new Vector2( 30 , 24 ); // // image = obj.GetComponent<Image>(); // image.enabled = false; ii++; } } } #endif }
public void showEffect(int id, int s) { for (int j = 0; j < activeBattleStage.Layer.L1.Length; j++) { if (activeBattleStage.Layer.L1[j].Parm == id) { if (objsLayer1[j] == null) { string path = GameDefine.getString2(GameUserData.instance.Stage); string pathDir = "Prefab/Stage/Stage" + path + "/"; string pathTexture = pathDir + activeBattleStage.Layer.L1[j].Name; GameObject imgObject = Resources.Load <GameObject>(pathTexture); GameObject obj = Instantiate(imgObject, transBackground); obj.name = activeBattleStage.Layer.L1[j].Name; Transform trans = obj.transform; trans.localPosition = new Vector3(GameBattleSceneMovement.instance.AnimationPosX, GameBattleSceneMovement.instance.AnimationPosY + layerHeight, 1.0f); trans.localScale = new Vector3(1.0f, 1.0f, 1.0f); GameAnimation animation = obj.GetComponent <GameAnimation>(); objsLayer1[j] = animation.gameObject; if (GameUserData.instance.Stage == 29) { // fix stage 29 bug trans.localPosition = new Vector3(GameBattleSceneMovement.instance.AnimationPosX, GameBattleSceneMovement.instance.AnimationPosY + layerHeight, -1005.0f); } if (GameUserData.instance.Stage == 34 && id == 6) { // fix stage 34 bug trans.localPosition = new Vector3(0.0f, layerHeight, 1.0f); } if (activeBattleStage.Layer.L1[j].Pause == 0) { animation.playAnimation(); } else { animation.stopAnimation(); animation.showFrame(0); } return; } GameAnimation animation1 = objsLayer1[j].GetComponent <GameAnimation>(); if (activeBattleStage.Layer.L1[j].Pause == 0) { animation1.playAnimation(); } else { animation1.stopAnimation(); animation1.showFrame(0); } } } }
public void initMusic() { short music = activeBattleStart.Music; GameMusicManager.instance.playMusic(0, "Music/Music_" + GameDefine.getString2(music)); }
public void doEvent() { #if UNITY_EDITOR Debug.LogWarning("doEvent type: " + activeID + " " + activeStep + " " + String.Format("{0:X}", activeEvent.Type)); #endif switch (activeEvent.Type) { case 0x01: // unknow { short id = BitConverter.ToInt16(activeEvent.Data, 0); #if UNITY_EDITOR Debug.Log("0x01 unknow " + id); #endif nextEvent(); } break; case 0x02: // visible { GameRPGManager.instance.visibleLayer(!GameRPGManager.instance.IsVisibleLayer); #if UNITY_EDITOR Debug.Log("0x02 visible layer"); #endif nextEvent(); } break; case 0x04: // move scene { short posX = BitConverter.ToInt16(activeEvent.Data, 0); short posY = BitConverter.ToInt16(activeEvent.Data, 2); short posXSpeed = BitConverter.ToInt16(activeEvent.Data, 4); short posYSpeed = BitConverter.ToInt16(activeEvent.Data, 6); #if UNITY_EDITOR Debug.Log("0x04 move scene " + posX + " " + posY + " " + posXSpeed + " " + posYSpeed); #endif // if ( GameRPGManager.instance.IsVisibleLayer ) // { // GameRPGManager.instance.moveTo( posX , posY , nextEvent ); // } // else // { GameRPGSceneMovement.instance.moveToEvent(posX, posY - 1, posXSpeed, posYSpeed, nextEvent); // } } break; case 0x06: // black { GameBlackUI.instance.showBlack(1, null); #if UNITY_EDITOR Debug.Log("0x06 black "); #endif nextEvent(); } break; case 0x07: // black fade out { GameBlackUI.instance.unShowBlack(1, null); #if UNITY_EDITOR Debug.Log("0x07 black fade out "); #endif nextEvent(); } break; case 0x09: // talk { short face = BitConverter.ToInt16(activeEvent.Data, 6); short type = BitConverter.ToInt16(activeEvent.Data, 8); short side = BitConverter.ToInt16(activeEvent.Data, 10); short num = BitConverter.ToInt16(activeEvent.Data, 12); #if UNITY_EDITOR Debug.Log("0x09 talk " + face + " " + type + " " + side + " " + num); #endif GameTouchCenterUI.instance.unShowUI(); GameMsgBoxUI.instance.showText(face, type, side, GameRPGManager.instance.ActiveRPGStage.EMSG[activeID].Msg[num], nextEvent); } break; case 0x10: // set game data max 128 + 128 { short id = BitConverter.ToInt16(activeEvent.Data, 0); int dat = BitConverter.ToInt32(activeEvent.Data, 2); #if UNITY_EDITOR Debug.Log("0x10 set game data " + id + " " + dat); #endif GameUserData.instance.setGameData(id, dat); nextEvent(); } break; case 0x15: // add animation { short id = BitConverter.ToInt16(activeEvent.Data, 0); short id2 = BitConverter.ToInt16(activeEvent.Data, 2); #if UNITY_EDITOR Debug.Log("0x15 add animation " + id + " " + id2); #endif GameRPGManager.instance.addAnimation(id, id2); nextEvent(); } break; case 0x16: // remove animation { short id = BitConverter.ToInt16(activeEvent.Data, 0); short id2 = BitConverter.ToInt16(activeEvent.Data, 2); #if UNITY_EDITOR Debug.Log("0x16 remove animation " + id + " " + id2); #endif GameRPGManager.instance.clearAnimation(id, id2); nextEvent(); } break; case 0x18: // show animation { short id = BitConverter.ToInt16(activeEvent.Data, 0); short id2 = BitConverter.ToInt16(activeEvent.Data, 2); short frame = BitConverter.ToInt16(activeEvent.Data, 4); short endFrame = BitConverter.ToInt16(activeEvent.Data, 6); #if UNITY_EDITOR Debug.Log("0x18 show animation " + id + " " + id2 + " " + frame + " " + endFrame); #endif GameRPGManager.instance.playAnimation(id, id2, frame, endFrame, nextEvent); } break; case 0x1A: // play music { short id = BitConverter.ToInt16(activeEvent.Data, 0); short id2 = BitConverter.ToInt16(activeEvent.Data, 2); #if UNITY_EDITOR Debug.Log("0x1A play music" + id + " " + id2); #endif GameMusicManager.instance.playMusic(id2, "Music/Music_" + GameDefine.getString2(id)); nextEvent(); } break; case 0x1B: { short id2 = BitConverter.ToInt16(activeEvent.Data, 0); #if UNITY_EDITOR Debug.Log("0x1C pause music" + id2); #endif GameMusicManager.instance.pauseMusic(id2, true); nextEvent(); } break; case 0x1C: { short id2 = BitConverter.ToInt16(activeEvent.Data, 0); short v = BitConverter.ToInt16(activeEvent.Data, 2); #if UNITY_EDITOR Debug.Log("0x1C music volume" + id2 + " " + v); #endif GameMusicManager.instance.musicVolume(id2, v == 1 ? 0.5f : 1.0f); nextEvent(); } break; case 0x1D: { short id2 = BitConverter.ToInt16(activeEvent.Data, 0); short s = BitConverter.ToInt16(activeEvent.Data, 2); #if UNITY_EDITOR Debug.Log("0x1D pause music" + id2 + " " + s); #endif GameMusicManager.instance.pauseMusic(id2, true); nextEvent(); } break; case 0x1E: { short id2 = BitConverter.ToInt16(activeEvent.Data, 0); short s = BitConverter.ToInt16(activeEvent.Data, 2); #if UNITY_EDITOR Debug.Log("0x1E pause music" + id2 + " " + s); #endif // GameMusicManager.instance.musicVolume( id2 , s == 1 ? 0.2f : 1.0f ); GameMusicManager.instance.pauseMusic(id2, false); nextEvent(); } break; case 0x20: // check game data { // CheckData cd = new CheckData(); short id = BitConverter.ToInt16(activeEvent.Data, 0); int dat = BitConverter.ToInt32(activeEvent.Data, 2); short step = BitConverter.ToInt16(activeEvent.Data, 6); short unknow = BitConverter.ToInt16(activeEvent.Data, 8); //checkData.Add( cd ); #if UNITY_EDITOR Debug.Log("0x20 check game data == " + id + " " + dat + " " + step + " " + unknow + " " + (GameUserData.instance.getGameData(id) == dat).ToString()); #endif if (GameUserData.instance.getGameData(id) == dat) { activeStep = step - 1; } nextEvent(); } break; case 0x21: // check game data > { short id = BitConverter.ToInt16(activeEvent.Data, 0); int dat = BitConverter.ToInt32(activeEvent.Data, 2); short step = BitConverter.ToInt16(activeEvent.Data, 6); short unknow = BitConverter.ToInt16(activeEvent.Data, 8); #if UNITY_EDITOR Debug.Log("0x21 check game data > " + id + " " + dat + " " + step + " " + unknow + " " + (GameUserData.instance.getGameData(id) > dat).ToString()); #endif //checkData.Add( cd ); if (GameUserData.instance.getGameData(id) > dat) { activeStep = step - 1; } else { } nextEvent(); } break; case 0x22: // check game data >= { short id = BitConverter.ToInt16(activeEvent.Data, 0); int dat = BitConverter.ToInt32(activeEvent.Data, 2); short step = BitConverter.ToInt16(activeEvent.Data, 6); short unknow = BitConverter.ToInt16(activeEvent.Data, 8); #if UNITY_EDITOR Debug.Log("0x22 check game data >= " + id + " " + dat + " " + step + " " + unknow + " " + (GameUserData.instance.getGameData(id) >= dat).ToString()); #endif //checkData.Add( cd ); if (GameUserData.instance.getGameData(id) >= dat) { activeStep = step - 1; } else { } nextEvent(); } break; case 0x23: // check game data < { short id = BitConverter.ToInt16(activeEvent.Data, 0); int dat = BitConverter.ToInt32(activeEvent.Data, 2); short step = BitConverter.ToInt16(activeEvent.Data, 6); short unknow = BitConverter.ToInt16(activeEvent.Data, 8); #if UNITY_EDITOR Debug.Log("0x22 check game data < " + id + " " + dat + " " + step + " " + unknow + " " + (GameUserData.instance.getGameData(id) < dat).ToString()); #endif //checkData.Add( cd ); if (GameUserData.instance.getGameData(id) < dat) { activeStep = step - 1; } else { // stage 3 bug if (checkGold && GameUserData.instance.Stage == 3) { checkGold = false; GameUserData.instance.addGold(-dat); } } nextEvent(); } break; case 0x24: // check game data <= { short id = BitConverter.ToInt16(activeEvent.Data, 0); int dat = BitConverter.ToInt32(activeEvent.Data, 2); short step = BitConverter.ToInt16(activeEvent.Data, 6); short unknow = BitConverter.ToInt16(activeEvent.Data, 8); #if UNITY_EDITOR Debug.Log("0x22 check game data <= " + id + " " + dat + " " + step + " " + unknow + " " + (GameUserData.instance.getGameData(id) <= dat).ToString()); #endif //checkData.Add( cd ); if (GameUserData.instance.getGameData(id) <= dat) { activeStep = step - 1; } else { } nextEvent(); } break; case 0x26: // change scene { changeSceneID = BitConverter.ToInt16(activeEvent.Data, 0); changeScenePos = BitConverter.ToInt16(activeEvent.Data, 2); #if UNITY_EDITOR Debug.Log("0x26 change scene " + changeSceneID + " " + changeScenePos); #endif GameBlackUI.instance.showBlack(1, onChangeScene); GameRPGManager.instance.stopMove(); nextEvent(); } break; case 0x27: // shop { short id = BitConverter.ToInt16(activeEvent.Data, 0); #if UNITY_EDITOR Debug.Log("0x27 shop " + id); #endif GameRPGShopInfo info = GameRPGManager.instance.ActiveRPGStage.Info.Shop[id]; GameShopUI.instance.show(info, nextEvent); GameRPGManager.instance.stopMove(); GameBlackUI.instance.unShowBlack(1, null); } break; case 0x28: // nextStage { #if UNITY_EDITOR Debug.Log("0x28 nextStage "); #endif GameUserData.instance.setStage(GameUserData.instance.NextStage); GameBlackUI.instance.showBlack(1, onShowBlackOverLoadBattle); } break; case 0x29: // camp { short id = BitConverter.ToInt16(activeEvent.Data, 0); #if UNITY_EDITOR Debug.Log("0x29 camp " + id); #endif GameBlackUI.instance.showBlack(1, onShowBlackOverLoadCamp); GameMusicManager.instance.stopMusic(0); } break; case 0x2B: // clear { GameRPGManager.instance.clearGameAnimation(); #if UNITY_EDITOR Debug.Log("0x2B clear animation "); #endif nextEvent(); } break; case 0x2C: // add game data { short id = BitConverter.ToInt16(activeEvent.Data, 0); int dat = BitConverter.ToInt32(activeEvent.Data, 2); #if UNITY_EDITOR Debug.Log("0x2C add game data " + id + " " + dat); #endif GameUserData.instance.addGameData(id, dat); nextEvent(); } break; case 0x2D: // add game data { short id = BitConverter.ToInt16(activeEvent.Data, 0); int dat = BitConverter.ToInt32(activeEvent.Data, 2); #if UNITY_EDITOR Debug.Log("0x2D add game data " + id + " " + -dat); #endif GameUserData.instance.addGameData(id, -dat); nextEvent(); } break; case 0x2E: // show check msg box { short id = BitConverter.ToInt16(activeEvent.Data, 0); int dat = BitConverter.ToInt32(activeEvent.Data, 2); short num = BitConverter.ToInt16(activeEvent.Data, 6); msgBoxData = BitConverter.ToInt16(activeEvent.Data, 8); #if UNITY_EDITOR Debug.Log("0x2E show check msg box " + id + " " + dat + " " + num + " " + msgBoxData); #endif string str0 = GameRPGManager.instance.ActiveRPGStage.EMSG[activeID].Msg[num]; string str1 = GameRPGManager.instance.ActiveRPGStage.EMSG[activeID].Msg[num + 1]; string str2 = GameRPGManager.instance.ActiveRPGStage.EMSG[activeID].Msg[num + 2]; GameMsgBoxChooseUI.instance.showText(str0, str1, str2, true, onMsgBoxClick); GameMsgBoxChooseUI.instance.showFade(); GameTouchCenterUI.instance.showUI(); } break; case 0x2F: // add item { short id = BitConverter.ToInt16(activeEvent.Data, 0); #if UNITY_EDITOR Debug.Log("0x2F add item " + id); #endif GameUserData.instance.addItem(id); nextEvent(); } break; case 0x30: // check item { short item = BitConverter.ToInt16(activeEvent.Data, 0); short id = BitConverter.ToInt16(activeEvent.Data, 2); #if UNITY_EDITOR Debug.Log("0x30 check item " + item + " set dat " + id); #endif if (GameUserData.instance.hasItem(item)) { GameUserData.instance.setGameData(id, 1); } nextEvent(); } break; case 0x31: // set gold { short id = BitConverter.ToInt16(activeEvent.Data, 0); #if UNITY_EDITOR Debug.Log("0x31 set dat " + id + " gold " + GameUserData.instance.Gold); #endif GameUserData.instance.setGameData(id, GameUserData.instance.Gold); checkGold = true; nextEvent(); } break; case 0x32: // gold { short gold = BitConverter.ToInt16(activeEvent.Data, 0); #if UNITY_EDITOR Debug.Log("0x32 add gold " + -gold); #endif GameUserData.instance.addGold(-gold); nextEvent(); } break; case 0x33: // next stage { short stage = BitConverter.ToInt16(activeEvent.Data, 0); #if UNITY_EDITOR Debug.Log("0x33 next stage "); #endif GameUserData.instance.setNextStage(stage); GameUserData.instance.setStage(GameUserData.instance.NextStage); nextEvent(); } break; case 0: // none { #if UNITY_EDITOR Debug.Log("0x00 none."); #endif eventOver(); } break; default: { Debug.LogError("doEvent type: " + activeStep + " " + String.Format("{0:X}", activeEvent.Type)); nextEvent(); } break; } }
public void show(byte f, GameBattleUnit lt, GameBattleUnit rt, GameBattleAttackResultSide s, GameBattleAttackResultPhysical rs, bool o, OnEventOver over) { clear(); skill = null; onEventOver = over; result = rs; resultSkill = null; side = s; isShow = true; overUnShow = false; showAdd = false; mapAttack = false; gameObject.SetActive(true); leftUnit = lt; rightUnit = rt; string path = "Prefab/Stage/Stage" + GameDefine.getString2(GameUserData.instance.Stage) + "/FLOOR_"; path += GameDefine.getString2(GameUserData.instance.Stage); GameObject gameObjectFloor = Instantiate <GameObject>(Resources.Load <GameObject>(path)); floorAnimation = gameObjectFloor.GetComponent <GameAnimation>(); floorAnimation.UI = true; floorAnimation.showFrame(f); floorAnimation.transform.SetParent(floorTrans); floorAnimation.transform.localScale = Vector3.one; floorAnimation.transform.localPosition = Vector3.zero; // string ab = result.type == GameBattleAttackResultType.Block ? "ab" : "a"; path = "Prefab/Sprite/man" + GameDefine.getString3(rt.Sprite) + "/"; path += (GameDefine.getString3(rt.Sprite) + "MISC"); GameObject obj = Instantiate <GameObject>(Resources.Load <GameObject>(path)); rightAnimation = obj.GetComponent <GameAnimation>(); rightAnimation.UI = true; rightAnimation.showFrame(6 + (rightAnimation.safHead.count3[0] == 0 ? 1 : rightAnimation.safHead.count3[0])); Transform trans = obj.transform; trans.SetParent(right.transform); trans.localScale = Vector3.one; trans.localPosition = Vector3.zero; rightInfoUI.gameObject.SetActive(true); rightInfoUI.setValue(rt.HP, rt.HPMax, rt.Name); path = "Prefab/Sprite/man" + GameDefine.getString3(lt.Sprite) + "/"; path += (GameDefine.getString3(lt.Sprite) + "MISC"); obj = Instantiate <GameObject>(Resources.Load <GameObject>(path)); leftAnimation = obj.GetComponent <GameAnimation>(); leftAnimation.UI = true; leftAnimation.showFrame(6 + (leftAnimation.safHead.count3[0] == 0 ? 1 : leftAnimation.safHead.count3[0])); trans = obj.transform; trans.SetParent(left.transform); trans.localScale = Vector3.one; trans.localPosition = Vector3.zero; leftInfoUI.gameObject.SetActive(true); leftInfoUI.setValue(lt.HP, lt.HPMax, lt.Name); if (side == GameBattleAttackResultSide.Left) { path = "Prefab/Sprite/man" + GameDefine.getString3(lt.Sprite) + "/" + GameDefine.getString3(lt.Sprite); path += (result.type == GameBattleAttackResultPhysical.Type.Block ? "ab" : "a"); GameObject object1 = Resources.Load <GameObject>(path); if (object1 == null) { onShowOver(); return; } obj = Instantiate <GameObject>(object1); attackerAnimation = obj.GetComponent <GameAnimation>(); attackerAnimation.UI = true; attackerAnimation.onAnimationEvent = onAnimationEvent; trans = obj.transform; trans.SetParent(left.transform); trans.localScale = Vector3.one; trans.localPosition = Vector3.zero; defencerAnimation = rightAnimation; RectTransform trans1 = left.GetComponent <RectTransform>(); trans1.SetSiblingIndex(3); rangedAttack = (lt.AttackType == GameUnitAttackType.Ranged); if (rangedAttack) { rightAnimation.clearAnimation(); } } else { path = "Prefab/Sprite/man" + GameDefine.getString3(rt.Sprite) + "/" + GameDefine.getString3(rt.Sprite); path += (result.type == GameBattleAttackResultPhysical.Type.Block ? "ab" : "a"); GameObject object1 = Resources.Load <GameObject>(path); if (object1 == null) { onShowOver(); return; } obj = Instantiate <GameObject>(object1); attackerAnimation = obj.GetComponent <GameAnimation>(); attackerAnimation.UI = true; attackerAnimation.onAnimationEvent = onAnimationEvent; trans = obj.transform; trans.SetParent(right.transform); trans.localScale = Vector3.one; trans.localPosition = Vector3.zero; defencerAnimation = leftAnimation; RectTransform trans1 = right.GetComponent <RectTransform>(); trans1.SetSiblingIndex(3); rangedAttack = (rt.AttackType == GameUnitAttackType.Ranged); if (rangedAttack) { leftAnimation.clearAnimation(); } } attackerAnimation.otherGameAnimation = defencerAnimation; if (o) { onShowOver(); } else { scale = 2.0f; alpha = 0.1f; time = 0.0f; alphaAdd = true; startFade = true; updateStage(); } }
public void showSkillMap(byte f, GameSkill m, GameBattleUnit lt, GameBattleUnit rt, GameBattleAttackMapDirection dir, GameBattleAttackResultSide s, List <GameBattleAttackResultSkill> r, OnEventOver over) { if (m.BattleType == GameSkillBattleType.Normal || m.BattleType == GameSkillBattleType.Map) { return; } clear(); skill = m; direction = dir; onEventOver = over; resultSkill = r; result = null; side = s; isShow = true; mapAttack = true; overUnShow = true; showAdd = false; GameUserData.instance.LastSkillID = skill.ID; gameObject.SetActive(true); leftUnit = lt; rightUnit = rt; string path = "Prefab/Stage/Stage" + GameDefine.getString2(GameUserData.instance.Stage) + "/FLOOR_"; path += GameDefine.getString2(GameUserData.instance.Stage); GameObject gameObjectFloor = Instantiate <GameObject>(Resources.Load <GameObject>(path)); floorAnimation = gameObjectFloor.GetComponent <GameAnimation>(); floorAnimation.UI = true; floorAnimation.showFrame(f); floorAnimation.transform.SetParent(floorTrans); floorAnimation.transform.localScale = Vector3.one; floorAnimation.transform.localPosition = Vector3.zero; if (side == GameBattleAttackResultSide.Left) { path = "Prefab/Sprite/man" + GameDefine.getString3(lt.Sprite) + "/"; path += (GameDefine.getString3(lt.Sprite) + "MISC"); GameObject obj = Instantiate <GameObject>(Resources.Load <GameObject>(path)); leftAnimation = obj.GetComponent <GameAnimation>(); leftAnimation.UI = true; leftAnimation.showFrame(6 + (leftAnimation.safHead.count3[0] == 0 ? 1 : leftAnimation.safHead.count3[0])); Transform trans = obj.transform; trans.SetParent(left.transform); trans.localScale = Vector3.one; trans.localPosition = Vector3.zero; leftInfoUI.gameObject.SetActive(true); leftInfoUI.setValue(lt.HP, lt.HPMax, lt.Name); rightInfoUI.gameObject.SetActive(false); path = "Prefab/Sprite/man" + GameDefine.getString3(lt.Sprite) + "/" + GameDefine.getString3(lt.Sprite); path += (m.BattleSprite > 0 ? "-" + m.BattleSprite : ""); path += "s"; obj = Instantiate <GameObject>(Resources.Load <GameObject>(path)); attackerAnimation = obj.GetComponent <GameAnimation>(); attackerAnimation.UI = true; attackerAnimation.onAnimationEvent = onAnimationEvent; trans = obj.transform; trans.SetParent(left.transform); trans.localScale = Vector3.one; trans.localPosition = Vector3.zero; defencerAnimation = null; } else { path = "Prefab/Sprite/man" + GameDefine.getString3(rt.Sprite) + "/"; path += (GameDefine.getString3(rt.Sprite) + "MISC"); GameObject obj = Instantiate <GameObject>(Resources.Load <GameObject>(path)); rightAnimation = obj.GetComponent <GameAnimation>(); rightAnimation.UI = true; rightAnimation.showFrame(6 + (rightAnimation.safHead.count3[0] == 0 ? 1 : rightAnimation.safHead.count3[0])); Transform trans = obj.transform; trans.SetParent(right.transform); trans.localScale = Vector3.one; trans.localPosition = Vector3.zero; rightInfoUI.gameObject.SetActive(true); rightInfoUI.setValue(rt.HP, rt.HPMax, rt.Name); leftInfoUI.gameObject.SetActive(false); path = "Prefab/Sprite/man" + GameDefine.getString3(rt.Sprite) + "/" + GameDefine.getString3(rt.Sprite); path += (m.BattleSprite > 0 ? "-" + m.BattleSprite : ""); path += "s"; obj = Instantiate <GameObject>(Resources.Load <GameObject>(path)); attackerAnimation = obj.GetComponent <GameAnimation>(); attackerAnimation.UI = true; attackerAnimation.onAnimationEvent = onAnimationEvent; trans = obj.transform; trans.SetParent(right.transform); trans.localScale = Vector3.one; trans.localPosition = Vector3.zero; defencerAnimation = null; } scale = 2.0f; alpha = 0.1f; time = 0.0f; alphaAdd = true; startFade = true; updateStage(); }