diff --git a/Assets/ChillConnect/FGUI/package/GameResult_08/GameResult_08Binder.cs b/Assets/ChillConnect/FGUI/package/GameResult_08/GameResult_08Binder.cs index a4350c4..08780d9 100644 --- a/Assets/ChillConnect/FGUI/package/GameResult_08/GameResult_08Binder.cs +++ b/Assets/ChillConnect/FGUI/package/GameResult_08/GameResult_08Binder.cs @@ -12,7 +12,6 @@ namespace FGUI.GameResult_08 UIObjectFactory.SetPackageItemExtension(cash_broad.URL, typeof(cash_broad)); UIObjectFactory.SetPackageItemExtension(com_arrow_end.URL, typeof(com_arrow_end)); UIObjectFactory.SetPackageItemExtension(com_arrow_end_again.URL, typeof(com_arrow_end_again)); - UIObjectFactory.SetPackageItemExtension(btn_claim.URL, typeof(btn_claim)); UIObjectFactory.SetPackageItemExtension(com_end.URL, typeof(com_end)); } } diff --git a/Assets/ChillConnect/FGUI/package/GameResult_08/btn_claim.cs b/Assets/ChillConnect/FGUI/package/GameResult_08/btn_claim.cs deleted file mode 100644 index 591ace0..0000000 --- a/Assets/ChillConnect/FGUI/package/GameResult_08/btn_claim.cs +++ /dev/null @@ -1,29 +0,0 @@ -/** This is an automatically generated class by FairyGUI. Please do not modify it. **/ - -using FairyGUI; -using FairyGUI.Utils; - -namespace FGUI.GameResult_08 -{ - public partial class btn_claim : GButton - { - public Controller state; - public GImage ad_icon; - public GImage img_saveingpot; - public const string URL = "ui://8sjqw0q3rsd42i"; - - public static btn_claim CreateInstance() - { - return (btn_claim)UIPackage.CreateObject("GameResult_08", "btn_claim"); - } - - public override void ConstructFromXML(XML xml) - { - base.ConstructFromXML(xml); - - state = GetControllerAt(0); - ad_icon = (GImage)GetChildAt(1); - img_saveingpot = (GImage)GetChildAt(2); - } - } -} \ No newline at end of file diff --git a/Assets/ChillConnect/FGUI/package/GameResult_08/btn_claim.cs.meta b/Assets/ChillConnect/FGUI/package/GameResult_08/btn_claim.cs.meta deleted file mode 100644 index 6186947..0000000 --- a/Assets/ChillConnect/FGUI/package/GameResult_08/btn_claim.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e0993c012a030ad4391f9c97f177470c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ChillConnect/FGUI/package/GameResult_08/com_arrow_end.cs b/Assets/ChillConnect/FGUI/package/GameResult_08/com_arrow_end.cs index 531f22e..5161e35 100644 --- a/Assets/ChillConnect/FGUI/package/GameResult_08/com_arrow_end.cs +++ b/Assets/ChillConnect/FGUI/package/GameResult_08/com_arrow_end.cs @@ -8,9 +8,9 @@ namespace FGUI.GameResult_08 public partial class com_arrow_end : GComponent { public GTextField title; - public GButton btn_back; public GButton btn_watchAd; public GButton btn_restart; + public GButton btn_back; public const string URL = "ui://8sjqw0q3rsd42f"; public static com_arrow_end CreateInstance() @@ -23,9 +23,9 @@ namespace FGUI.GameResult_08 base.ConstructFromXML(xml); title = (GTextField)GetChildAt(3); - btn_back = (GButton)GetChildAt(4); - btn_watchAd = (GButton)GetChildAt(9); - btn_restart = (GButton)GetChildAt(10); + btn_watchAd = (GButton)GetChildAt(8); + btn_restart = (GButton)GetChildAt(9); + btn_back = (GButton)GetChildAt(10); } } } \ No newline at end of file diff --git a/Assets/ChillConnect/FGUI/package/GameResult_08/com_end.cs b/Assets/ChillConnect/FGUI/package/GameResult_08/com_end.cs index c1b3c74..132f639 100644 --- a/Assets/ChillConnect/FGUI/package/GameResult_08/com_end.cs +++ b/Assets/ChillConnect/FGUI/package/GameResult_08/com_end.cs @@ -25,6 +25,7 @@ namespace FGUI.GameResult_08 public GButton btn_claim; public GRichTextField text_award_2; public GRichTextField text_award_3; + public com_arrow_end com_arrow_end; public Transition t0; public Transition t2; public const string URL = "ui://8sjqw0q3sebxk"; @@ -56,6 +57,7 @@ namespace FGUI.GameResult_08 btn_claim = (GButton)GetChildAt(23); text_award_2 = (GRichTextField)GetChildAt(24); text_award_3 = (GRichTextField)GetChildAt(25); + com_arrow_end = (com_arrow_end)GetChildAt(26); t0 = GetTransitionAt(0); t2 = GetTransitionAt(1); } diff --git a/Assets/Resources/ChillConnectAssets/FGUI/GameResult_08_atlas0.png b/Assets/Resources/ChillConnectAssets/FGUI/GameResult_08_atlas0.png index f9585ff..7799dff 100644 Binary files a/Assets/Resources/ChillConnectAssets/FGUI/GameResult_08_atlas0.png and b/Assets/Resources/ChillConnectAssets/FGUI/GameResult_08_atlas0.png differ diff --git a/Assets/Resources/ChillConnectAssets/FGUI/GameResult_08_fui.bytes b/Assets/Resources/ChillConnectAssets/FGUI/GameResult_08_fui.bytes index ed98082..044a8b5 100644 Binary files a/Assets/Resources/ChillConnectAssets/FGUI/GameResult_08_fui.bytes and b/Assets/Resources/ChillConnectAssets/FGUI/GameResult_08_fui.bytes differ diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index a2575fe..fe95614 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -1099,6 +1099,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1361344199} + - component: {fileID: 1361344200} m_Layer: 0 m_Name: GameObject m_TagString: Untagged @@ -1121,6 +1122,18 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1361344200 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1361344198} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 36de1e54129c45dc8fc672793fee00fe, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1442936684 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/InputHelper.cs b/Assets/Scripts/InputHelper.cs new file mode 100644 index 0000000..09f02db --- /dev/null +++ b/Assets/Scripts/InputHelper.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +public class InputHelper : MonoBehaviour +{ + public static InputHelper Instance; + + private void Awake() + { + if (Instance == null) Instance = this; + else Destroy(gameObject); + } + + // 提供输入状态给UI层调用 + public int TouchCount => Input.touchCount; + public Touch GetTouch(int index) => Input.GetTouch(index); + public bool GetMouseButtonDown(int button) => Input.GetMouseButtonDown(button); + public bool GetMouseButton(int button) => Input.GetMouseButton(button); + public bool GetMouseButtonUp(int button) => Input.GetMouseButtonUp(button); + public Vector3 MousePosition => Input.mousePosition; + // public float GetMouseWheelDelta() => Input.GetMouseWheelDelta(); +} \ No newline at end of file diff --git a/Assets/Scripts/InputHelper.cs.meta b/Assets/Scripts/InputHelper.cs.meta new file mode 100644 index 0000000..9940f18 --- /dev/null +++ b/Assets/Scripts/InputHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 36de1e54129c45dc8fc672793fee00fe +timeCreated: 1781427648 \ No newline at end of file diff --git a/Assets/Scripts/ModuleUI/ArrowGame/ArrowGameUI.cs b/Assets/Scripts/ModuleUI/ArrowGame/ArrowGameUI.cs index cc3aea2..ce2a889 100644 --- a/Assets/Scripts/ModuleUI/ArrowGame/ArrowGameUI.cs +++ b/Assets/Scripts/ModuleUI/ArrowGame/ArrowGameUI.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; +using DG.Tweening; using FairyGUI; using FGUI.Arrow_game; using UnityEngine; @@ -160,6 +161,14 @@ namespace ChillConnect { ui = baseUI as com_arrow_game; } + + // 新增坐标转换方法 + private Vector2 UnityMouseToFGUIPos(Vector2 unityPos) + { + float x = unityPos.x; + float y = Screen.height - unityPos.y; + return new Vector2(x, y); + } public override void OnUpdate() { @@ -170,46 +179,52 @@ namespace ChillConnect // } // // ========= 编辑器模拟触摸(仅编辑模式生效) ========= + + // ========== 编辑器鼠标拖拽 ========== #if UNITY_EDITOR - //1. 鼠标左键 = 单指拖拽 - // Debug.Log($"Input.GetMouseButtonDown======={Input.GetMouseButtonDown(0)}"); - if (Input.GetMouseButtonDown(0)) + float moveThreshold = 1f; // 移动阈值,大于这个值才算有效拖动 + + // 鼠标按下:仅初始化状态和起点 + if (InputHelper.Instance.GetMouseButtonDown(0)) { - _lastTouchPos = Input.mousePosition; + Vector2 unityPos = InputHelper.Instance.MousePosition; + _lastTouchPos = UnityMouseToFGUIPos(unityPos); _isDraging = true; - } - if (Input.GetMouseButton(0) && _isDraging) - { - Vector2 curMousePos = Input.mousePosition; - Vector2 offset = curMousePos - _lastTouchPos; - MoveContainer(offset); - _lastTouchPos = curMousePos; - } - if (Input.GetMouseButtonUp(0)) - { - _isDraging = false; + Debug.Log("鼠标按下,开始拖拽"); + return; // 本帧直接返回,不执行拖动逻辑 } - // 2. 鼠标滚轮 = 双指缩放 - // float scrollDelta = Input.GetMouseWheelDelta(); - // if (Mathf.Abs(scrollDelta) > 0) - // { - // float curScale = _viewContainer.scaleX; - // curScale += scrollDelta * 0.1f; - // curScale = Mathf.Clamp(curScale, _minScale, _maxScale); - // - // _viewContainer.scaleX = curScale; - // _viewContainer.scaleY = curScale; - // _zoomSlider.value = GetSliderValueByScale(curScale); - // } + // 拖拽中:按住左键 + 拖拽标记为true + if (_isDraging && InputHelper.Instance.GetMouseButton(0)) + { + Vector2 unityPos = InputHelper.Instance.MousePosition; + Vector2 curMousePos = UnityMouseToFGUIPos(unityPos); + Vector2 offset = curMousePos - _lastTouchPos; + + Debug.Log($"curMousePos=={curMousePos} _lastTouchPos=={_lastTouchPos} offset=={offset}"); + + // 只有偏移超过阈值才移动 & 更新基准点 + if (offset.magnitude > moveThreshold) + { + MoveContainer(offset); + _lastTouchPos = curMousePos; // 移动后再刷新起点 + } + } + + // 鼠标抬起,结束拖拽 + if (InputHelper.Instance.GetMouseButtonUp(0)) + { + _isDraging = false; + Debug.Log("鼠标抬起,结束拖拽"); + } #endif // ========= 双指 = 缩放(优先级最高) ========= - if (Input.touchCount == 2) + if (InputHelper.Instance.TouchCount == 2) { _isDraging = false; - Touch t0 = Input.GetTouch(0); - Touch t1 = Input.GetTouch(1); + Touch t0 = InputHelper.Instance.GetTouch(0); + Touch t1 = InputHelper.Instance.GetTouch(1); float currentDis = Vector2.Distance(t0.position, t1.position); if (!_isTwoFingerTouch) @@ -236,9 +251,9 @@ namespace ChillConnect } } // ========= 单指 = 拖拽平移 ========= - else if (Input.touchCount == 1) + else if (InputHelper.Instance.TouchCount == 1) { - Touch touch = Input.GetTouch(0); + Touch touch = InputHelper.Instance.GetTouch(0); Vector2 curTouchPos = touch.position; if (touch.phase == TouchPhase.Began) @@ -820,6 +835,7 @@ namespace ChillConnect /// 移动容器 + 边界限制,防止完全拖出屏幕 private void MoveContainer(Vector2 offset) { + Debug.Log($"[arrow] 移动容器:{offset}"); float newX = _viewContainer.x + offset.x; float newY = _viewContainer.y + offset.y; @@ -1400,7 +1416,42 @@ namespace ChillConnect arrow.isMoving = false; } - uiCtrlDispatcher.Dispatch(UICtrlMsg.LevelSuccessUI_Open, isSuccess); + // uiCtrlDispatcher.Dispatch(UICtrlMsg.LevelSuccessUI_Open, isSuccess); + + if (isSuccess) + { + GameHelper.SetLevel(GameHelper.GetLevel() + 1); + //通关成功 + float[] cash_array = GameHelper.GetRewardValue(2); + + var temp = new SuccessData(); + temp.IsWin = true; + temp.cash_number = cash_array[0]; + temp.rate = (int)cash_array[1]; + temp.IsLevelSuccess = true; + temp.IsH5Reward = false; + temp.boost_array = GameHelper.GetRewardBoost(2); + DOVirtual.DelayedCall(0.5f, () => + { + UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Open, temp); + }); + } + else + { + //通关失败 + float[] cash_array = GameHelper.GetRewardValue(2); + + var temp = new SuccessData(); + temp.IsWin = false; + temp.cash_number = cash_array[0]; + temp.IsLevelSuccess = true; + temp.IsH5Reward = false; + temp.boost_array = GameHelper.GetRewardBoost(2); + DOVirtual.DelayedCall(0.5f, () => + { + UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Open, temp); + }); + } } // 重新开始本局 diff --git a/Assets/Scripts/ModuleUI/GameAgain/GameAgainUI.cs b/Assets/Scripts/ModuleUI/GameAgain/GameAgainUI.cs index 20538a1..bf01a6a 100644 --- a/Assets/Scripts/ModuleUI/GameAgain/GameAgainUI.cs +++ b/Assets/Scripts/ModuleUI/GameAgain/GameAgainUI.cs @@ -51,7 +51,7 @@ namespace ChillConnect { ui.btn_restart.SetClick(() => { - UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Open); + UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Open, args); CtrlCloseUI(); }); diff --git a/Assets/Scripts/ModuleUI/GameResult/GameResultUI.cs b/Assets/Scripts/ModuleUI/GameResult/GameResultUI.cs index 8228720..b97431a 100644 --- a/Assets/Scripts/ModuleUI/GameResult/GameResultUI.cs +++ b/Assets/Scripts/ModuleUI/GameResult/GameResultUI.cs @@ -10,7 +10,6 @@ using IgnoreOPS; using Newtonsoft.Json; using Spine.Unity; using UnityEngine; -using btn_claim = FGUI.Common_01.btn_claim; using Random = UnityEngine.Random; namespace ChillConnect @@ -19,10 +18,15 @@ namespace ChillConnect { private GameResultUICtrl ctrl; private GameResultModel model; - private com_arrow_end ui; - + private com_end ui; + private bool IsWin; + private bool IsLevelSuccess; + private bool IsH5Reward; + + private float AwardNum = 20; private Action closeCallback; - + + private int AwardRate = 10; public GameResultUI(GameResultUICtrl ctrl) : base(ctrl) { @@ -33,10 +37,10 @@ namespace ChillConnect protected override void SetUIInfo(UIInfo uiInfo) { uiInfo.packageName = "GameResult_08"; - uiInfo.assetName = "com_arrow_end"; + uiInfo.assetName = "com_end"; uiInfo.layerType = UILayerType.Popup; - uiInfo.isNeedOpenAnim = true; - uiInfo.isNeedCloseAnim = true; + uiInfo.isNeedOpenAnim = false; + uiInfo.isNeedCloseAnim = false; uiInfo.isNeedUIMask = true; } @@ -49,21 +53,106 @@ namespace ChillConnect protected override void OnClose() { + // GameHelper.SetCloseResult(false); + closeCallback?.Invoke(); + // if (IsLevelSuccess && !GameHelper.is_first_login) + // UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Open, true); + + } // protected override void OnBind() { - ui = baseUI as com_arrow_end; + ui = baseUI as com_end; } private SuccessData successData_; - protected override void OnOpenBefore(object args) { - ((btn_claim)ui.btn_watchAd).state.selectedIndex = DataMgr.ArrowResultLevel.Value == 1 ? 1 : 0; - ((btn_claim)ui.btn_watchAd).title = DataMgr.ArrowResultLevel.Value == 1 ? "Free Revive" : "Revive"; + if (Screen.safeArea.y != 0) + {//刘海屏 + ui.btn_gold.y += 68; + } + + var anim_paly = FXManager.Instance.SetFx(ui.btn_gold.GetChild("gold_anim") as GGraph, Fx_Type.fx_coin, ref closeCallback); + anim_paly.state.SetAnimation(0, "animation", true); + (ui.top_money as com_money).btn_ch.title = GameHelper.getDesByKey("ch_out_1"); + if (GameHelper.IsGiftSwitch()) + ui.switchgift.selectedIndex = 1; + + ui.tips_text.text = GameHelper.getDesByKey("ww_condition_lv"); + SuccessData SuccessDatas = args as SuccessData; + AwardNum = SuccessDatas.cash_number; + AwardRate = SuccessDatas.rate; + IsWin = SuccessDatas.IsWin; + + IsLevelSuccess = SuccessDatas.IsLevelSuccess; + IsH5Reward = SuccessDatas.IsH5Reward; + + successData_ = SuccessDatas; + if (!GameHelper.IsGiftSwitch()) + { + successData_.cash_number = (int)successData_.cash_number; + successData_.rate = 2; + } + // if (IsLevelSuccess && !IsH5Reward) + // { + // UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Open); + // + // GameHelper.PlayGameTimeEvent(1, () => + // { + // GameHelper.RequestGameConfig(); + // }); + // } + // else + // { + // GameHelper.SetCloseResult(true); + // } + if (!GameHelper.IsGiftSwitch()) + { + AwardNum = 20; + AwardRate = 2; + ui.btn_claim.title = "Claim(" + AwardNum + ")"; + } + else ui.btn_claim.title = "Claim(" + GameHelper.getChString((decimal)AwardNum) + ")"; + if (IsWin) + { + if (PlayerPrefs.GetFloat("soundVolume", 1.0f) > 0f) + { + AudioManager.Instance.PlayDynamicEffect(AudioConst.Victoriously); + } + + } + if (IsWin) + { + ui.win_lose.selectedIndex = 1; + } + else + { + // ui.win_lose.selectedIndex = 0; + ui.win_lose.selectedIndex = 2; + ui.lab_lose_des.text = GameHelper.getDesByKey("game_resulte_1"); + } + ui.btn_restart.SetClick(() => + { + if (!GameHelper.GetCloseResult()) + return; + GameHelper.addInterAdnumber(); + if (!IsWin) + { + GameHelper.SetLevelstate(3); + UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Open, true); + GameDispatcher.Instance.Dispatch(GameMsg.sendLog, false); + GameDispatcher.Instance.Dispatch(GameMsg.reset_game, false); + } + UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Close); + }); - ui.btn_watchAd.SetClick(() => + + ((btn_claim)ui.com_arrow_end.btn_watchAd).state.selectedIndex = DataMgr.ArrowResultLevel.Value == 1 ? 1 : 0; + ((btn_claim)ui.com_arrow_end.btn_watchAd).title = DataMgr.ArrowResultLevel.Value == 1 ? "Free Revive" : "Revive"; + + ui.com_arrow_end.btn_watchAd.SetClick(() => { if (DataMgr.ArrowResultLevel.Value == 1) { @@ -72,25 +161,212 @@ namespace ChillConnect } else if (DataMgr.ArrowResultLevel.Value == 0) { - GameHelper.ShowVideoAd("gameResult", success => - { - if (success) - { - GameDispatcher.Instance.Dispatch(GameMsg.reset_game, true); - } - }); + GameHelper.ShowVideoAd("gameResult", success => + { + if (success) + { + GameDispatcher.Instance.Dispatch(GameMsg.reset_game, true); + } + }); } CtrlCloseUI(); }); - - ui.btn_restart.SetClick(() => + ui.com_arrow_end.btn_restart.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.GameAgainUI_Open); CtrlCloseUI(); }); + + ui.com_arrow_end.btn_back.SetClick(() => + { + UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.GameAgainUI_Open); + CtrlCloseUI(); + }); + + + ui.btn_mult.GetChild("title").text = "Claim X" + AwardRate; + + if (SuccessDatas.IsH5Reward) + ui.com_ch.visible = false; + InitView(); + if (IsWin) + { + if (GameHelper.IsGiftSwitch()) + ui.text_award.text = GameHelper.Get102Str((decimal)AwardNum); + else + ui.text_award.text = ((int)AwardNum).ToString(); + + + var sk = FXManager.Instance.SetFx(ui.bg_parent, Fx_Type.fx_win, ref closeCallback); + sk.state.SetAnimation(0, "out", true); + + var sk1 = FXManager.Instance.SetFx(ui.bg_parent_title, Fx_Type.fx_winstar, ref closeCallback); + sk1.state.SetAnimation(0, "animation", false); + + } + else + { + // var sk1 = FXManager.Instance.SetFx(ui.bg_parent_fail, Fx_Type.fx_fail, ref closeCallback); + // sk1.state.SetAnimation(0, "animation", true); + + if (GameHelper.IsGiftSwitch()) + ui.text_award.text = GameHelper.Get102Str(DataMgr.Ticket.Value); + else + ui.text_award.text = DataMgr.Coin.Value.ToString(); + } + ui.com_ch.btn_cash.title = GameHelper.getDesByKey("ch_out_1"); + // if (IsWin) + // { + // if (GameHelper.IsGiftSwitch()) ui.text_award.text = GameHelper.Get102Str((decimal)AwardNum); + // else ui.text_award.text = ((int)AwardNum).ToString(); + + // var sk = FXManager.Instance.SetFx(ui.bg_parent, Fx_Type.fx_win, ref closeCallback); + // sk.state.SetAnimation(0, "out", true); + + // var sk1 = FXManager.Instance.SetFx(ui.bg_parent_title, Fx_Type.fx_win_title, ref closeCallback); + // sk1.state.SetAnimation(0, "animation", false); + + // } + // else + // { + + // if (GameHelper.IsGiftSwitch()) ui.text_award.text = GameHelper.Get102Str(DataMgr.Ticket.Value); + // else ui.text_award.text = DataMgr.Coin.Value.ToString(); + // } + + + + if (GameHelper.IsGiftSwitch()) + { + if (SaveData.GetSaveObject().LargeRewardNum < ConfigSystem.GetConfig().FreeClaims) + { + (ui.btn_mult as btn_claim3).state.selectedIndex = 1; + } + else if (ConfigSystem.GetConfig().PiggyBankSwitch == 1) + { + (ui.btn_mult.GetChild("img_saveingpot") as GImage).visible = true; + } + } + ui.btn_gold.GetChild("text_gold").text = $"{DataMgr.Coin.Value:N0}"; + ui.top_money.GetChild("text_gold").text = DataMgr.Ticket.Value.ToString(); + ui.btn_mult.SetClick(() => + { + if (!GameHelper.GetCloseResult()) + return; + if (GameHelper.IsGiftSwitch()) + { + if (SaveData.GetSaveObject().LargeRewardNum < ConfigSystem.GetConfig().FreeClaims) + { + ui.com_ch.btn_cash.SetClick(() => { }); + ui.btn_claim.SetClick(() => { }); + ui.btn_mult.SetClick(() => { }); + StartScroll(); + } + else + { + GameHelper.ShowVideoAd("reward_lobby", isSuccess => + { + if (isSuccess) + { + ui.com_ch.btn_cash.SetClick(() => { }); + ui.btn_claim.SetClick(() => { }); + ui.btn_mult.SetClick(() => { }); + StartScroll(); + } + }); + } + } + else + { + + GameHelper.ShowVideoAd("reward_lobby", isSuccess => + { + if (isSuccess) + { + ui.com_ch.btn_cash.SetClick(() => { }); + ui.btn_claim.SetClick(() => { }); + ui.btn_mult.SetClick(() => { }); + GetReward(AwardNum * 2); + } + }); + + } + + }); + ui.btn_claim.SetClick(() => + { + if (!GameHelper.GetCloseResult()) + return; + + ui.com_ch.btn_cash.SetClick(() => { }); + ui.btn_claim.SetClick(() => { }); + ui.btn_mult.SetClick(() => { }); + GetReward(AwardNum); + DOVirtual.DelayedCall(2f, () => + { + GameHelper.addInterAdnumber(); + }); + }); + //} + } + private bool isget; + private void GetReward(float awardNum) + { + if (isget) + return; + isget = true; + var rewardData = new RewardData(); + + int curr_type = 101; + Vector2 end_ = GameHelper.GetUICenterPosition(ui.btn_gold, true); + + if (GameHelper.IsGiftSwitch()) + { + curr_type = 102; + end_ = GameHelper.GetUICenterPosition(ui.top_money, true); + + } + var rewardSingleData = new RewardSingleData(curr_type, (decimal)awardNum, RewardOrigin.Play) + { + startPosition = GameHelper.GetUICenterPosition(ui.btn_mult, true), + endPosition = new Vector2(end_.x - 110, end_.y - 110), + }; + + rewardData.AddReward(rewardSingleData); + rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange; + rewardData.AddCompleted(success => + { + if (success) + { + // RefreshGold((decimal)awardNum); + + DOVirtual.DelayedCall(0.7f, () => + { + CtrlCloseUI(); + // if (IsLevelSuccess) UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Open, true); + }); + } + }); + + GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData); + DOVirtual.DelayedCall(1, () => + { + DOVirtual.Float(0, (float)DataMgr.Ticket.Value, 1, + value => { ui.top_money.GetChild("text_gold").text = ((decimal)value).ToString("0.00"); }); + }); + } + + private void RefreshGold(decimal coin = -1) + { + if (coin < 0) + { + coin = DataMgr.Coin.Value; + } + var btnCoin = ui.btn_gold as com_gold; + + CommonHelper.ShowNumAnim(btnCoin.text_gold, coin); } - protected override void OnOpen(object args) { } @@ -107,12 +383,357 @@ namespace ChillConnect #region 消息 protected override void AddListener() { + HallManager.Instance.UpdateSecondEvent += timeEvent; } protected override void RemoveListener() { + HallManager.Instance.UpdateSecondEvent -= timeEvent; } #endregion private int time_count; - + void timeEvent() + { + time_count++; + + if (time_count > 3) + { + time_count = 0; + ui.com_ch.broad.t0.Play(() => + { + var name_index = Random.Range(0, ConfigSystem.GetConfig().config_name_list.Count); + var money_index = Random.Range(0, ConfigSystem.GetConfig().config_money_list.Count); + + DateTime oldtime = DateTime.Now.AddSeconds(-Random.Range(1 * 3600, 2 * 3600)); + + // ui.com_ch.broad.cast_text.text = string.Format("Congratulations, [color=#dfad42]{0}[/color] withdrew [color=#90c04e]{1} [/color]dollars", ConfigSystem.GetConfig().config_name_list[name_index], + // ConfigSystem.GetConfig().config_money_list[money_index]); + string broad_text = String.Format(GameHelper.getDesByKey("makeup_5"), ConfigSystem.GetConfig().config_name_list[name_index], + ConfigSystem.GetConfig().config_money_list[money_index]); + ui.com_ch.broad.cast_text.text = broad_text; + + //, oldtime.Hour + ":" + (oldtime.Minute > 10 ? oldtime.Minute : "0" + oldtime.Minute) + ui.com_ch.broad.t1.Play(); + }); + } + } + //初始化页面逻辑 + private void InitView() + { + if (Screen.safeArea.y != 0) + {//刘海屏 + ui.top_group.y += 68; + } + closeCallback = null; + if (!GameHelper.IsGiftSwitch()) + return; + var name_index = Random.Range(0, ConfigSystem.GetConfig().config_name_list.Count); + var money_index = Random.Range(0, ConfigSystem.GetConfig().config_money_list.Count); + // ui.com_ch.broad.cast_text.text = string.Format("Congratulations, [color=#dfad42]{0}[/color] withdrew [color=#90c04e]{1} [/color]dollars", ConfigSystem.GetConfig().config_name_list[name_index], + // ConfigSystem.GetConfig().config_money_list[money_index]); + string broad_text = String.Format(GameHelper.getDesByKey("makeup_5"), ConfigSystem.GetConfig().config_name_list[name_index], + ConfigSystem.GetConfig().config_money_list[money_index]); + ui.com_ch.broad.cast_text.text = broad_text; + if (DataMgr.MakeupTaskHistory.Value.Count == 0) + { + return; + } + var makeupTaskData = DataMgr.MakeupTaskHistory.Value.Last(); + var vo = ConfigSystem.GetConfig().GetData(makeupTaskData.tableId); + + ui.com_ch.btn_cash.SetClick(() => + { + if (!GameHelper.GetCloseResult()) + return; + + ui.btn_claim.SetClick(() => { }); + ui.btn_mult.SetClick(() => { }); + ui.com_ch.btn_cash.SetClick(() => { }); + ui.top_money.GetChild("btn_ch").SetClick(() => { }); + if (IsWin) + { + //ui.btn_claim.FireClick(false, true); + GetReward(AwardNum); + DOVirtual.DelayedCall(2f, () => + { + GameHelper.addInterAdnumber(); + uiCtrlDispatcher.Dispatch(UICtrlMsg.MakeupConfirmUI_Open, makeupTaskData); + UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Close); + }); + + } + else + { + GameHelper.addInterAdnumber(); + if (!IsWin) + GameHelper.SetLevelstate(3); + uiCtrlDispatcher.Dispatch(UICtrlMsg.MakeupConfirmUI_Open, makeupTaskData); + UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Close); + GameDispatcher.Instance.Dispatch(GameMsg.reset_game, false); + + } + // ui.btn_claim.enabled = false; + // ui.btn_mult.enabled = false; + + }); + + ui.top_money.GetChild("btn_ch").SetClick(() => + { + ui.btn_claim.SetClick(() => { }); + ui.btn_mult.SetClick(() => { }); + ui.com_ch.btn_cash.SetClick(() => { }); + ui.top_money.GetChild("btn_ch").SetClick(() => { }); + if (IsWin) + { + //ui.btn_claim.FireClick(false, true); + GetReward(AwardNum); + DOVirtual.DelayedCall(2f, () => + { + GameHelper.addInterAdnumber(); + uiCtrlDispatcher.Dispatch(UICtrlMsg.MakeupConfirmUI_Open, makeupTaskData); + UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Close); + }); + + } + else + { + GameHelper.addInterAdnumber(); + if (!IsWin) + GameHelper.SetLevelstate(3); + uiCtrlDispatcher.Dispatch(UICtrlMsg.MakeupConfirmUI_Open, makeupTaskData); + UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Close); + } + }); + + + + + + if ((float)DataMgr.Ticket.Value < vo.item_need) + { + string str = string.Format(GameHelper.getDesByKey("makeup_2"), vo.item_need); + ui.com_ch.ch_text.text = str; + if ((float)DataMgr.Ticket.Value > vo.item_need) + { + ui.com_ch.progress.width = 656; + ui.com_ch.progress_text.text = GameHelper.Get102Str(vo.item_need) + "/" + GameHelper.Get102Str(vo.item_need); + } + else + { + ui.com_ch.progress.width = 656 * ((float)DataMgr.Ticket.Value / vo.item_need); + ui.com_ch.progress_text.text = GameHelper.Get102Str(DataMgr.Ticket.Value) + "/" + GameHelper.Get102Str(vo.item_need); + } + + Debug.Log((float)DataMgr.Ticket.Value); + } + // else if ((float)DataMgr.MakeupTaskH5Time < vo.task_need) + // { + // ui.com_ch.ch_text.text = "Cumulataive " + (vo.task_need / 60) + @" minutes in ""Game"" to cash out"; + // if ((float)DataMgr.MakeupTaskH5Time > vo.task_need) + // { + // ui.com_ch.progress.width = 656; + // ui.com_ch.progress_text.text = (vo.task_need / 60) + "/" + (vo.task_need / 60); + // } + // else + // { + // ui.com_ch.progress.width = 656 * ((float)DataMgr.MakeupTaskH5Time / vo.task_need); + // ui.com_ch.progress_text.text = Math.Round(((float)(DataMgr.MakeupTaskH5Time / 60)), 2) + "/" + (vo.task_need / 60); + // } + // + // } + else if (makeupTaskData.videoCount < vo.ad_need) + { + + string str = string.Format(GameHelper.getDesByKey("makeup_1"), vo.ad_need); + ui.com_ch.ch_text.text = str; + if (makeupTaskData.videoCount > vo.ad_need) + { + ui.com_ch.progress.width = 656; + ui.com_ch.progress_text.text = vo.ad_need + "/" + vo.ad_need; + } + else + { + ui.com_ch.progress.width = 656 * ((float)makeupTaskData.videoCount / vo.ad_need); + ui.com_ch.progress_text.text = makeupTaskData.videoCount + "/" + vo.ad_need; + } + } + else if (GameHelper.GetLevel() <= vo.levels_need) + { + string str = string.Format(GameHelper.getDesByKey("makeup_3"), vo.levels_need); + ui.com_ch.ch_text.text = str; + ui.com_ch.progress.width = 656 * (GameHelper.GetLevel() - 1) / vo.levels_need; + ui.com_ch.progress_text.text = (GameHelper.GetLevel() - 1) + "/" + vo.levels_need; + } + else + { + var vo1 = ConfigSystem.GetConfig().GetData(makeupTaskData.tableId + 1); + if (vo1 == null) + vo1 = vo; + string str1 = string.Format(GameHelper.getDesByKey("makeup_2"), vo1.item_need); + ui.com_ch.ch_text.text = str1; + + if ((float)(DataMgr.Ticket.Value - vo.item_need) < vo1.item_need) + { + string str = string.Format(GameHelper.getDesByKey("makeup_2"), vo1.item_need); + ui.com_ch.ch_text.text = str; + + ui.com_ch.progress.width = 656f * ((float)(DataMgr.Ticket.Value - vo.item_need) / vo1.item_need); + ui.com_ch.progress_text.text = GameHelper.Get102Str((DataMgr.Ticket.Value - vo.item_need)) + "/" + GameHelper.Get102Str(vo1.item_need); + + + // Debug.Log((float)DataMgr.Ticket.Value); + } + else if (makeupTaskData.videoCount < vo1.ad_need) + { + + string str = string.Format(GameHelper.getDesByKey("makeup_1"), vo1.ad_need); + ui.com_ch.ch_text.text = str; + if (makeupTaskData.videoCount > vo1.ad_need) + { + ui.com_ch.progress.width = 656f; + ui.com_ch.progress_text.text = vo1.ad_need + "/" + vo1.ad_need; + } + else + { + ui.com_ch.progress.width = 656f * ((float)makeupTaskData.videoCount / vo1.ad_need); + ui.com_ch.progress_text.text = makeupTaskData.videoCount + "/" + vo1.ad_need; + } + } + else if (GameHelper.GetLevel() <= vo1.levels_need) + { + string str = string.Format(GameHelper.getDesByKey("makeup_3"), vo1.levels_need); + ui.com_ch.ch_text.text = str; + ui.com_ch.progress.width = 656f * (GameHelper.GetLevel() - 1) / vo1.levels_need; + ui.com_ch.progress_text.text = (GameHelper.GetLevel() - 1) + "/" + vo1.levels_need; + } + + else + { + + string str = string.Format(GameHelper.getDesByKey("makeup_3"), vo1.levels_need); + ui.com_ch.ch_text.text = str; + ui.com_ch.progress.width = 656f * (GameHelper.GetLevel() - 1) / vo1.levels_need; + if (GameHelper.GetLevel() > vo1.levels_need) + { + ui.com_ch.progress.width = 656f; + ui.com_ch.progress_text.text = vo1.levels_need + "/" + vo1.levels_need; + } + else + { + ui.com_ch.progress.width = 590f * (GameHelper.GetLevel() - 1) / vo1.levels_need; + ui.com_ch.progress_text.text = (GameHelper.GetLevel() - 1) + "/" + vo1.levels_need; + } + + } + + + } + if (successData_.boost_array != null && GameHelper.IsGiftSwitch()) + { + (ui.wheel.GetChild("wheel_") as wheel_).t0.Play(Scroll); + (ui.wheel.GetChild("wheel_") as wheel_).t1.Play(() => + { + rate_idnex++; + ui.btn_mult.title = "(" + GameHelper.getChString((decimal)successData_.cash_number * successData_.boost_array[rate_idnex % 5]) + ")"; + }); + ui.btn_mult.title = "(" + GameHelper.getChString((decimal)successData_.cash_number * successData_.boost_array[rate_idnex]) + ")"; + + list_1 = new List() { (ui.wheel.GetChild("wheel_") as wheel_).item_0, (ui.wheel.GetChild("wheel_") as wheel_).item_1, (ui.wheel.GetChild("wheel_") as wheel_).item_2, (ui.wheel.GetChild("wheel_") as wheel_).item_3, (ui.wheel.GetChild("wheel_") as wheel_).item_4, (ui.wheel.GetChild("wheel_") as wheel_).item_5, (ui.wheel.GetChild("wheel_") as wheel_).item_6, (ui.wheel.GetChild("wheel_") as wheel_).item_7, }; + // list_1[2].img_light.visible = true; + + for (int i = 0; i < list_1.Count; i++) + { + list_1[i].type.selectedIndex = (i + scroll_number) % 3; + list_1[i].text_rate.text = "X" + successData_.boost_array[i % successData_.boost_array.Length]; + } + } + } + List list_1; + private int rate_idnex = 3; + private int scroll_number; + List rate_list = new List(); + private int scroll_type = 1; + + private void StartScroll() + { + (ui.wheel.GetChild("wheel_") as wheel_).t0.timeScale = (ui.wheel.GetChild("wheel_") as wheel_).t0.timeScale = 5.0f; + scroll_type = 2; + } + private void Scroll() + { + if (scroll_type == 1) + { + scroll_number++; + rate_list.Clear(); + for (int i = 0; i < 8; i++) + { + rate_list.Add(successData_.boost_array[(scroll_number + i) % successData_.boost_array.Length]); + } + Debug.Log(JsonConvert.SerializeObject(rate_list)); + for (int i = 0; i < list_1.Count; i++) + { + list_1[i].type.selectedIndex = (i + scroll_number) % 3; + list_1[i].text_rate.text = "X" + rate_list[i]; + } + + (ui.wheel.GetChild("wheel_") as wheel_).t1.Play(() => + { + rate_idnex++; + ui.btn_mult.title = "(" + GameHelper.getChString((decimal)successData_.cash_number * successData_.boost_array[rate_idnex % successData_.boost_array.Length]) + ")"; + }); + + (ui.wheel.GetChild("wheel_") as wheel_).t0.Play(Scroll); + + } + else + { + + scroll_number++; + + rate_list.Clear(); + for (int i = 0; i < 8; i++) + { + rate_list.Add(successData_.boost_array[(scroll_number + i) % successData_.boost_array.Length]); + } + + // bool need_return = false; + if (((ui.wheel.GetChild("wheel_") as wheel_).t0.timeScale < 2.2f) && (list_1[4].text_rate.text == ("X" + successData_.rate))) + { + //开始领取 + float reward = successData_.cash_number * successData_.rate; + + if (GameHelper.IsGiftSwitch()) + GetReward(reward); + else + GetReward(reward); + GameDispatcher.Instance.Dispatch(GameMsg.RefreshMakeupData); + SaveData.GetSaveObject().LargeRewardNum++; + SaveData.saveDataFunc(); + return; + } + for (int i = 0; i < list_1.Count; i++) + { + list_1[i].type.selectedIndex = (i + scroll_number) % 3; + list_1[i].text_rate.text = "X" + rate_list[i]; + Debug.Log((ui.wheel.GetChild("wheel_") as wheel_).t0.timeScale); + } + + // if (need_return) + // { + // (ui.wheel.GetChild("wheel_") as wheel_).t0.timeScale = 0; + // return; + // } + + (ui.wheel.GetChild("wheel_") as wheel_).t1.Play(() => + { + rate_idnex++; + ui.btn_mult.title = "(" + GameHelper.getChString((decimal)successData_.cash_number * successData_.boost_array[rate_idnex % successData_.boost_array.Length]) + ")"; + }); + + (ui.wheel.GetChild("wheel_") as wheel_).t0.Play(Scroll); + (ui.wheel.GetChild("wheel_") as wheel_).t0.timeScale = (ui.wheel.GetChild("wheel_") as wheel_).t0.timeScale - 0.3f; + + } + + } } }