public void Clear() { fishMgr.Clear(); fishPoolMgr.Clear(); UILotteryMgr.Instance.Clear(); RemoveNetListenEvent(); //Add by Xhj. Clear stuff uIDHookMap.Clear(); hook = null; oHook = null; if (_oPlayer != null) { uIDPlayerMap.Remove(_oPlayer.UID); } }
//1. get hook gameObject //2. add component //3. activate //4. Init //5. OnEnter //6. Add it into Map public void NewEnter(Message msg) { MessageSycHook allhookInfo = JsonReader.Deserialize <MessageSycHook>(msg.rawString); int iCount = allhookInfo.playerList.Count; if (iCount == 1) { HookInfo info = allhookInfo.playerList[0]; this.PassTime = info.enterTime; HookPos hookPos = (HookPos)Enum.Parse(typeof(HookPos), info.chairId); AllStuffNeeded allStuff = SceneMgr.Instance.hookPosAllStuffMap[hookPos]; hook = allStuff.gmObjRealPoleEnd.AddComponent <Hook>(); allStuff.gmObjBoat.SetActive(true); FloatEffect floatEffect = allStuff.gmObjBoat.AddComponent <FloatEffect>(); floatEffect.Init(); floatEffect.StartEffect(); hook.gameObject.SetActive(true); hook.Init(hookPos); hook.OnEnter(info.enterTime, _player, allStuff); uIDHookMap.Add(info.uid, hook); _raisePlayerInitCompleteEvent(hook.hookPos); _raisePlayerChangeEvent(hook.hookPos, true); _raiseScoreChangeEvent(hook.hookPos, _player.Score); raiseLotteryChangeEvent(hook.hookPos, _player.Lottery); raiseHookPowerEvent(1); } else if (iCount == 2) { this.PassTime = Mathf.Max(allhookInfo.playerList[0].enterTime, allhookInfo.playerList[1].enterTime); for (int i = 0; i < iCount; i++) { HookInfo info = allhookInfo.playerList[i]; if (info.uid == Game.Instance.player.UID) { if (hook == null) { this.PassTime = info.enterTime; HookPos hookPos = (HookPos)Enum.Parse(typeof(HookPos), info.chairId); AllStuffNeeded allStuff = SceneMgr.Instance.hookPosAllStuffMap[hookPos]; hook = allStuff.gmObjRealPoleEnd.AddComponent <Hook>(); allStuff.gmObjBoat.SetActive(true); FloatEffect floatEffect = allStuff.gmObjBoat.AddComponent <FloatEffect>(); floatEffect.Init(); floatEffect.StartEffect(); hook.gameObject.SetActive(true); hook.Init(hookPos); hook.OnEnter(info.enterTime, _player, allStuff); uIDHookMap.Add(info.uid, hook); _raisePlayerInitCompleteEvent(hook.hookPos); _raisePlayerChangeEvent(hook.hookPos, true); _raiseScoreChangeEvent(hook.hookPos, _player.Score); raiseLotteryChangeEvent(hook.hookPos, _player.Lottery); raiseHookPowerEvent(1); } } else if (info.uid != Game.Instance.player.UID) { HookPos hookPos = (HookPos)Enum.Parse(typeof(HookPos), info.chairId); AllStuffNeeded allStuff = SceneMgr.Instance.hookPosAllStuffMap[hookPos]; if (oHook == null) { oHook = allStuff.gmObjRealPoleEnd.AddComponent <OHook>(); //Assume that player can't change position in level oHook.Init(hookPos); FloatEffect floatEffect = allStuff.gmObjBoat.AddComponent <FloatEffect>(); floatEffect.Init(); floatEffect.StartEffect(); } allStuff.gmObjBoat.SetActive(true); oHook.gameObject.SetActive(true); uIDHookMap.Add(info.uid, oHook); //Init oPlayer(no definition, just intialize it) _oPlayer.UID = info.uid; _oPlayer.Score = info.score; _oPlayer.Lottery = info.lottery; uIDPlayerMap.Add(info.uid, _oPlayer); oHook.OnEnter(info.enterTime, _oPlayer, allStuff); oHook.ChangeHooks(info.hook); _raisePlayerChangeEvent(oHook.hookPos, true); _raiseScoreChangeEvent(oHook.hookPos, _oPlayer.Score); raiseLotteryChangeEvent(oHook.hookPos, _oPlayer.Lottery); } } } else { DebugLogger.LogWarning(eLogType.LT_LOGIC, iCount + " hooks, out of bound!"); } }