You've already forked taptap2024_GJ_chidouren
init
This commit is contained in:
138
Assets/Scripts/Game/RoomManager.cs
Normal file
138
Assets/Scripts/Game/RoomManager.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.ScriptListener;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using FJson;
|
||||
using Framework.Audio;
|
||||
using Framework.GamePool.manager;
|
||||
using Framework.Timer;
|
||||
using Framework.UI;
|
||||
using Framework.Utils.SingletonTemplate;
|
||||
using Game.Data;
|
||||
using Game.EventDefine;
|
||||
using IcecreamView;
|
||||
using StateSystem;
|
||||
using UniFramework.Event;
|
||||
using UnityEngine;
|
||||
using Views;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
public enum VibratorScale
|
||||
{
|
||||
Small = 1,
|
||||
Normal = 2,
|
||||
Big = 4,
|
||||
SuperBig = 6,
|
||||
Max = 8
|
||||
}
|
||||
|
||||
public class RoomManager : MgrBase<RoomManager>
|
||||
{
|
||||
private EventGroup _eventGroup;
|
||||
private GameFsm _gameFsm;
|
||||
private RoomGlobalData _roomGlobalData;
|
||||
public bool HasGaming { get; private set; }
|
||||
public bool HasLock { get ; private set; }
|
||||
|
||||
public GameState CurrentGameState => this._gameFsm.CurrentState;
|
||||
|
||||
public RoomGlobalData RoomGlobalData
|
||||
{
|
||||
get => _roomGlobalData;
|
||||
set => _roomGlobalData = value;
|
||||
}
|
||||
|
||||
public void JoinGame (params object[] args)
|
||||
{
|
||||
this._gameFsm = new GameFsm ();
|
||||
this._gameFsm.Active (GameState.InitGame , args);
|
||||
GameUpdateMgr.Instance.AddUpdater (DoUpdate);
|
||||
this.BindEvent ();
|
||||
this._gameFsm.OpenState (GameState.StartGame);
|
||||
}
|
||||
|
||||
internal void _OnExitGame ()
|
||||
{
|
||||
UnBindEvent ();
|
||||
this._gameFsm.Kill ();
|
||||
GameUpdateMgr.Instance.RemoveUpdater (DoUpdate);
|
||||
GameStateManager.Instance.OpenState (System.StateSystem.GameGlobalState.GameHome);
|
||||
}
|
||||
|
||||
private void DoUpdate ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (Input.GetKeyDown (KeyCode.F1))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
if (HasGaming)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void OnCreateMge ()
|
||||
{
|
||||
// _eventBindHandler = new EventBindHandler (this);
|
||||
_eventGroup = new EventGroup ();
|
||||
}
|
||||
|
||||
protected override bool InstanceHook ()
|
||||
{
|
||||
return GameStateManager.Instance.CurrentState == System.StateSystem.GameGlobalState.GameRoom;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 锁定操作
|
||||
/// </summary>
|
||||
public void Lock ()
|
||||
{
|
||||
this.HasLock = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解除锁定操作
|
||||
/// </summary>
|
||||
public void UnLock ()
|
||||
{
|
||||
this.HasLock = false;
|
||||
}
|
||||
|
||||
#region 事件
|
||||
|
||||
private void BindEvent ()
|
||||
{
|
||||
this._eventGroup.AddListener<GameEventDefine.ChangeGameFsm> (ChangeGameFsm);
|
||||
this._eventGroup.AddListener<GameEventDefine.OverlyCoin> (OverlyCoin);
|
||||
}
|
||||
|
||||
|
||||
private void ChangeGameFsm (IEventMessage eventMessage)
|
||||
{
|
||||
GameEventDefine.ChangeGameFsm message = eventMessage as GameEventDefine.ChangeGameFsm;
|
||||
this._gameFsm.OpenState (message.State , message.Args);
|
||||
}
|
||||
|
||||
private void OverlyCoin (IEventMessage obj)
|
||||
{
|
||||
if (obj is GameEventDefine.OverlyCoin message)
|
||||
{
|
||||
AudioManager.Instance.PlaySoundEffect (SeAudio.Gaming_GetCoin);
|
||||
this.RoomGlobalData.OverlyCoin (message.overlyCoin , message.hasEcho);
|
||||
GlobalEventDefine.RefreshView.SendMessage ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void UnBindEvent ()
|
||||
{
|
||||
this._eventGroup.RemoveAllListener ();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user