From 7da2890d9908a383c0b7552dede5f28b5f6a87c9 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Thu, 19 Dec 2024 16:38:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=95=9C=E5=A4=B4=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E5=8A=9F=E8=83=BD=20=E5=AE=8C=E5=96=84=E8=99=9A?= =?UTF-8?q?=E7=BA=BF=E9=A2=84=E5=88=B6=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Art/DrawLine/Line.prefab | 2 +- Assets/Scripts/Actions/ActionHelper.cs | 11 ++- ...ockCameraAction.cs => CameraLockAction.cs} | 26 ++++--- ...ction.cs.meta => CameraLockAction.cs.meta} | 2 +- Assets/Scripts/Actions/DestroyAction.cs | 70 +++++++++++++++++++ Assets/Scripts/Actions/DestroyAction.cs.meta | 11 +++ Assets/Scripts/Actions/LineAction.cs | 13 +++- .../Scripts/Conditions/StrEventCondition.cs | 1 - Assets/Scripts/FreeCameraController.cs | 23 +++--- Assets/Scripts/Xml/XmlParser.cs | 42 +++++++++++ Doc/Xml配置文档.xml | 7 +- 11 files changed, 180 insertions(+), 28 deletions(-) rename Assets/Scripts/Actions/{LockCameraAction.cs => CameraLockAction.cs} (61%) rename Assets/Scripts/Actions/{LockCameraAction.cs.meta => CameraLockAction.cs.meta} (83%) create mode 100644 Assets/Scripts/Actions/DestroyAction.cs create mode 100644 Assets/Scripts/Actions/DestroyAction.cs.meta diff --git a/Assets/Art/DrawLine/Line.prefab b/Assets/Art/DrawLine/Line.prefab index 8789b451..21e627f7 100644 --- a/Assets/Art/DrawLine/Line.prefab +++ b/Assets/Art/DrawLine/Line.prefab @@ -128,7 +128,7 @@ LineRenderer: numCapVertices: 0 alignment: 0 textureMode: 1 - textureScale: {x: 1, y: 1} + textureScale: {x: 10, y: 1} shadowBias: 0.5 generateLightingData: 0 m_MaskInteraction: 0 diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index b8566a30..0d421db8 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -147,9 +147,10 @@ public class ActionHelper var strAction = (XMLTool.StringListAction)act; return CameraSwitchAction.Allocate(strAction.args[0], strAction.args[1], strAction.args[2], strAction.args[3], strAction.args[4], strAction.args[5], strAction.args[6]); } - case "LockCamera": + case "CameraLock": { - return LockCameraAction.Allocate(act.Value); + var strAction = (XMLTool.StringListAction)act; + return CameraLockAction.Allocate(strAction.args[0], strAction.args[1]); } case "Video": { @@ -174,7 +175,11 @@ public class ActionHelper case "Line": { var strAction = (XMLTool.StringListAction)act; - return LineAction.Allocate(act.Name, act.Value, strAction.args[0]); + return LineAction.Allocate(act.Name, act.Value, strAction.args[0], strAction.args[1], strAction.args[2]); + } + case "Destroy": + { + return DestroyAction.Allocate(act.Value); } default: Debug.LogError($"ûҵAction{act.Type}"); diff --git a/Assets/Scripts/Actions/LockCameraAction.cs b/Assets/Scripts/Actions/CameraLockAction.cs similarity index 61% rename from Assets/Scripts/Actions/LockCameraAction.cs rename to Assets/Scripts/Actions/CameraLockAction.cs index 8f053d03..5a2d87bc 100644 --- a/Assets/Scripts/Actions/LockCameraAction.cs +++ b/Assets/Scripts/Actions/CameraLockAction.cs @@ -3,27 +3,29 @@ using UnityEngine; namespace QFramework { - internal class LockCameraAction : IAction + internal class CameraLockAction : IAction { public System.Action OnFinished { get; set; } - private LockCameraAction() + private CameraLockAction() { } - private static readonly SimpleObjectPool mPool = - new SimpleObjectPool(() => new LockCameraAction(), null, 10); - string isLock; - public static LockCameraAction Allocate(string isLock, System.Action OnFinished = null) + private static readonly SimpleObjectPool mPool = + new SimpleObjectPool(() => new CameraLockAction(), null, 10); + string isMove; + string isRotate; + public static CameraLockAction Allocate(string isMove, string isRotate, System.Action OnFinished = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.Deinited = false; retNode.Reset(); - retNode.isLock = isLock; + retNode.isMove = isMove; + retNode.isRotate = isRotate; retNode.OnFinished = OnFinished; return retNode; } @@ -33,10 +35,12 @@ namespace QFramework public ActionStatus Status { get; set; } public void OnStart() - { - bool cameraLock = false; - bool.TryParse(isLock, out cameraLock); - FreeCameraController.instance.SetLock(cameraLock); + { + bool isMov = true; + bool isRot = true; + bool.TryParse(isMove, out isMov); + bool.TryParse(isRotate, out isRot); + FreeCameraController.instance.SetLock(isMov, isRot); } public void OnExecute(float dt) diff --git a/Assets/Scripts/Actions/LockCameraAction.cs.meta b/Assets/Scripts/Actions/CameraLockAction.cs.meta similarity index 83% rename from Assets/Scripts/Actions/LockCameraAction.cs.meta rename to Assets/Scripts/Actions/CameraLockAction.cs.meta index b1ae16fd..92136008 100644 --- a/Assets/Scripts/Actions/LockCameraAction.cs.meta +++ b/Assets/Scripts/Actions/CameraLockAction.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b3aa7c1b51454fe49a1a1646c5236be6 +guid: 1a7e9684055af6048bdb95f014c3170a MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Actions/DestroyAction.cs b/Assets/Scripts/Actions/DestroyAction.cs new file mode 100644 index 00000000..eeb56493 --- /dev/null +++ b/Assets/Scripts/Actions/DestroyAction.cs @@ -0,0 +1,70 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using QFramework; +using System; +using QFramework.Example; +using DG.Tweening; +using System.ComponentModel.Design; +public class DestroyAction : IAction +{ + public ulong ActionID { get; set; } + public bool Deinited { get; set; } + public bool Paused { get; set; } + public ActionStatus Status { get; set; } + + + private static readonly SimpleObjectPool mPool = + new SimpleObjectPool(() => new DestroyAction(), null, 10); + string path; + public static DestroyAction Allocate(string path, System.Action onDelayFinish = null) + { + var retNode = mPool.Allocate(); + retNode.ActionID = ActionKit.ID_GENERATOR++; + retNode.Deinited = false; + retNode.Reset(); + retNode.path = path; + return retNode; + } + + + + public void Deinit() + { + if (!Deinited) + { + Deinited = true; + mPool.Recycle(this); + } + } + + public void OnExecute(float dt) + { + } + + public void OnFinish() + { + } + + public void OnStart() + { + + GameObject obj = Utility.FindObj(path); + if (obj == null) + { + Debug.LogError("ûҵ :" + path); + } + else + { + GameObject.Destroy(obj); + } + this.Finish(); + + } + + public void Reset() + { + Status = ActionStatus.NotStart; + Paused = false; + } +} diff --git a/Assets/Scripts/Actions/DestroyAction.cs.meta b/Assets/Scripts/Actions/DestroyAction.cs.meta new file mode 100644 index 00000000..2aa8dec3 --- /dev/null +++ b/Assets/Scripts/Actions/DestroyAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6f130e736d1064c4c83655115abcf453 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Actions/LineAction.cs b/Assets/Scripts/Actions/LineAction.cs index 98f6e0d1..b7e28a00 100644 --- a/Assets/Scripts/Actions/LineAction.cs +++ b/Assets/Scripts/Actions/LineAction.cs @@ -1,6 +1,7 @@ using QFramework.Example; using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using UnityEngine; using static UnityEditor.Progress; @@ -22,7 +23,9 @@ namespace QFramework public string paths; public string name; Color color = Color.green; - public static LineAction Allocate(string name, string paths, string color, System.Action OnFinished = null) + float width = 0.1f; + Vector2 scale = Vector2.one; + public static LineAction Allocate(string name, string paths, string color, string width, string lineScale, System.Action OnFinished = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; @@ -34,6 +37,11 @@ namespace QFramework { retNode.color = Utility.ToColor(color); } + float.TryParse(width, out retNode.width); + if (string.IsNullOrEmpty(lineScale) == false) + { + retNode.scale = Utility.GetVector2FromStrArray(lineScale); + } retNode.OnFinished = OnFinished; return retNode; } @@ -53,7 +61,10 @@ namespace QFramework obj.name = name; var render = obj.GetOrAddComponent(); + render.startWidth = width; + render.endWidth = width; render.material.color = color; + render.textureScale = scale; var pathsArr = paths.Split('|'); for (int i = 0; i < pathsArr.Length; i++) { diff --git a/Assets/Scripts/Conditions/StrEventCondition.cs b/Assets/Scripts/Conditions/StrEventCondition.cs index 611ea5ea..9caff2a3 100644 --- a/Assets/Scripts/Conditions/StrEventCondition.cs +++ b/Assets/Scripts/Conditions/StrEventCondition.cs @@ -38,7 +38,6 @@ namespace QFramework private void OnEventFnished() { - Debug.LogError("111"); StringEventSystem.Global.UnRegister(key, OnEventFnished); this.Finish(); } diff --git a/Assets/Scripts/FreeCameraController.cs b/Assets/Scripts/FreeCameraController.cs index 871d427c..89c40a15 100644 --- a/Assets/Scripts/FreeCameraController.cs +++ b/Assets/Scripts/FreeCameraController.cs @@ -20,8 +20,8 @@ public class FreeCameraController : MonoBehaviour private bool isDragging = false; private float xRotation = 0.0f; private float yRotation = 0.0f; - public bool isLock = false; - + public bool isMov = true; + public bool isRot = true; private void Awake() { instance = this; @@ -32,7 +32,7 @@ public class FreeCameraController : MonoBehaviour void Update() { - if (isLock == false) + if (isMov == true) { // ƶ float horizontal = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime; @@ -40,8 +40,9 @@ public class FreeCameraController : MonoBehaviour Vector3 move = transform.right * horizontal + transform.forward * vertical; transform.position += move; - - // ת + } + if (isRot) + { if (Input.GetMouseButtonDown(1)) { lastMousePosition = Input.mousePosition; @@ -53,9 +54,11 @@ public class FreeCameraController : MonoBehaviour { isDragging = false; } - if (isDragging) { + // ת + + Vector3 mouseDelta = Input.mousePosition - lastMousePosition; // תֵ lastMousePosition = Input.mousePosition; @@ -75,6 +78,9 @@ public class FreeCameraController : MonoBehaviour } } + + + } // תָ @@ -101,8 +107,9 @@ public class FreeCameraController : MonoBehaviour //maxRotationLimitY = currentRotation.y + yRotationLimit / 2; } - public void SetLock(bool isLock) + public void SetLock(bool isMov, bool isRot) { - this.isLock = isLock; + this.isMov = isMov; + this.isRot = isRot; } } \ No newline at end of file diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index 34b7bc85..0f1ad7a7 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -597,6 +597,30 @@ namespace XMLTool newAction = act; } break; + case "CameraLock": + { + var act = new StringListAction(); + XAttribute isMove = action.Attribute("isMove"); + if (isMove != null) + { + act.args.Add(isMove.Value); + } + else + { + act.args.Add("true"); + } + XAttribute isRotate = action.Attribute("isRotate"); + if (isRotate != null) + { + act.args.Add(isRotate.Value); + } + else + { + act.args.Add("true"); + } + newAction = act; + } + break; case "TextTip": { var act = new StringListAction(); @@ -767,6 +791,24 @@ namespace XMLTool { act.args.Add(""); } + XAttribute width = action.Attribute("width"); + if (width != null) + { + act.args.Add(width.Value); + } + else + { + act.args.Add("0.1"); + } + XAttribute lineScale = action.Attribute("lineScale"); + if (lineScale != null) + { + act.args.Add(lineScale.Value); + } + else + { + act.args.Add("1,1"); + } newAction = act; } break; diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index cef7b692..b5a60869 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -22,7 +22,7 @@ - - + + + +