步骤初始化测试
This commit is contained in:
parent
27a2039d30
commit
7b39d4d90d
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a38e68328447cf144883eda220a17ea1
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7d281825900800f4592beeb0a62db8df
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 步骤状态(管理一个步骤下的所有需要初始化的状态)
|
||||
/// </summary>
|
||||
public class StepState : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 步骤所处场景
|
||||
/// </summary>
|
||||
public E_SceneType initSceneType;
|
||||
|
||||
[HideInInspector]
|
||||
public int systemId;
|
||||
[HideInInspector]
|
||||
public int schemeId;
|
||||
[HideInInspector]
|
||||
public int subProcessId;
|
||||
|
||||
public List<StepStateBase> stepStateBases;
|
||||
private Action<E_SceneType> callback;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
stepStateBases = transform.GetComponentsInChildren<StepStateBase>(true).ToList();
|
||||
subProcessId = int.Parse(gameObject.name);
|
||||
schemeId = int.Parse(transform.parent.name);
|
||||
systemId= int.Parse(transform.parent.parent.name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册场景跳转回调
|
||||
/// </summary>
|
||||
/// <param name="callback"></param>
|
||||
public void AddResetChangeScene(Action<E_SceneType> callback)
|
||||
{
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public void InvokeChangeScene()
|
||||
{
|
||||
if (callback != null)
|
||||
{
|
||||
callback(initSceneType);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b60c6991d2888da47850978d1051aa7f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 步骤状态类
|
||||
/// </summary>
|
||||
public class StepStateBase : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置的步骤状态初始参数
|
||||
/// </summary>
|
||||
public string initStatePara;
|
||||
|
||||
private Action<string> callback;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置状态初始化方法
|
||||
/// </summary>
|
||||
/// <param name="callback"> 配置的初始化参数 </param>
|
||||
public void AddResetFunction(Action<string> callback)
|
||||
{
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行步骤状态初始化
|
||||
/// </summary>
|
||||
public void InvokeInitStepStae()
|
||||
{
|
||||
if (callback != null)
|
||||
{
|
||||
callback(initStatePara);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 40734e2dbb26ba24eaced19c3fbc57ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,60 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 步骤状态控制(配置步骤初始状态,断线重连步骤状态加载,步骤状态结果实时提交)
|
||||
/// </summary>
|
||||
public class StepStateControl : MonoBehaviour
|
||||
{
|
||||
//场景初始化
|
||||
//背包初始化
|
||||
//提示初始化
|
||||
//设备初始化
|
||||
//工具和材料初始化
|
||||
//自定义初始化
|
||||
|
||||
public static StepStateControl instance;
|
||||
List<StepState> m_Steps;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
m_Steps = transform.GetComponentsInChildren<StepState>(true).ToList();
|
||||
m_Steps.ForEach(a=> { a.Init(); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 调用初始化步骤
|
||||
/// </summary>
|
||||
/// <param name="process"></param>
|
||||
/// <param name="subProcess"></param>
|
||||
/// <param name="step"></param>
|
||||
public void InitStepState(int systemId, int schemeId, int subProcessId)
|
||||
{
|
||||
StepState tmp=m_Steps.Find(a => a.systemId == systemId && a.schemeId == schemeId && a.subProcessId == subProcessId);
|
||||
if (tmp != null)
|
||||
{
|
||||
//跳场景
|
||||
tmp.InvokeChangeScene();
|
||||
//初始化base
|
||||
tmp.stepStateBases.ForEach(a =>
|
||||
{
|
||||
a.InvokeInitStepStae();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提交步骤完成状态
|
||||
/// </summary>
|
||||
/// <param name="process"></param>
|
||||
/// <param name="subProcess"></param>
|
||||
/// <param name="step"></param>
|
||||
/// <param name="score"></param>
|
||||
public void SubmitStepState()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 614aca3f575a7014e9724a2ff85a8d25
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue