Merge branch 'master' into LouDi_Quan

This commit is contained in:
shenjianxing 2024-12-30 10:30:05 +08:00
commit 83a609e72c
5 changed files with 56 additions and 34 deletions

View File

@ -100,8 +100,8 @@ public class ActionHelper
return BtnsAction.Allocate(act.Value); return BtnsAction.Allocate(act.Value);
case "Anim": case "Anim":
{ {
var strAction = (XMLTool.StringListAction)act; var strAction = (XMLTool.DictionaryAction)act;
return QFramework.AnimationAction.Allocate(act.Value, strAction.args[0], strAction.args[1]); return QFramework.AnimationAction.Allocate(act.Value, strAction.args);
} }
case "UITools": case "UITools":
{ {

View File

@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.Rendering.Universal;
namespace QFramework namespace QFramework
{ {
@ -20,17 +22,19 @@ namespace QFramework
string path; string path;
string animName; string animName;
bool reset = false;
Animation anim; Animation anim;
public static AnimationAction Allocate(string path, string animName, string reset, System.Action OnFinished = null) string frame;
string speed;
public static AnimationAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null)
{ {
var retNode = mPool.Allocate(); var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false; retNode.Deinited = false;
retNode.Reset(); retNode.Reset();
retNode.path = path; retNode.path = path;
retNode.animName = animName; retNode.animName = datas.ContainsKey("animName") ? datas["animName"] : "";
bool.TryParse(reset, out retNode.reset); retNode.frame = datas.ContainsKey("frame") ? datas["frame"] : "";
retNode.speed = datas.ContainsKey("speed") ? datas["speed"] : "";
retNode.OnFinished = OnFinished; retNode.OnFinished = OnFinished;
return retNode; return retNode;
} }
@ -45,10 +49,25 @@ namespace QFramework
if (obj != null) if (obj != null)
{ {
anim = obj.GetComponent<Animation>(); anim = obj.GetComponent<Animation>();
anim.Play(animName);
if (reset) if (string.IsNullOrEmpty(frame) == false && frame != "-1")
{ {
ActionKit.DelayFrame(1, () => anim.Stop()).StartGlobal(); int curFrame = 0;
int.TryParse(frame, out curFrame);
anim[animName].time = curFrame / anim.clip.frameRate;
anim[animName].speed = 0;
anim.Play(animName);
this.Finish();
}
else
{
float curSpeed = 1;
if (string.IsNullOrEmpty(speed)==false)
{
float.TryParse(speed, out curSpeed);
}
anim[animName].speed = curSpeed;
anim.Play(animName);
} }
} }
else else

View File

@ -125,17 +125,20 @@ public class OperationController : MonoSingleton<OperationController>
if (this.index < targetIndex) if (this.index < targetIndex)
{ {
var seq = ActionKit.Sequence(); var seq = ActionKit.Sequence();
for (int i = this.index + 1; i < targetIndex; i++) if (this.index >= 0)
{ {
// Íê³É¶¯×÷ Ö±½ÓÖ´ÐÐ for (int i = this.index; i < targetIndex; i++)
IAction finishAction = ActionHelper.GetActionAndSub(steps[i].Finished);
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.Finished });
if (finishAction!=null)
{ {
seq.Append(finishAction); // Íê³É¶¯×÷ Ö±½ÓÖ´ÐÐ
IAction finishAction = ActionHelper.GetActionAndSub(steps[i].Finished);
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.Finished });
if (finishAction != null)
{
seq.Append(finishAction);
}
} }
} }
seq.Start(this,() => seq.Start(this, () =>
{ {
curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start);
RunCurAction(curAction, targetIndex); RunCurAction(curAction, targetIndex);
@ -143,19 +146,22 @@ public class OperationController : MonoSingleton<OperationController>
} }
else if (this.index > targetIndex) else if (this.index > targetIndex)
{ {
var seq = ActionKit.Sequence();
for (int i = this.index; i > targetIndex; i--) for (int i = this.index; i > targetIndex; i--)
{ {
// ÖØÖö¯×÷ Ö±½ÓÖØÖà // ÖØÖö¯×÷ Ö±½ÓÖØÖÃ
IAction resetAction = ActionHelper.GetActionAndSub(steps[i].Reset); IAction resetAction = ActionHelper.GetActionAndSub(steps[i].Reset);
if (resetAction != null) if (resetAction != null)
{ {
resetAction.Start(this); seq.Append(resetAction);
} }
TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.NoStart }); TypeEventSystem.Global.Send(new StepStatusOnChange() { curIndex = i, status = StepStatus.NoStart });
} }
curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start); seq.Start(this, () =>
RunCurAction(curAction, targetIndex); {
curAction = ActionHelper.GetActionAndSub(steps[targetIndex].Start);
RunCurAction(curAction, targetIndex);
});
} }
else else
{ {
@ -166,7 +172,7 @@ public class OperationController : MonoSingleton<OperationController>
} }
} }
public void RunCurAction(IAction curAction,int targetIndex) public void RunCurAction(IAction curAction, int targetIndex)
{ {
if (curAction != null) if (curAction != null)
{ {

View File

@ -358,24 +358,21 @@ namespace XMLTool
break; break;
case "Anim": case "Anim":
{ {
var act = new StringListAction(); var act = new DictionaryAction();
var animName = action.Attribute("animName"); var animName = action.Attribute("animName");
if (animName != null) if (animName != null)
{ {
act.args.Add(animName.Value); act.args.Add("animName",animName.Value);
} }
else var frame = action.Attribute("frame");
if (frame != null)
{ {
act.args.Add(""); act.args.Add("frame", frame.Value);
} }
var reset = action.Attribute("reset"); var speed = action.Attribute("speed");
if (reset != null) if (speed != null)
{ {
act.args.Add(reset.Value); act.args.Add("speed", speed.Value);
}
else
{
act.args.Add("false");
} }
newAction = act; newAction = act;

View File

@ -17,8 +17,8 @@
<Action type="Scale" value="Main Camera" to="0,180,0" time="0"></Action> <Action type="Scale" value="Main Camera" to="0,180,0" time="0"></Action>
<!--执行下一步左侧步骤列表 默认开始的时候为-1步 要主动调用一次才到第1步--> <!--执行下一步左侧步骤列表 默认开始的时候为-1步 要主动调用一次才到第1步-->
<Action type="NextOperation"></Action> <Action type="NextOperation"></Action>
<!--播放动画 reset=true则动画停在第一帧--> <!--播放动画 reset=true则动画停在第一帧 frame是指定格在动画的某一帧 如果为-1 正常播放动画 -->
<Action type="Anim" value="物体路径" animName="动画名字" reset="false"></Action> <Action type="Anim" value="物体路径" animName="动画名字" frame="-1"></Action>
<!--右下角生成按钮 可生成多个 用逗号分开--> <!--右下角生成按钮 可生成多个 用逗号分开-->
<Action type="Btns" value="按钮1,按钮2,按钮3"></Action> <Action type="Btns" value="按钮1,按钮2,按钮3"></Action>
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测 --> <!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测 -->