2024-12-14 18:27:59 +08:00
|
|
|
|
using QFramework;
|
|
|
|
|
|
using QFramework.Example;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ActionHelper
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly Dictionary<string, Type> typeDict = new Dictionary<string, Type>()
|
|
|
|
|
|
{
|
|
|
|
|
|
{ "UIRightTop", typeof(UIRightTop) },
|
|
|
|
|
|
{ "UIOperationList", typeof(UIOperationList) },
|
|
|
|
|
|
{ "UIBtns", typeof(QFramework.Example.UIBtns) },
|
|
|
|
|
|
{ "UITools", typeof(QFramework.Example.UITools) },
|
2024-12-30 16:24:41 +08:00
|
|
|
|
{ "UIHint", typeof(QFramework.Example.UIHint) },
|
2024-12-16 15:45:19 +08:00
|
|
|
|
{ "UICameraSwitch", typeof(QFramework.Example.UICameraSwitch) },
|
2024-12-14 18:27:59 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20>ݹ<EFBFBD><DDB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>Action
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="action"></param>
|
|
|
|
|
|
/// <param name="parentAct"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static IAction GetActionAndSub(XMLTool.ActionItem action, IAction parentAct = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
IAction sub = null;
|
|
|
|
|
|
if (action != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (parentAct == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
parentAct = ActionHelper.GetAction(action);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
sub = ActionHelper.GetAction(action);
|
|
|
|
|
|
switch (parentAct)
|
|
|
|
|
|
{
|
|
|
|
|
|
case QFramework.IParallel act:
|
|
|
|
|
|
act.Append(sub);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case QFramework.ISequence seq:
|
|
|
|
|
|
seq.Append(sub);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (action.SubActions != null && action.SubActions.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sub != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
parentAct = sub;
|
|
|
|
|
|
}
|
|
|
|
|
|
foreach (var item in action.SubActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
GetActionAndSub(item, parentAct);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return parentAct;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// ֻ<><D6BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="action"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static IAction GetAction(XMLTool.ActionItem action)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (action)
|
|
|
|
|
|
{
|
|
|
|
|
|
case XMLTool.Action act:
|
|
|
|
|
|
switch (act.Type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "Sequence":
|
|
|
|
|
|
return ActionKit.Sequence();
|
|
|
|
|
|
case "Parallel":
|
|
|
|
|
|
return ActionKit.Parallel();
|
|
|
|
|
|
case "Any":
|
|
|
|
|
|
return AnyAction.Allocate();
|
|
|
|
|
|
case "Log":
|
|
|
|
|
|
return LogAction.Allocate(action.Value);
|
|
|
|
|
|
case "Delay":
|
|
|
|
|
|
return ActionKit.Delay(float.Parse(action.Value), null);
|
|
|
|
|
|
case "NextOperation":
|
|
|
|
|
|
return NextOperationAction.Allocate();
|
|
|
|
|
|
case "Move":
|
|
|
|
|
|
var move = (XMLTool.MoveOrAction)act;
|
|
|
|
|
|
return MoveAction.Allocate(act.Value, move.to, move.time);
|
|
|
|
|
|
case "Rotate":
|
|
|
|
|
|
var rotate = (XMLTool.MoveOrAction)act;
|
|
|
|
|
|
return RotateAction.Allocate(act.Value, rotate.to, rotate.time);
|
2024-12-18 14:26:20 +08:00
|
|
|
|
case "Scale":
|
|
|
|
|
|
var scaleAct = (XMLTool.MoveOrAction)act;
|
|
|
|
|
|
return ScaleAction.Allocate(act.Value, scaleAct.to, scaleAct.time);
|
2024-12-14 18:27:59 +08:00
|
|
|
|
case "Btns":
|
|
|
|
|
|
return BtnsAction.Allocate(act.Value);
|
|
|
|
|
|
case "Anim":
|
2024-12-18 11:17:08 +08:00
|
|
|
|
{
|
2024-12-30 10:29:48 +08:00
|
|
|
|
var strAction = (XMLTool.DictionaryAction)act;
|
|
|
|
|
|
return QFramework.AnimationAction.Allocate(act.Value, strAction.args);
|
2024-12-18 11:17:08 +08:00
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
case "UITools":
|
2024-12-17 09:39:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
|
|
|
|
|
return UIToolsAction.Allocate(strAction.args[0], strAction.args[1], strAction.args[2], strAction.args[3],
|
|
|
|
|
|
strAction.args[4], strAction.args[5], strAction.args[6], strAction.args[7],
|
|
|
|
|
|
strAction.args[8], strAction.args[9]);
|
|
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
case "PointQuestion":
|
|
|
|
|
|
return PointQuestionAction.Allocate(act.Value);
|
|
|
|
|
|
case "TextQuestion":
|
2024-12-17 09:39:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
2024-12-26 15:44:04 +08:00
|
|
|
|
var strAction = (XMLTool.DictionaryAction)act;
|
|
|
|
|
|
return TextQuestionAction.Allocate(strAction.args);
|
2024-12-17 09:39:38 +08:00
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
case "Hint":
|
2024-12-17 09:39:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
|
|
|
|
|
return HintAction.Allocate(strAction.Value, strAction.args[0], strAction.args[1], strAction.args[2]);
|
|
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
case "Var":
|
|
|
|
|
|
return SetVarAction.Allocate(act.Name, act.Value);
|
|
|
|
|
|
case "Show":
|
2024-12-17 09:39:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
2024-12-23 11:30:18 +08:00
|
|
|
|
return ShowAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
|
2024-12-17 09:39:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
case "TextTip":
|
|
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
2024-12-17 09:49:59 +08:00
|
|
|
|
return TextTipAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
|
2024-12-17 09:39:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
case "UIShow":
|
|
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
|
|
|
|
|
return UIShowAction.Allocate(act.Value, strAction.args[0]);
|
|
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
case "SetScore":
|
|
|
|
|
|
return SetScoreAction.Allocate(act.Name, act.Value);
|
2024-12-16 15:45:19 +08:00
|
|
|
|
case "CameraSwitch":
|
2024-12-17 09:39:38 +08:00
|
|
|
|
{
|
2024-12-23 11:30:18 +08:00
|
|
|
|
var dictAction = (XMLTool.DictionaryAction)act;
|
|
|
|
|
|
return CameraSwitchAction.Allocate(dictAction.args);
|
2024-12-17 09:39:38 +08:00
|
|
|
|
}
|
2024-12-19 16:38:42 +08:00
|
|
|
|
case "CameraLock":
|
2024-12-17 14:40:30 +08:00
|
|
|
|
{
|
2024-12-19 16:38:42 +08:00
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
|
|
|
|
|
return CameraLockAction.Allocate(strAction.args[0], strAction.args[1]);
|
2024-12-17 14:40:30 +08:00
|
|
|
|
}
|
2024-12-17 18:07:20 +08:00
|
|
|
|
case "Video":
|
|
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
|
|
|
|
|
return VideoAction.Allocate(act.Value, strAction.args[0], strAction.args[1], strAction.args[2], strAction.args[3]);
|
|
|
|
|
|
}
|
2024-12-18 13:16:36 +08:00
|
|
|
|
case "HighLight":
|
|
|
|
|
|
{
|
2024-12-27 14:08:27 +08:00
|
|
|
|
var strAction = (XMLTool.DictionaryAction)act;
|
|
|
|
|
|
return HighLightAction.Allocate(act.Value, strAction.args);
|
2024-12-18 13:16:36 +08:00
|
|
|
|
}
|
2024-12-18 16:20:06 +08:00
|
|
|
|
case "LoadRes":
|
|
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
|
|
|
|
|
return LoadResAction.Allocate(act.Value, strAction.args[0]);
|
|
|
|
|
|
}
|
2024-12-19 09:47:07 +08:00
|
|
|
|
case "Audio":
|
|
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
|
|
|
|
|
return AudioAction.Allocate(act.Value, strAction.args[0], strAction.args[1], strAction.args[2], strAction.args[3], strAction.args[4]);
|
|
|
|
|
|
}
|
2024-12-19 15:25:22 +08:00
|
|
|
|
case "Line":
|
|
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
2024-12-19 16:38:42 +08:00
|
|
|
|
return LineAction.Allocate(act.Name, act.Value, strAction.args[0], strAction.args[1], strAction.args[2]);
|
|
|
|
|
|
}
|
|
|
|
|
|
case "Destroy":
|
|
|
|
|
|
{
|
|
|
|
|
|
return DestroyAction.Allocate(act.Value);
|
2024-12-19 15:25:22 +08:00
|
|
|
|
}
|
2024-12-19 17:43:29 +08:00
|
|
|
|
case "ResultTip":
|
|
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
|
|
|
|
|
return ResultTipAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
|
|
|
|
|
|
}
|
2024-12-20 15:33:37 +08:00
|
|
|
|
case "Led":
|
|
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
|
|
|
|
|
return LedAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
|
|
|
|
|
|
}
|
2024-12-20 17:05:19 +08:00
|
|
|
|
case "Script":
|
|
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
|
|
|
|
|
return ScriptAction.Allocate(act.Name, act.Value, strAction.args[0]);
|
|
|
|
|
|
}
|
2024-12-25 11:24:47 +08:00
|
|
|
|
case "Collider":
|
|
|
|
|
|
{
|
|
|
|
|
|
var strAction = (XMLTool.StringListAction)act;
|
|
|
|
|
|
return ColliderAction.Allocate(act.Value, strAction.args[0], strAction.args[1], strAction.args[2]);
|
|
|
|
|
|
}
|
2024-12-25 16:33:45 +08:00
|
|
|
|
case "TimeTip":
|
|
|
|
|
|
{
|
|
|
|
|
|
var dictAction = (XMLTool.DictionaryAction)act;
|
|
|
|
|
|
return TimeTipAction.Allocate(act.Value, dictAction.args);
|
|
|
|
|
|
}
|
2024-12-18 16:20:06 +08:00
|
|
|
|
default:
|
|
|
|
|
|
Debug.LogError($"û<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>Action<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{act.Type}");
|
|
|
|
|
|
break;
|
2024-12-14 18:27:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case XMLTool.Condition condition:
|
|
|
|
|
|
return GetCondition(condition);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="condition"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static ICondition GetCondition(XMLTool.ActionItem condition)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (condition.Type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "And":
|
|
|
|
|
|
case "Or":
|
|
|
|
|
|
var group = ConditionGroup.Allocate(condition.Type);
|
|
|
|
|
|
foreach (var item in condition.SubActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
group.AddCondition(GetCondition(item));
|
|
|
|
|
|
}
|
|
|
|
|
|
return group;
|
|
|
|
|
|
case "UIClick":
|
|
|
|
|
|
return UIClickCondition.Allocate(condition.Value);
|
|
|
|
|
|
case "ObjClick":
|
2024-12-26 19:35:31 +08:00
|
|
|
|
var dict = (XMLTool.DictionaryCondition)condition;
|
|
|
|
|
|
return ObjClickCondition.Allocate(dict.Value, dict.args);
|
2024-12-14 18:27:59 +08:00
|
|
|
|
case "Input":
|
|
|
|
|
|
return InputCondition.Allocate(condition.Value);
|
|
|
|
|
|
case "Var":
|
|
|
|
|
|
return VarCondition.Allocate(condition.Name, condition.Value);
|
|
|
|
|
|
case "StrEvent":
|
|
|
|
|
|
return StrEventCondition.Allocate(condition.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|