Forráskód Böngészése

添加相机效果

DESKTOP-FB72PO8\Administrator 5 hónapja
szülő
commit
a3244292bd

+ 109 - 0
Assets/Art/HeroTimeLine/Hero01.playable

@@ -446,6 +446,22 @@ MonoBehaviour:
   m_Rotation: {x: 0, y: 0, z: 0, w: 1}
   isRunPlay: 0
   layerId: 0
+--- !u!114 &-7162324253849020917
+MonoBehaviour:
+  m_ObjectHideFlags: 1
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 683eb9f12ea94ddda5e5780eaceef1d1, type: 3}
+  m_Name: CameraShakingAsset
+  m_EditorClassIdentifier: 
+  camera:
+    exposedName: 
+    defaultValue: {fileID: 0}
+  qiangDu: 0.3
 --- !u!114 &-7083228526680016239
 MonoBehaviour:
   m_ObjectHideFlags: 1
@@ -492,6 +508,7 @@ MonoBehaviour:
   m_Children:
   - {fileID: -3153904920175548778}
   - {fileID: 515659726093480869}
+  - {fileID: -889926587357520947}
   m_Clips: []
   m_Markers:
     m_Objects: []
@@ -993,6 +1010,98 @@ MonoBehaviour:
   m_Clips: []
   m_Markers:
     m_Objects: []
+--- !u!114 &-889926587357520947
+MonoBehaviour:
+  m_ObjectHideFlags: 1
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 3fc2695741642bd42a34534ca2286500, type: 3}
+  m_Name: Customize Track (1)
+  m_EditorClassIdentifier: 
+  m_Version: 3
+  m_AnimClip: {fileID: 0}
+  m_Locked: 0
+  m_Muted: 0
+  m_CustomPlayableFullTypename: 
+  m_Curves: {fileID: 0}
+  m_Parent: {fileID: -7018264418762285241}
+  m_Children: []
+  m_Clips:
+  - m_Version: 1
+    m_Start: 0.2
+    m_ClipIn: 0
+    m_Asset: {fileID: -7162324253849020917}
+    m_Duration: 0.26666666666666666
+    m_TimeScale: 1
+    m_ParentTrack: {fileID: -889926587357520947}
+    m_EaseInDuration: 0
+    m_EaseOutDuration: 0
+    m_BlendInDuration: -1
+    m_BlendOutDuration: -1
+    m_MixInCurve:
+      serializedVersion: 2
+      m_Curve:
+      - serializedVersion: 3
+        time: 0
+        value: 0
+        inSlope: 0
+        outSlope: 0
+        tangentMode: 0
+        weightedMode: 0
+        inWeight: 0
+        outWeight: 0
+      - serializedVersion: 3
+        time: 1
+        value: 1
+        inSlope: 0
+        outSlope: 0
+        tangentMode: 0
+        weightedMode: 0
+        inWeight: 0
+        outWeight: 0
+      m_PreInfinity: 2
+      m_PostInfinity: 2
+      m_RotationOrder: 4
+    m_MixOutCurve:
+      serializedVersion: 2
+      m_Curve:
+      - serializedVersion: 3
+        time: 0
+        value: 1
+        inSlope: 0
+        outSlope: 0
+        tangentMode: 0
+        weightedMode: 0
+        inWeight: 0
+        outWeight: 0
+      - serializedVersion: 3
+        time: 1
+        value: 0
+        inSlope: 0
+        outSlope: 0
+        tangentMode: 0
+        weightedMode: 0
+        inWeight: 0
+        outWeight: 0
+      m_PreInfinity: 2
+      m_PostInfinity: 2
+      m_RotationOrder: 4
+    m_BlendInCurveMode: 0
+    m_BlendOutCurveMode: 0
+    m_ExposedParameterNames: []
+    m_AnimationCurves: {fileID: 0}
+    m_Recordable: 0
+    m_PostExtrapolationMode: 0
+    m_PreExtrapolationMode: 0
+    m_PostExtrapolationTime: 0
+    m_PreExtrapolationTime: 0
+    m_DisplayName: CameraShakingAsset
+  m_Markers:
+    m_Objects: []
 --- !u!114 &-757740235362837759
 MonoBehaviour:
   m_ObjectHideFlags: 1

+ 17 - 0
Assets/Res/CombatScenes/TestCombatScenes.prefab

@@ -909,6 +909,7 @@ GameObject:
   serializedVersion: 7
   m_Component:
   - component: {fileID: 5372369682255974467}
+  - component: {fileID: 1932646405540330048}
   m_Layer: 0
   m_HasEditorInfo: 1
   m_Name: CombatRoot
@@ -933,3 +934,19 @@ Transform:
   - {fileID: 684568781563919061}
   m_Father: {fileID: 386538483028777619}
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!114 &1932646405540330048
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8662191797414001423}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: e1ee1c62c905bb24ea7c9cf3d9d40b56, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  trauma: 0
+  TraumaExponent: 1
+  MaximumAngularShake: {x: 5, y: 5, z: 5}
+  MaximumTranslationShake: {x: 0.75, y: 0.75, z: 0.75}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
Assets/Res/TimeLineAssets/Hero01_TD.txt


+ 1 - 1
Assets/Scenes/testCombat.scene

@@ -154,7 +154,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 72b9dd5ad46807849b93ecfaf88c1343, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  BundleLoadType: 2
+  BundleLoadType: 0
   h5Url: http://42.192.110.229/WY/Bundle/
 --- !u!4 &1421949366
 Transform:

+ 5 - 2
Assets/Scripts/Core/CameraEffect/StressReceiver.cs

@@ -14,10 +14,11 @@ public class StressReceiver : MonoBehaviour
     [Tooltip("Maximum translation that the gameobject can receive when applying the shake effect.")]
     public Vector3 MaximumTranslationShake = Vector3.one * .75f;
 
+    private System.Action callBack;
     [ContextMenu("asdasda")]
     public void Test()
     {
-        InduceStress(trauma);
+        InduceStress(trauma,null);
     }
 
     private void Update()
@@ -53,6 +54,7 @@ public class StressReceiver : MonoBehaviour
             transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles - _lastRotation);
             _lastPosition = Vector3.zero;
             _lastRotation = Vector3.zero;
+            callBack?.Invoke();
         }
     }
 
@@ -60,8 +62,9 @@ public class StressReceiver : MonoBehaviour
     ///  Applies a stress value to the current object.
     /// </summary>
     /// <param name="Stress">[0,1] Amount of stress to apply to the object</param>
-    public void InduceStress(float Stress)
+    public void InduceStress(float Stress,System.Action callBack)
     {
+        this.callBack = callBack;
         _trauma = Mathf.Clamp01(_trauma + Stress);
     }
 }

+ 0 - 47
Assets/Scripts/Core/CameraEffect/TraumaInducer.cs

@@ -1,47 +0,0 @@
- using UnityEngine;
-using System.Collections;
-
-/* Example script to apply trauma to the camera or any game object */
-public class TraumaInducer : MonoBehaviour 
-{
-    [Tooltip("Seconds to wait before trigerring the explosion particles and the trauma effect")]
-    public float Delay = 1;
-    [Tooltip("Maximum stress the effect can inflict upon objects Range([0,1])")]
-    public float MaximumStress = 0.6f;
-    [Tooltip("Maximum distance in which objects are affected by this TraumaInducer")]
-    public float Range = 45;
-
-    private IEnumerator Start()
-    {
-        /* Wait for the specified delay */
-        yield return new WaitForSeconds(Delay);
-        /* Play all the particle system this object has */
-        // PlayParticles();
-
-        /* Find all gameobjects in the scene and loop through them until we find all the nearvy stress receivers */
-        var targets = UnityEngine.Object.FindObjectsOfType<GameObject>();
-        for(int i = 0; i < targets.Length; ++i)
-        {
-            var receiver = targets[i].GetComponent<StressReceiver>();
-            if(receiver == null) continue;
-            float distance = Vector3.Distance(transform.position, targets[i].transform.position);
-            /* Apply stress to the object, adjusted for the distance */
-            if(distance > Range) continue;
-            float distance01 = Mathf.Clamp01(distance / Range);
-            float stress = (1 - Mathf.Pow(distance01, 2)) * MaximumStress;
-            receiver.InduceStress(stress);
-        }
-    }
-
-    /* Search for all the particle system in the game objects children */
-    private void PlayParticles()
-    {
-        var children = transform.GetComponentsInChildren<ParticleSystem>();
-        for(var i  = 0; i < children.Length; ++i)
-        {
-            children[i].Play();
-        }
-        var current = GetComponent<ParticleSystem>();
-        if(current != null) current.Play();
-    }
-}

+ 0 - 11
Assets/Scripts/Core/CameraEffect/TraumaInducer.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 47b6b88d425f7234aae309cb9a973743
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 10 - 0
Assets/Scripts/GameLogic/Combat/CombatEvent/CameraShakeEventData.cs

@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+using Core.Utility.Event;
+
+namespace Common.Utility.CombatEvent
+{
+    public class CameraShakeEventData : EventDataBasic<CameraShakeEventData>
+    {
+        public float shakeTime;
+    }
+}

+ 3 - 0
Assets/Scripts/GameLogic/Combat/CombatEvent/CameraShakeEventData.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 558b0ce893b54bb6ab32fa7b40b29b59
+timeCreated: 1731491444

+ 1 - 0
Assets/Scripts/GameLogic/Combat/CombatEvent/CombatEventType.cs

@@ -7,5 +7,6 @@
         HeroDie,
         HeroHpUpdate,
         HarmUpdate,
+        CameraShake,
     }
 }

+ 45 - 8
Assets/Scripts/GameLogic/Combat/CombatTool/CombatCameraControllder.cs

@@ -1,31 +1,68 @@
-using UnityEngine;
+using System;
+using Common.Utility.CombatEvent;
+using Fort23.Core;
+using UnityEngine;
+using Utility.CustomizeTimeLogic.FxLogic.TimeLineEvent;
+using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
 
 namespace GameLogic.Combat.CombatTool
 {
-    public class CombatCameraControllder
+    public class CombatCameraControllder : IDisposable, ICameraShaking
     {
         public Transform root;
         public Camera Camera;
         public CombatController combatController;
+        public StressReceiver StressReceiver;
+
+        private bool isStartShake;
 
         public void Init(CombatController combatController, Camera camera)
         {
             this.combatController = combatController;
             Camera = camera;
             root = Camera.transform.parent;
+            StressReceiver = camera.transform.GetComponentInParent<StressReceiver>();
+            TimeLineSingletonEventManager.Instance.AddTimeLineBasic(this);
+        }
+
+
+        private void ShakeFinish()
+        {
+            isStartShake = false;
         }
 
         public void Update(float t)
         {
-            CombatHeroEntity[] combatHeroEntities = combatController.CombatHeroController.GetHero(false);
-            Vector3 p = Vector3.zero;
-            for (int i = 0; i < combatHeroEntities.Length; i++)
+            if (!isStartShake)
             {
-                p += combatHeroEntities[i].dotPos;
+                CombatHeroEntity[] combatHeroEntities = combatController.CombatHeroController.GetHero(false);
+                if (combatHeroEntities == null)
+                {
+                    return;
+                }
+
+                Vector3 p = Vector3.zero;
+                for (int i = 0; i < combatHeroEntities.Length; i++)
+                {
+                    p += combatHeroEntities[i].dotPos;
+                }
+
+                p /= combatHeroEntities.Length;
+                root.position = Vector3.Lerp(root.position, new Vector3(p.x, root.position.y, p.z - 7), 0.3f);
             }
+        }
+
+        public void Dispose()
+        {
+        }
 
-            p /= combatHeroEntities.Length;
-            root.position = Vector3.Lerp(root.position, new Vector3(p.x, root.position.y, p.z - 7), 0.3f);
+        public void Shaking(CameraShakingSerializtion cameraShakingSerializtion)
+        {
+            if (StressReceiver != null)
+            {
+                isStartShake = true;
+                StressReceiver.InduceStress(cameraShakingSerializtion.qiangDu, ShakeFinish);
+            }
         }
     }
 }

+ 2 - 11
Assets/Scripts/GameTimeLine/CustomizeTime/CameraShakingAsset/CameraShakingAsset.cs

@@ -8,23 +8,14 @@ using Utility;
 public class CameraShakingAsset : CustomizePlayableAsset
 {
     [Header("激活对象")] public ExposedReference<Camera> camera;
-    [Header("抖动方向")] public ShakeDirection direction;
-    // [Header("曲线类型")] public int type;
-    [Header("抖动时间")] public float totalTime;
-    [Header("抖动次数")] public int count;
-    [Header("抖动强度")] public float qiangDu;
-    [Header("动画曲线")] public AnimationCurve AnimationCurve;
+    [Header("强度")] public float qiangDu;
+ 
 
     public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
     {
         ScriptPlayable<CameraShakingBehaviour> playable =
             ScriptPlayable<CameraShakingBehaviour>.Create(graph);
-        playable.GetBehaviour().direction = direction;
-        // playable.GetBehaviour().type = type;
-        playable.GetBehaviour().totalTime = totalTime;
-        playable.GetBehaviour().count = count;
         playable.GetBehaviour().qiangDu = qiangDu;
-        playable.GetBehaviour().AnimationCurve = AnimationCurve;
         playable.GetBehaviour().Camera = camera.Resolve(graph.GetResolver());
         return playable;
     }

+ 0 - 29
Assets/Scripts/GameTimeLine/SerializationTimeLine/TimeLineSerialization/CameraShakingSerializtion.cs

@@ -14,13 +14,7 @@ using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic;
 [System.Serializable]
 public class CameraShakingSerializtion : TimeLineAssetSerialization
 {
-    public ShakeDirection direction;
-    public int type;
-    public CurveInfo[] keys;
-    
-    public int count;
     public float qiangDu;
-
     public CameraShakingSerializtion()
     {
         
@@ -31,30 +25,7 @@ public class CameraShakingSerializtion : TimeLineAssetSerialization
     public CameraShakingSerializtion(PlayableDirector playableDirector, GroupTrack groupTrack, TimelineClip timelineClip) : base(groupTrack, timelineClip)
     {
         CameraShakingAsset audioPlayableAsset = timelineClip.asset as CameraShakingAsset;
-        direction = audioPlayableAsset.direction;
-        // type = audioPlayableAsset.type;
-        count = audioPlayableAsset.count;
-        totalTime = audioPlayableAsset.totalTime;
         qiangDu = audioPlayableAsset.qiangDu;
-        if (audioPlayableAsset.AnimationCurve != null)
-        {
-            keys = new CurveInfo[audioPlayableAsset.AnimationCurve.keys.Length];
-            for (int i = 0; i < audioPlayableAsset.AnimationCurve.keys.Length; i++)
-            {
-                CurveInfo curveInfo = new CurveInfo();
-                curveInfo.t = audioPlayableAsset.AnimationCurve.keys[i].time;
-                curveInfo.v = audioPlayableAsset.AnimationCurve.keys[i].value;
-                curveInfo.it = audioPlayableAsset.AnimationCurve.keys[i].inTangent;
-                curveInfo.ot = audioPlayableAsset.AnimationCurve.keys[i].outTangent;
-                keys[i] = curveInfo;
-            }
-          
-        }
-        else
-        {
-            keys = new CurveInfo[2] {new CurveInfo(), new CurveInfo()};
-        }
-
     }
 #endif
     public override TimeLineEventLogicBasic CreateLogic()

+ 0 - 1
Fort23.Core.csproj

@@ -228,7 +228,6 @@
     <Compile Include="Assets\Scripts\Core\UI\UTool\EditoUILoadSpriteHand.cs" />
     <Compile Include="Assets\Scripts\Core\Attribute\CTask\AsyncMethodBuilderAttribute.cs" />
     <Compile Include="Assets\Scripts\Core\UI\Core\UIDataManager.cs" />
-    <Compile Include="Assets\Scripts\Core\CameraEffect\TraumaInducer.cs" />
     <Compile Include="Assets\Scripts\Core\Utility\SafeTool.cs" />
     <Compile Include="Assets\Scripts\Core\AssetLoadTool\Asset\AssetBundleLoadManager.cs" />
     <Compile Include="Assets\Scripts\Core\Utility\Helper\ObjectHelper.cs" />

+ 1 - 0
Fort23.GameLogic.csproj

@@ -63,6 +63,7 @@
     <Compile Include="Assets\Scripts\GameLogic\Combat\CombatTool\HarmReturnInfo.cs" />
     <Compile Include="Assets\Scripts\GameLogic\Combat\CombatEvent\CombatItemShowEventData.cs" />
     <Compile Include="Assets\Scripts\GameLogic\Combat\Hero\CombatHeroEntity.cs" />
+    <Compile Include="Assets\Scripts\GameLogic\Combat\CombatEvent\CameraShakeEventData.cs" />
     <Compile Include="Assets\Scripts\GameLogic\Combat\CombatState\CombatIdleState.cs" />
     <Compile Include="Assets\Scripts\GameLogic\CombatScenesTool\CombatScenesNodeConfig.cs" />
     <Compile Include="Assets\Scripts\GameLogic\Combat\CombatEvent\CreateHeroHpEventData.cs" />

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott