You've already forked taptap2024_GJ_chidouren
155 lines
4.2 KiB
C#
155 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.ScriptListener;
|
|
using Cysharp.Threading.Tasks;
|
|
using FJson;
|
|
using Framework.Asset;
|
|
using Framework.Audio;
|
|
using Framework.GamePool.manager;
|
|
using Framework.Timer;
|
|
using Framework.UI;
|
|
using Framework.Utils.SingletonTemplate;
|
|
using Game.Component;
|
|
using Game.Data;
|
|
using Game.EventDefine;
|
|
using IcecreamView;
|
|
using StateSystem;
|
|
using UniFramework.Event;
|
|
using UnityEngine;
|
|
using Views;
|
|
using Object = UnityEngine.Object;
|
|
|
|
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 int PartIndex = 1;
|
|
|
|
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 ();
|
|
if (MapContent.Instance.ScenePart == null)
|
|
{
|
|
LoadScenePart (this.PartIndex);
|
|
}
|
|
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;
|
|
}
|
|
|
|
public void LoadScenePart (int partIndex)
|
|
{
|
|
var loadName = $"AutoSource/Part/part{partIndex}.prefab";
|
|
var scenePart = AssetManager.Instance.LoadAsset<GameObject> (loadName).GetComponent<ScenePart> ();
|
|
var instantiate = Object.Instantiate (scenePart, MapContent.Instance.transform, true);
|
|
MapContent.Instance.SetPart (instantiate);
|
|
}
|
|
|
|
#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);
|
|
MapContent.Instance.OverlyCoin (message.overlyCoin);
|
|
GlobalEventDefine.RefreshView.SendMessage ();
|
|
}
|
|
}
|
|
|
|
|
|
private void UnBindEvent ()
|
|
{
|
|
this._eventGroup.RemoveAllListener ();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |