using System.Collections; using System.Collections.Generic; using System.IO; using GameFramework.Event; using GameFramework.Fsm; using GameFramework.Procedure; using GameFramework.Resource; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using UnityEngine; using UnityGameFramework.Runtime; public class ProcedureMain : ProcedureBase { private bool waitChange = false; protected override void OnInit(IFsm procedureOwner) { base.OnInit(procedureOwner); } //每次进入流程调用 protected override void OnEnter(IFsm procedureOwner) { base.OnEnter(procedureOwner); Log.Debug("进入主流程"); waitChange = true; #if !UNITY_EDITOR waitChange = false; GameMain.Resource.SetResourceMode(ResourceMode.Package); GameMain.Resource.InitResources(InItResourceDone); #endif InitAddressConfig(); } void InitAddressConfig() { string addressContent = File.ReadAllText(Application.dataPath + "/Config/HttpAddress.json"); HttpAddressConfig config = JsonConvert.DeserializeObject(addressContent); HttpAddress.docAddress = config.address.docAddress; HttpAddress.examAddress = config.address.examAddress; HttpAddress.loginAddress = config.address.loginAddress; HttpAddress.logAddress = config.address.logAddress; HttpAddress.pingAddress = config.address.pingAddress; } //update咯 protected override void OnUpdate(IFsm procedureOwner, float elapseSeconds, float realElapseSeconds) { base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds); //切换流程样例 //Debug.Log("切换ProcedureInit流程"); //ChangeState(procedureOwner); //----调试直接跳进流程 if (waitChange) { waitChange = false; ChangeState(procedureOwner); } } //离开流程调用 protected override void OnLeave(IFsm procedureOwner, bool isShutdown) { base.OnLeave(procedureOwner, isShutdown); } private void InItResourceDone() { waitChange = true; Debug.Log("加载资源包完成"); } //流程一般不会主动卸载 protected override void OnDestroy(IFsm procedureOwner) { base.OnDestroy(procedureOwner); } }