Repository navigation
PlotModelList
muxigame edited this page Nov 24, 2021
·
1 revision
GalForUnity.Model.PlotModelList是当前被触发且待执行的剧情模型列表,它持有着所有待执行的剧情,是DailyStateChecker和PlotFlowController之间的桥梁,继承自IDisposable
GalForUnity.Model.PlotModelList:结束活动模型是从1.0b集成过来的基础类,他不需要附加或者管理,由GalForUnity自动操作,所有满足条件的剧情会先在PlotModelList中待命,随后由PlotFlowController获得,并且执行。
| 名称 | 描述 |
|---|---|
| 无公开字段 | 无公开字段 |
| 名称 | 描述 |
|---|---|
| PlotModelList GetInstance() | 获得待执行剧情模型列表的实例 |
| void Insert(int index,PlotModel plotModel) | 向指定索引插入待执行任务 |
| void Add(PlotModel plotModel) | 向待执行剧情列表添加剧情模型 |
| PlotModel GetPlot(int index = 0) | 获取一个待执行剧情,如果没有需要执行的剧情,返回null |
| PlotModel PopPlot(int index) | 从列表弹出一个待执行剧情,如果没有需要执行的剧情,返回null |
| bool HasPlot(PlotModel plotModel) | 查询是否有该剧情类型的剧情 |
| void Dispose() | 销毁对象 |
using System;
using System.Collections.Generic;
using System.Linq;
using GalForUnity.Model.Plot;
using UnityEngine;
namespace GalForUnity.Model{
/// <summary>
/// 所有的待执行事件列表
/// </summary>
///
[Serializable]
public class PlotModelList :IDisposable{
private static PlotModelList _plotModelList = new PlotModelList();
// private readonly Dictionary<PlotType, List<PlotModel>> _plotsModel = new Dictionary<PlotType, List<PlotModel>>();
private readonly List<PlotModel> _plotsModel = new List<PlotModel>();
/// <summary>
/// 获得待执行剧情模型列表的实例
/// </summary>
/// <returns></returns>
public static PlotModelList GetInstance(){ return _plotModelList ?? (_plotModelList = CreateInstance()); }
private static PlotModelList CreateInstance() => new PlotModelList();
/// <summary>
/// 向待执行剧情列表添加剧情模型
/// </summary>
/// <param name="plotModel">指定要添加的剧情模型</param>
public void Add(PlotModel plotModel) {
Debug.Log("对象被添加"+plotModel);
_plotsModel.Add(plotModel);
}
/// <summary>
/// 向指定索引插入待执行任务
/// </summary>
/// <param name="index"></param>
/// <param name="plotModel"></param>
public void Insert(int index,PlotModel plotModel) {
_plotsModel.Insert(index,plotModel);
}
/// <summary>
/// 获取待执行剧情列表
/// </summary>
/// <param name="index"></param>
/// <returns>剧情列表,如果没有需要执行的剧情,返回null</returns>
public PlotModel GetPlot(int index = 0) {
if (_plotsModel.Count == 0) return null;
var plotModel = _plotsModel[index];
return plotModel;
}
/// <summary>
/// 获取待执行剧情列表
/// </summary>
/// <param name="index"></param>
/// <returns>剧情列表,如果没有需要执行的剧情,返回null</returns>
public PlotModel PopPlot(int index) {
var plotModel = _plotsModel[index];
_plotsModel.Remove(plotModel);
return plotModel;
}
public PlotModel PopPlot() {
return PopPlot(0);
}
/// <summary>
/// 是否有该剧情类型的剧情
/// </summary>
/// <param name="plotType">指定要查找的剧情类型</param>
/// <returns>剧情类型是否存在</returns>
public bool HasPlot(PlotModel plotModel) {
if (_plotsModel != null) {
return _plotsModel.Contains(plotModel);
}
return false;
}
// /// <summary>
// /// 是否有该剧情类型的剧情
// /// </summary>
// /// <param name="plotType">指定要查找的剧情类型</param>
// /// <param name="plotModel"></param>
// /// <returns>剧情类型是否存在</returns>
// public bool HasPlot(PlotType plotType,PlotModel plotModel) {
// if (_plotsModel.ContainsKey(plotType)) {
// return _plotsModel[plotType].Contains(plotModel);
// }
// return false;
// }
// public void Dispose()
// {
// _plotsModel.Clear();
// }
public void Dispose(){
_plotsModel.Clear();
}
}
}