/// <summary> /// 注册输入 /// </summary> protected virtual void RegisterInput() { if (this.InputRegistered) { return; } #if !UNITY_EDITOR && UNITY_ANDROID CupMotionManager.start(); CupMotionManager.addShakeListener(this._CupShake); //摇晃 CupMotionManager.addPoseChangeListener(this._CupPoseChanged); //姿势 CupMotionManager.addTiltStatusChangeEventListener(this._CupTiltStatusChanged); //倾斜 CupKeyEventHookStaticManager.addPowerKeyPressCallBack(this._PowerClick); if (!this.Registered) { CupKeyEventHookStaticManager.addPowerKeyLongPressCallBack(this._PowerHold); } TouchLeftStaticManager.start(); TouchLeftStaticManager.addTapListener(this._CupTapLeft); TouchLeftStaticManager.addDoubleTapListener(this._CupDoubleTapLeft); TouchLeftStaticManager.addSwipeUpwardListener(this._CupLeftSwipeUp); TouchLeftStaticManager.addSwipeDownwardListener(this._CupLeftSwipeDown); TouchLeftStaticManager.addSwipeUpAndDownListener(this._CupLeftSwipeUpDown); TouchRightStaticManager.start(); TouchRightStaticManager.addTapListener(this._CupTapRight); TouchRightStaticManager.addDoubleTapListener(this._CupDoubleTapRight); TouchRightStaticManager.addSwipeUpwardListener(this._CupRightSwipeUp); TouchRightStaticManager.addSwipeDownwardListener(this._CupRightSwipeDown); TouchRightStaticManager.addSwipeUpAndDownListener(this._CupRightSwipeUpDown); #else dispatcher.UpdateListener(true, MainKeys.PowerClick, this._PowerClick); if (!this.Registered) { dispatcher.UpdateListener(true, MainKeys.PowerHold, this._PowerHold); } dispatcher.UpdateListener(true, MainKeys.CupShake, this._CupShake); dispatcher.UpdateListener(true, MainKeys.CupTiltLeft, this._CupTiltLeft); dispatcher.UpdateListener(true, MainKeys.CupTiltRight, this._CupTiltRight); dispatcher.UpdateListener(true, MainKeys.CupKeepFlat, this._CupKeepFlat); dispatcher.UpdateListener(true, MainKeys.CupTapLeft, this._CupTapLeft); dispatcher.UpdateListener(true, MainKeys.CupTapRight, this._CupTapRight); dispatcher.UpdateListener(true, MainKeys.CupDoubleTapLeft, this._CupDoubleTapLeft); dispatcher.UpdateListener(true, MainKeys.CupDoubleTapRight, this._CupDoubleTapRight); dispatcher.UpdateListener(true, MainKeys.CupLeftSwipeUp, this._CupLeftSwipeUp); dispatcher.UpdateListener(true, MainKeys.CupLeftSwipeDown, this._CupLeftSwipeDown); dispatcher.UpdateListener(true, MainKeys.CupLeftSwipeUpDown, this._CupLeftSwipeUpDown); dispatcher.UpdateListener(true, MainKeys.CupRightSwipeUp, this._CupRightSwipeUp); dispatcher.UpdateListener(true, MainKeys.CupRightSwipeDown, this._CupRightSwipeDown); dispatcher.UpdateListener(true, MainKeys.CupRightSwipeUpDown, this._CupRightSwipeUpDown); #endif this.InputRegistered = true; }
private void ShowLowBattery(BatteryStatus lowBattery) { myStatus = lowBattery; if (myStatus == BatteryStatus.LowBattery_10) { FlurryUtil.LogEvent("Petscreen_LowBattery_10_Ani_View"); } else { FlurryUtil.LogEvent("Petscreen_LowBattery_20_Ani_View"); } if (this.PlayerDataManager.LanguageInitialized())//设置过语言后才能播放此声音 { SoundPlayer.GetInstance().PlaySoundType("system_charging_low_battery_in"); } if (TopViewHelper.Instance.IsInGuideView()) { ShowSmallBatteryIcon(); } else { lowBatteryGp.AnimationState.ClearTracks(); smallBattery.SetActive(false); backBtn.SetActive(true); backImg.gameObject.SetActive(true); backImg.DOFade(0.8f, 0.5f); lowBatteryGp.gameObject.SetActive(true); lowBatteryGp.AnimationState.SetAnimation(1, "enter_" + GetPostfixOfAnimation(), false); lowBatteryGp.AnimationState.Complete += delegate(TrackEntry trackEntry) { if (trackEntry.trackIndex == 1) { lowBatteryGp.AnimationState.ClearTracks(); lowBatteryGp.AnimationState.SetAnimation(3, "idle_" + GetPostfixOfAnimation(), true); #if (UNITY_ANDROID) && (!UNITY_EDITOR) CupKeyEventHookStaticManager.addPowerKeyPressCallBack(PowerKeyPressUp); #endif } }; TopViewHelper.Instance.AddTopView(TopViewHelper.ETopView.eLowBattary); } }
private void OnEnable() { #if (UNITY_ANDROID) && (!UNITY_EDITOR) CupKeyEventHookStaticManager.addPowerKeyPressCallBack(powerKeyPressUp); #endif }