102 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			102 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using UnityEngine;
 | |
| 
 | |
| /// <summary>
 | |
| /// 步骤状态(管理一个步骤下的所有需要初始化的状态)
 | |
| /// </summary>
 | |
| public abstract class StepState : MonoBehaviour
 | |
| {
 | |
|     [HideInInspector]
 | |
|     public int systemId;
 | |
|     [HideInInspector]
 | |
|     public int schemeId;
 | |
| 
 | |
| 
 | |
|     public Dictionary<int,E_SceneType> steps=new Dictionary<int, E_SceneType>();
 | |
| 
 | |
|     public void Init()
 | |
|     {
 | |
|         schemeId = int.Parse(transform.name);
 | |
|         systemId = int.Parse(transform.parent.name);
 | |
|     }
 | |
| 
 | |
|     /// <summary>
 | |
|     /// 跳步骤
 | |
|     /// </summary>
 | |
|     /// <param name="num">从一开始</param>
 | |
|     public void JumpStep(int num)
 | |
|     {
 | |
|         //检查是否跳场景
 | |
|         InvokeChangeScene(steps[num], isChangeSence =>
 | |
|         {
 | |
|             //找到此步骤场景第一个
 | |
|             int first = steps.First(a => a.Value == steps[num]).Key;
 | |
| 
 | |
|             //从场景第一个开始还原到此步骤
 | |
|             foreach (var item in steps)
 | |
|             {
 | |
|                 if(item.Key>=first && item.Key<=num)
 | |
|                 {
 | |
|                     SetStepState(item.Key,num);
 | |
|                 }
 | |
|             }
 | |
|         });
 | |
|     }
 | |
| 
 | |
|     /// <summary>
 | |
|     /// 跳场景并且执行场景状态设置
 | |
|     /// </summary>
 | |
|     /// <param name="jumpSence"></param>
 | |
|     /// <param name="doStepState"></param>
 | |
|     public void InvokeChangeScene(E_SceneType jumpSence, Action<bool> doStepState)
 | |
|     {
 | |
|         string sname = "";
 | |
|         switch (jumpSence)
 | |
|         {
 | |
|             case E_SceneType.None:
 | |
|                 return;
 | |
|             case E_SceneType.Office:
 | |
|                 sname = "03_OfficeScene";
 | |
|                 break;
 | |
|             case E_SceneType.ToolRoom:
 | |
|                 sname = "04_ToolMaterialScene";
 | |
|                 break;
 | |
|             case E_SceneType.Site:
 | |
|                 sname = "05_LiveScene";
 | |
|                 break;
 | |
|             default:
 | |
|                 return;
 | |
|         }
 | |
|         if (GameManager.RunModelMgr.SceneType != jumpSence)
 | |
|         {
 | |
|             //跳场景
 | |
|             GameManager.UIMgr.ShowPanel<UI_LoadingPanel>(E_UI_Layer.System);
 | |
|             GameManager.ScenesMgr.LoadSceneAsyn(sname, () =>
 | |
|             {
 | |
|                 Debug.Log("步骤场景:" + jumpSence.ToString());
 | |
|                 GameManager.UIMgr.HidePanel<UI_LoadingPanel>();
 | |
|                 GameManager.RunModelMgr.SceneType = jumpSence;
 | |
|                 GameManager.EventMgr.EventTrigger(Enum_EventType.SwitchScene, jumpSence);
 | |
|                 GameManager.EventMgr.EventTrigger<string>(Enum_EventType.SwitchSubProcessStepTriggerID, ProcessManager.Instance.subProcessStepTriggerID);
 | |
| 
 | |
|                 doStepState?.Invoke(true);
 | |
|             });
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             doStepState?.Invoke(false);
 | |
|         }
 | |
|     }
 | |
| 
 | |
| /// <summary>
 | |
| /// 执行步骤还原
 | |
| /// </summary>
 | |
| /// <param name="num">要执行的步骤</param>
 | |
| /// <param name="lastNum">目标步骤</param>
 | |
|     public abstract void SetStepState(int num,int lastNum);
 | |
| }
 | |
| 
 |