146 lines
3.8 KiB
C#
146 lines
3.8 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Unity
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2018-2-29
|
|||
|
// Description : 游戏管理器,负责游戏的状态切换和一些全局变量控制 进行整体游戏的流程控制
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "GameWorld" company=""></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
namespace G
|
|||
|
{
|
|||
|
using System.Collections;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
public partial class GameWorld : MonoBehaviour
|
|||
|
{
|
|||
|
#region Field
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Property
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Method
|
|||
|
|
|||
|
public void InitGame()
|
|||
|
{
|
|||
|
if (!GlobalVar.FirstInitGame)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//设置为非第一次进入游戏
|
|||
|
GlobalVar.FirstInitGame = false;
|
|||
|
|
|||
|
//new GameObject(nameof(SceneLoader)).AddComponent<SceneLoader>().transform.SetParent(this.transform);
|
|||
|
//new GameObject(nameof(WorldSyncer)).AddComponent<WorldSyncer>().transform.SetParent(this.transform);
|
|||
|
|
|||
|
//初始化全局管理器
|
|||
|
//new GameObject(nameof(GameInput)).AddComponent<GameInput>().transform.SetParent(this.transform);
|
|||
|
//new GameObject(nameof(GameLevel)).AddComponent<GameLevel>().transform.SetParent(this.transform);
|
|||
|
new GameObject(nameof(GameScene)).AddComponent<GameScene>().transform.SetParent(this.transform);
|
|||
|
|
|||
|
//new GameObject(nameof(CameraManager)).AddComponent<CameraManager>().transform.SetParent(this.transform);
|
|||
|
//new GameObject(nameof(EntityManager)).AddComponent<EntityManager>().transform.SetParent(this.transform);
|
|||
|
//new GameObject(nameof(BoardManager)).AddComponent<BoardManager>().transform.SetParent(this.transform);
|
|||
|
//new GameObject(nameof(Weather.WeatherManager)).AddComponent<Weather.WeatherManager>().transform.SetParent(this.transform);
|
|||
|
//自动寻路管理器
|
|||
|
//new GameObject(nameof(AutoSearchManager)).AddComponent<AutoSearchManager>().transform.SetParent(this.transform);
|
|||
|
//new GameObject(nameof(BuffManager)).AddComponent<BuffManager>().transform.SetParent(this.transform);
|
|||
|
//new GameObject(nameof(BulletManager)).AddComponent<BulletManager>().transform.SetParent(this.transform);
|
|||
|
|
|||
|
///初始化资源管理
|
|||
|
|
|||
|
//从这里开始添加其他操作
|
|||
|
|
|||
|
//临时
|
|||
|
//ServerProxy.Instance.SwitchScene(45001);
|
|||
|
StartGame();
|
|||
|
}
|
|||
|
|
|||
|
public void ReloadGame()
|
|||
|
{
|
|||
|
if (GlobalVar.FirstInitGame)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
KFramework.GameFacade.ReadArchive();
|
|||
|
GameScene.Instance.EnterScene(0);
|
|||
|
var mainW = KUIWindow.GetWindow<UI.MainWindow>();
|
|||
|
if (mainW != null)
|
|||
|
{
|
|||
|
mainW.RefreshView();
|
|||
|
mainW.OpenPage((int)UI.MainWindow.PageType.Map, "reload");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void StartGame()
|
|||
|
{
|
|||
|
#if !UNITY_WEBGL
|
|||
|
if (GlobalVar.IsNewPlayer)
|
|||
|
{
|
|||
|
Launch.LoadLevel("opening");
|
|||
|
//SceneLoader.Instance.LoadSceneAsync("opening", (error) =>
|
|||
|
// {
|
|||
|
// });
|
|||
|
//GameScene.Instance.EnterScene(1);
|
|||
|
//KStatistics.Instance.ReportEventStartPlay("1");
|
|||
|
}
|
|||
|
else
|
|||
|
#endif
|
|||
|
{
|
|||
|
GameScene.Instance.EnterScene(0);
|
|||
|
}
|
|||
|
//WorldSyncer.Instance.StartGame();
|
|||
|
//UnityEngine.SceneManagement.SceneManager.LoadScene("main");
|
|||
|
//KUIWindow.OpenWindow<UI.MainWindow>();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Unity
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Awake
|
|||
|
/// </summary>
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
//所有的其他操作都要放在后面
|
|||
|
_Instance = this;
|
|||
|
DontDestroyOnLoad(this.gameObject);
|
|||
|
}
|
|||
|
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Static
|
|||
|
|
|||
|
private static GameWorld _Instance;
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
public static GameWorld Instance
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_Instance is null)
|
|||
|
{
|
|||
|
_Instance = new GameObject(nameof(GameWorld)).AddComponent<GameWorld>();
|
|||
|
}
|
|||
|
return _Instance;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|