private void On_Swipe(Gesture gesture) { if (!this.TouchSwitcher) { return; } if (MessageManager.Instance.IsActivate && !MessageManager.Instance.IsSerializeToLocal) { return; } if (touchBegined) { deltaSpeedX = -gesture.deltaPosition.x; //float distanceX = deltaSpeedX * speedRate; float destX = (gesture.startPosition.x - gesture.position.x) * destRate + startCameraPosX; //MainUICamera.getInstance().move(distanceX, 0); //Debuger.Log("aaaa destX = " + destX + " startCameraPosX = " + startCameraPosX + " gesture.startPosition = " + gesture.startPosition + " gesture.position = " + gesture.position); MainUICamera.getInstance().moveTo(destX, 0); //if (MessageManager.Instance.IsActivate && MessageManager.Instance.IsSerializeToLocal) //{ // SwipeAction swipeAction = new SwipeAction(destX, 0, deltaSpeedX, RemoteModel.Instance.CurrentTime); // MessageManager.Instance.serializeToLocal(swipeAction, MessageManager.DEST_PATH_DRAG_EVENT); //} Debuger.Log("destX:" + destX); mNewMoveEvt = true; } }
void OnDisable() { MainUICamera.getInstance().UnRegisterGesture(); UIMainScene.getInstance().OnDisable(); if (playerEntity != null) { playerEntity.removeEventListener(PlayerEntity.MainNinjaChangeEvent, UpdateActor); } KHUIManager inst = KHUIManager.getInstance(); if (inst != null && inst.Dispatcher != null) { inst.Dispatcher.removeEventListener("OnOpenWindow", OnOpenOtherWindow); inst.Dispatcher.removeEventListener("OnCloseWindow", OnCloseOtherWindow); } mainModel.Dispatcher.removeEventListener(UIMainScene.EVT_REQ_SCENE_CHANGE_CHECK, OnReqSceneChangeCheckRecived); KHSceneSettingModel sceneSettingModel = KHPluginManager.Instance.GetModel(KHSceneSettingPlugin.pluginName) as KHSceneSettingModel; sceneSettingModel.Dispatcher.removeEventListener(KHSceneSettingModel.SELECT_SCENE_SETTING_EVT, OnRreshSceneSetting); sceneSettingModel.Dispatcher.removeEventListener(KHSceneSettingModel.PREVIEW_SCENE_SETTING_CANCEL_EVT, OnRreshSceneSetting); sceneSettingModel.Dispatcher.removeEventListener(KHSceneSettingModel.PREVIEW_SCENE_SETTING_EVT, OnRreshSceneSetting); UnReigstBuildingButtonClickEvtProc(); }
static public MainUICamera getInstance() { if (_Instnace == null) { _Instnace = new MainUICamera(); } return(_Instnace); }
//private int lastDirection; //private Vector3 lastPos; public void update(float deltaTime) { //if (!touchSwitcher) { return; } if (!touchBegined && Mathf.Abs(deltaSpeedX) >= 0.001f) { float distanceX = deltaSpeedX * speedRate; MainUICamera.getInstance().move(distanceX, 0); deltaSpeedX -= deltaSpeedX * 0.06f; //Debuger.Log("MCamera.update deltaSpeedX = " + deltaSpeedX); } //cameraPos = (destPos - cameraPos) * 0.3f + cameraPos; this.RefreshCameraPosBy_DestPos(); //Debuger.LogWarning("cameraPos.." + cameraPos.ToString()); if (mNewMoveEvt && Mathf.Abs(destPos.x - cameraPos.x) < 0.01f) { mNewMoveEvt = false; Dispatcher.dispatchEvent(new KHEvent(EVT_MainUICamera_MOVE) { data = cameraPos }); } //if (this.focus != null) //{ // Vector3 pos = this.focus.transform.position; // int direction = this.focus.getMoveComponet().getDirection(); // pos.x += direction == Direction.LEFT ? -offset : offset; // pos = this.adjustPosition(pos); // float v = V_A; // if (direction != lastDirection || Mathf.Abs(lastPos.x - pos.x) < 0.025) // v = TurnV_A; // lastPos = pos; // pos.x = (pos.x - this.unityCamera.position.x) * v + this.unityCamera.position.x; // pos.y = (pos.y - this.unityCamera.position.y) * v + this.unityCamera.position.y; // this.locateAt(pos, false); // lastDirection = direction; //} //List<KHCameraBehaviour> toRemove = new List<KHCameraBehaviour>(); //foreach (KHCameraBehaviour behaviour in this.cameraBehaviourList) //{ // if (behaviour.update(deltaTime)) // 结束 // { // toRemove.Add(behaviour); // } //} //foreach (KHCameraBehaviour behaviour in toRemove) //{ // this.cameraBehaviourList.Remove(behaviour); //} }
void Update() { MainUICamera.getInstance().update(Time.deltaTime); UIMainScene.getInstance().Update(); // if (Input.GetKeyDown (KeyCode.A)) // { // Debuger.Log("KeyCode........................................A"); // //UIActivityTipView.ShowTip("ABC", "12345"); // //KHPluginManager.Instance.SendMessage(UltimateKillPlugin.pluginName, UltimateKillZhanjiAndRewardOperation.OpenZhanjiRewardView); // //KHPluginManager.Instance.SendMessage(UltimateKillPlugin.pluginName, UltimateKillOperation.OpenRewardView); // // UIShareMainCityView.TopName = KHUIManager.getInstance ().GetTopWindow ().name; // KHPluginManager.Instance.SendMessage(SharePlugin.PLUGIN_NAME, "ShowView", new ShowViewArgument(UIDef.SHARE_MAINCITY_VIEW, false, null)); // //UIActivityTipView.ShowTipV2(KHDataManager.CONFIG.GetFeatureDefineTitle1(SystemConfigDef.Match), KHDataManager.CONFIG.GetFeatureDefineDes1(SystemConfigDef.Match),""); // //单触发定时器:Invoke(string method, int Secondtimes) 过Secondtimes 秒后触发method 函数, // //重复触发InvokeRepeating(string method, int Secondtimetowake, int Secondtimetonext)每Secondtimetonext触发下一次 // } }