225 lines
6.4 KiB
C#
225 lines
6.4 KiB
C#
using DG.Tweening;
|
|
using IgnoreOPS;
|
|
using SGModule.Net;
|
|
using UNSDK;
|
|
|
|
namespace ChillConnect
|
|
{
|
|
using System;
|
|
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using FairyGUI;
|
|
using SGModule.ApplePay;
|
|
using Newtonsoft.Json;
|
|
using SGModule.NetKit;
|
|
using Assets.Scripts;
|
|
using SGModule.Common;
|
|
|
|
public class HallManager : BaseUnityManager<HallManager>
|
|
{
|
|
public event Action UpdateSecondEvent;
|
|
public event Action UpdateFiveSecondEvent;
|
|
|
|
private float _secondTime;
|
|
private float _secondTime1;
|
|
private LoginModel loginModel;
|
|
private bool isGameStart;
|
|
private GameDataSystem gameDataSys;
|
|
private WindowSystem windowSys;
|
|
private RewardSystem rewardSys;
|
|
private ConsumeSystem consumeSys;
|
|
|
|
private bool isFirstEnter = true;
|
|
public int openTipsTimes = 0;
|
|
public bool isShowRankView = false;
|
|
public event Action UpdateEvent;
|
|
private Camera _gameCamera;
|
|
|
|
// public int countTimes = 0;
|
|
|
|
public override void Init()
|
|
{
|
|
CtrlDispatcher.Instance.AddListener(CtrlMsg.Game_Start, OnGameStart);
|
|
GameDispatcher.Instance.AddListener(GameMsg.OpenGame, EnterGame);
|
|
GameDispatcher.Instance.AddListener(GameMsg.BackMainScene, EnterHall);
|
|
|
|
AppDispatcher.Instance.AddListener(MainThreadMsg.App_Focus_True, BackToGame);
|
|
CtrlDispatcher.Instance.AddListener(CtrlMsg.open_wb, OpenWb);
|
|
|
|
SetSoundVolume();
|
|
InitSystem();
|
|
}
|
|
|
|
private void InitSystem()
|
|
{
|
|
gameDataSys = new GameDataSystem();
|
|
windowSys = new WindowSystem();
|
|
rewardSys = new RewardSystem();
|
|
consumeSys = new ConsumeSystem();
|
|
}
|
|
|
|
void BackToGame(object obj = null)
|
|
{
|
|
if (MaxPayManager.isPay)
|
|
{
|
|
MaxPayManager.isPay = false;
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
|
MaxPayManager.Instance.PaySuccess();
|
|
}
|
|
|
|
}
|
|
private void OnGameStart(object obj)
|
|
{
|
|
|
|
// var lang = PlayerPrefsKit.ReadString("LangIdKey");
|
|
// if (lang.IsNullOrWhiteSpace())
|
|
// {
|
|
// lang = "en";
|
|
// }
|
|
|
|
// UIManager.Instance.SetSwitchLanguage(lang);
|
|
|
|
|
|
EnterHall(true);
|
|
isGameStart = true;
|
|
|
|
TrackKit.TrackLoginFunnel(LoginFunnelEventType.EnterHall);
|
|
|
|
|
|
}
|
|
private void SetSoundVolume()
|
|
{
|
|
float last_sound = PlayerPrefs.GetFloat("soundVolume", 1.0f);
|
|
// Debug.Log($"barry last_sound=== " + last_sound);
|
|
GRoot.inst.soundVolume = last_sound;
|
|
|
|
AudioManager.Instance.SetBGMSound();
|
|
}
|
|
|
|
private void EnterHall(object obj = null)
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PlayUI_Close);
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.RewardAniUI_Close);
|
|
AudioManager.Instance.StopBGM();
|
|
AudioManager.Instance.PlayBGM(AudioConst.MainBg);
|
|
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.ArrowGameUI_Open);
|
|
|
|
if (GameHelper.IsGiftSwitch()) UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BroadcastUI_Open);
|
|
GameHelper.PlayGameTimeEvent(1);
|
|
}
|
|
|
|
|
|
private void EnterGame(object obj)
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.MainUI_Close);
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.ArrowGameUI_Open);
|
|
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.RainPlayUI_Open);
|
|
AudioManager.Instance.StopBGM();
|
|
|
|
AudioManager.Instance.PlayBGM(AudioConst.GameBg);
|
|
|
|
}
|
|
|
|
|
|
private void OpenWb(object obj) {
|
|
return;
|
|
if (obj is not SDKOpenConfig openConfig) return;
|
|
|
|
|
|
Debug.Log($"open wb normal==={openConfig.normal} url==={openConfig.url}");
|
|
SdkConfigMgr.Instance.Open(openConfig.normal, openConfig.url);
|
|
SetCameraVisible(false);
|
|
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.H5UI_Open);
|
|
|
|
GameDispatcher.Instance.Dispatch(GameMsg.hideBroadCast);
|
|
|
|
if (UIManager.Instance.IsExistUI(UIConst.GameLoginUI))
|
|
{
|
|
Debug.Log($"gamelogin ui is exist ");
|
|
}
|
|
|
|
}
|
|
|
|
public void SetCameraVisible(bool visible)
|
|
{
|
|
// // 只在首次调用时查找
|
|
// if (_gameCamera == null)
|
|
// {
|
|
// // 使用 FindWithTag 确保能找到非激活对象
|
|
//
|
|
// _gameCamera = GameObject.Find("GameCamera").GetComponent<Camera>();
|
|
//
|
|
// }
|
|
// if (_gameCamera != null)
|
|
// {
|
|
// _gameCamera.enabled = visible;
|
|
// }
|
|
// else
|
|
// {
|
|
// Debug.LogError("GameCamera reference not found!");
|
|
// }
|
|
|
|
GameHelper.ShowSheepPlayUI(visible);
|
|
}
|
|
|
|
#region 缓存资源
|
|
|
|
public void GetGalleryNet(int imageID, Action<bool> action = null)
|
|
{
|
|
// StartCoroutine(TextureHelper.GetGalleryFromNet(imageID, action));
|
|
}
|
|
|
|
#endregion
|
|
|
|
public void Update()
|
|
{
|
|
if (!isGameStart) return;
|
|
UpdateEvent?.Invoke();
|
|
_secondTime += Time.deltaTime;
|
|
_secondTime1 += Time.deltaTime;
|
|
if (_secondTime >= 1)
|
|
{
|
|
_secondTime = 0;
|
|
UpdateSecondEvent?.Invoke();
|
|
}
|
|
|
|
if (_secondTime1 >= 5)
|
|
{
|
|
_secondTime1 = 0;
|
|
UpdateFiveSecondEvent?.Invoke();
|
|
}
|
|
}
|
|
|
|
public void AddChangeGiftSwitch(Action action)
|
|
{
|
|
}
|
|
|
|
public void RemoveChangeGiftSwitch(Action action)
|
|
{
|
|
}
|
|
|
|
void OnApplicationQuit()
|
|
{
|
|
// DataMgr.ImmediateSendSave();
|
|
}
|
|
|
|
private bool isInH5;
|
|
|
|
public void SetInH5(bool isInH5)
|
|
{
|
|
this.isInH5 = isInH5;
|
|
}
|
|
}
|
|
|
|
public class SDKOpenConfig
|
|
{
|
|
[JsonProperty("normal")]
|
|
public bool normal;
|
|
[JsonProperty("url")]
|
|
public string url;
|
|
}
|
|
}
|