using System;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.Events;
namespace Framework.ProcessMode
{
///
/// 动作类型枚举
///
public enum ProcessActionType
{
默认, // 默认类型
判断题, // 判断题类型
多选题 // 多选题类型
}
///
/// 判断题配置
///
public class JudgmentQuestionConfig
{
public string Question { get; set; } // 题目
public string CorrectAnswer { get; set; } // 正确答案
public float Score { get; set; } // 题目分数
}
///
/// 多选题配置
///
public class MultipleChoiceConfig
{
public string Question { get; set; } // 题目
public List Options { get; set; } // 选项列表
public List CorrectAnswers { get; set; } // 正确答案列表(可以多选)
public float Score { get; set; } // 题目分数
public MultipleChoiceConfig()
{
Options = new List();
CorrectAnswers = new List();
}
}
///
/// 流程步骤描述类
///
public enum ProcessTargetType
{
Model, // 目标类型:模型
Event // 目标类型:事件
}
///
/// 目标对象配置
///
public class TargetObjectConfig
{
public string ObjectName { get; set; }
public ProcessTargetType Type { get; set; }
public float Score { get; set; } // 目标对象分数
}
public class ProcessStepDescription
{
///
/// 动作类型
///
public ProcessActionType ActionType { get; set; }
///
/// 判断题配置列表
///
public List JudgmentQuestions { get; set; }
///
/// 多选题配置列表
///
public List MultipleChoiceQuestions { get; set; }
///
/// 动作标题,用于对动作的简单描述
///
public string Title { get; set; }
///
/// 目标对象列表,包含目标的名称和类型
///
public List TargetObjects { get; set; }
///
/// 动作执行逻辑
///
public Action Action { get; set; }
///
/// 动作的详细描述信息
///
public string Description { get; set; }
///
/// 是否需要按顺序点击目标对象
///
public bool IsSequential { get; set; }
///
/// 已点击的目标对象集合
///
public HashSet ClickedObjects { get; set; }
///
/// 当前正在处理的目标对象索引
///
public int CurrentObjectIndex { get; set; }
///
/// 是否已显示过反馈
///
public bool FeedbackDisplayed { get; set; }
///
/// 当前动作所属步骤的描述
///
public string StepDescription { get; set; }
///
/// 动作评分
///
public float Score { get; set; }
public string SceneName { get; set; } // 场景名称
public bool RequiresSceneSwitch { get; set; } // 是否需要切换场景
///
/// 目标物体及其事件的映射
///
public Dictionary TargetObjectEvents { get; private set; }
///
/// 动作编号
///
public int ProcessStepIndex { get; set; }
///
/// 是否需要正确完成该动作
///
public bool RequireCorrectCompletion { get; set; }
///
/// 动作是否已完成
///
public bool IsCompleted { get; set; }
///
/// 构造函数,初始化动作描述
///
/// 目标对象列表
/// 动作逻辑
/// 动作详细描述
/// 是否按顺序点击
/// 所属步骤描述
/// 动作评分
/// 动作标题
public ProcessStepDescription(List targetObjects, Action action, string description, bool isSequential, string stepDescription, float score = 0, string title = "新动作")
{
Title = title;
TargetObjects = targetObjects ?? new List();
Action = action;
Description = description;
IsSequential = isSequential;
ClickedObjects = new HashSet();
CurrentObjectIndex = 0;
FeedbackDisplayed = false;
StepDescription = stepDescription;
Score = score;
RequireCorrectCompletion = true;
TargetObjectEvents = new Dictionary();
// 初始化新增字段
ActionType = ProcessActionType.默认;
JudgmentQuestions = new List();
MultipleChoiceQuestions = new List();
}
///
/// 绑定目标物体的事件
///
public void BindEventToObject(string objectName, Action customEvent)
{
if (!TargetObjectEvents.ContainsKey(objectName))
{
TargetObjectEvents.Add(objectName,customEvent);
}
}
///
/// 执行目标物体的事件
///
public void ExecuteObjectEvent(string objectName)
{
if (TargetObjectEvents.TryGetValue(objectName, out var customEvent))
{
customEvent.Invoke();
}
else
{
Debug.LogWarning($"目标物体 {objectName} 没有绑定事件!");
}
}
}
}