net.dreditor.phraseanimations 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.attestation.p7m +0 -0
- package/AnimData.cs +41 -41
- package/AnimData.cs.meta +11 -11
- package/DREditor.PhraseAnimations.asmdef +19 -19
- package/DREditor.PhraseAnimations.asmdef.meta +7 -7
- package/Editor/CompactPhraseTypeEditor.cs +96 -96
- package/Editor/CompactPhraseTypeEditor.cs.meta +11 -11
- package/Editor/PhraseAnimationEditor.cs +179 -179
- package/Editor/PhraseAnimationEditor.cs.meta +11 -11
- package/Editor/PhraseAnimationTypeEditor.cs +24 -24
- package/Editor/PhraseAnimationTypeEditor.cs.meta +11 -11
- package/Editor/PhraseAnimationTypeList.cs +23 -23
- package/Editor/PhraseAnimationTypeList.cs.meta +11 -11
- package/Editor/PhraseFadeTypeEditor.cs +18 -18
- package/Editor/PhraseFadeTypeEditor.cs.meta +11 -11
- package/Editor/PhraseRotationTypeEditor.cs +19 -19
- package/Editor/PhraseRotationTypeEditor.cs.meta +11 -11
- package/Editor/PhraseScaleTypeEditor.cs +19 -19
- package/Editor/PhraseScaleTypeEditor.cs.meta +11 -11
- package/Editor/PhraseTransformTypeEditor.cs +18 -18
- package/Editor/PhraseTransformTypeEditor.cs.meta +11 -11
- package/Editor/PhraseTypeEditor.cs +277 -277
- package/Editor/PhraseTypeEditor.cs.meta +11 -11
- package/Editor.meta +8 -8
- package/IPhraseAnimationType.cs +16 -16
- package/IPhraseAnimationType.cs.meta +11 -11
- package/PhraseAnimation.cs +73 -73
- package/PhraseAnimation.cs.meta +11 -11
- package/PhraseAnimationCompact.cs +44 -44
- package/PhraseAnimationCompact.cs.meta +11 -11
- package/PhraseAnimationHandler.cs +135 -135
- package/PhraseAnimationHandler.cs.meta +11 -11
- package/PhraseAnimationTypeBase.cs +53 -53
- package/PhraseAnimationTypeBase.cs.meta +11 -11
- package/PhraseFadeType.cs +19 -19
- package/PhraseFadeType.cs.meta +11 -11
- package/PhraseRotationType.cs +27 -27
- package/PhraseRotationType.cs.meta +11 -11
- package/PhraseScaleType.cs +25 -25
- package/PhraseScaleType.cs.meta +11 -11
- package/PhraseTransformType.cs +25 -25
- package/PhraseTransformType.cs.meta +11 -11
- package/package.json +42 -37
- package/package.json.meta +7 -7
package/PhraseAnimation.cs
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using DREditor.Minigames.Debates;
|
|
3
|
-
using System.Collections.Generic;
|
|
4
|
-
using System.Linq;
|
|
5
|
-
using UnityEngine;
|
|
6
|
-
|
|
7
|
-
namespace DREditor.PhraseAnimations
|
|
8
|
-
{
|
|
9
|
-
/// <summary>
|
|
10
|
-
///
|
|
11
|
-
/// </summary>
|
|
12
|
-
[System.Serializable]
|
|
13
|
-
public class PhraseAnimation : IPhraseAnimationArchitecture
|
|
14
|
-
{
|
|
15
|
-
/// <summary>
|
|
16
|
-
///
|
|
17
|
-
/// </summary>
|
|
18
|
-
public Vector3 spawnPoint;
|
|
19
|
-
|
|
20
|
-
/// <summary>
|
|
21
|
-
///
|
|
22
|
-
/// </summary>
|
|
23
|
-
public Vector4 spawnAngle;
|
|
24
|
-
|
|
25
|
-
/// <summary>
|
|
26
|
-
///
|
|
27
|
-
/// </summary>
|
|
28
|
-
public List<AnimData> animations = new();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/// <summary>
|
|
32
|
-
///
|
|
33
|
-
/// </summary>
|
|
34
|
-
/// <param name="spawnPoint"></param>
|
|
35
|
-
public virtual void SetSpawnPoint(Vector3 spawnPoint) => this.spawnPoint = spawnPoint;
|
|
36
|
-
|
|
37
|
-
/// <summary>
|
|
38
|
-
///
|
|
39
|
-
/// </summary>
|
|
40
|
-
/// <param name="spawnAngle"></param>
|
|
41
|
-
public virtual void SetSpawnAngle(Vector4 spawnAngle) => this.spawnAngle = spawnAngle;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/// <inheritdoc/>
|
|
45
|
-
public virtual void Initialize(object o = null)
|
|
46
|
-
{
|
|
47
|
-
if (o is AnimationClip clip)
|
|
48
|
-
foreach (AnimData anim in animations)
|
|
49
|
-
anim.Initialize(clip);
|
|
50
|
-
else
|
|
51
|
-
UnityEngine.Debug.LogWarning($"ALERT: Failed to initialize animation architecture: {nameof(PhraseAnimation)}" +
|
|
52
|
-
$" because the sent value for initialization was not of type {nameof(AnimationClip)}.");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/// <inheritdoc/>
|
|
56
|
-
public virtual void Apply(IPhraseAnimationArchitecture architecture)
|
|
57
|
-
{
|
|
58
|
-
PhraseAnimation animation = architecture as PhraseAnimation;
|
|
59
|
-
|
|
60
|
-
spawnPoint = animation.spawnPoint;
|
|
61
|
-
|
|
62
|
-
spawnAngle = animation.spawnAngle;
|
|
63
|
-
|
|
64
|
-
foreach (var newAnimation in animation.animations)
|
|
65
|
-
{
|
|
66
|
-
if (animations.Any(animation => animation.animationType?.GetType() == newAnimation.animationType?.GetType()))
|
|
67
|
-
UnityEngine.Debug.Log("REPORT: The phrases simple animation contains duplicate types." +
|
|
68
|
-
"\nPROPOSAL: Test animation to ensure no animations conflict with each other.");
|
|
69
|
-
|
|
70
|
-
animations.Add(newAnimation);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Minigames.Debates;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.PhraseAnimations
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
[System.Serializable]
|
|
13
|
+
public class PhraseAnimation : IPhraseAnimationArchitecture
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
///
|
|
17
|
+
/// </summary>
|
|
18
|
+
public Vector3 spawnPoint;
|
|
19
|
+
|
|
20
|
+
/// <summary>
|
|
21
|
+
///
|
|
22
|
+
/// </summary>
|
|
23
|
+
public Vector4 spawnAngle;
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
public List<AnimData> animations = new();
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
/// <param name="spawnPoint"></param>
|
|
35
|
+
public virtual void SetSpawnPoint(Vector3 spawnPoint) => this.spawnPoint = spawnPoint;
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
///
|
|
39
|
+
/// </summary>
|
|
40
|
+
/// <param name="spawnAngle"></param>
|
|
41
|
+
public virtual void SetSpawnAngle(Vector4 spawnAngle) => this.spawnAngle = spawnAngle;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/// <inheritdoc/>
|
|
45
|
+
public virtual void Initialize(object o = null)
|
|
46
|
+
{
|
|
47
|
+
if (o is AnimationClip clip)
|
|
48
|
+
foreach (AnimData anim in animations)
|
|
49
|
+
anim.Initialize(clip);
|
|
50
|
+
else
|
|
51
|
+
UnityEngine.Debug.LogWarning($"ALERT: Failed to initialize animation architecture: {nameof(PhraseAnimation)}" +
|
|
52
|
+
$" because the sent value for initialization was not of type {nameof(AnimationClip)}.");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// <inheritdoc/>
|
|
56
|
+
public virtual void Apply(IPhraseAnimationArchitecture architecture)
|
|
57
|
+
{
|
|
58
|
+
PhraseAnimation animation = architecture as PhraseAnimation;
|
|
59
|
+
|
|
60
|
+
spawnPoint = animation.spawnPoint;
|
|
61
|
+
|
|
62
|
+
spawnAngle = animation.spawnAngle;
|
|
63
|
+
|
|
64
|
+
foreach (var newAnimation in animation.animations)
|
|
65
|
+
{
|
|
66
|
+
if (animations.Any(animation => animation.animationType?.GetType() == newAnimation.animationType?.GetType()))
|
|
67
|
+
UnityEngine.Debug.Log("REPORT: The phrases simple animation contains duplicate types." +
|
|
68
|
+
"\nPROPOSAL: Test animation to ensure no animations conflict with each other.");
|
|
69
|
+
|
|
70
|
+
animations.Add(newAnimation);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
74
|
}
|
package/PhraseAnimation.cs.meta
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: d8da34f2f29d3a14184b82bfe14d87cb
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: d8da34f2f29d3a14184b82bfe14d87cb
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using System;
|
|
3
|
-
using UnityEngine.Serialization;
|
|
4
|
-
|
|
5
|
-
namespace DREditor.PhraseAnimations
|
|
6
|
-
{
|
|
7
|
-
/// <summary>
|
|
8
|
-
///
|
|
9
|
-
/// </summary>
|
|
10
|
-
/// <typeparam name="T"></typeparam>
|
|
11
|
-
[Serializable]
|
|
12
|
-
public abstract class PhraseAnimationCompact<T> : PhraseAnimationTypeBase
|
|
13
|
-
{
|
|
14
|
-
/// <summary>
|
|
15
|
-
///
|
|
16
|
-
/// </summary>
|
|
17
|
-
[FormerlySerializedAs("startScale")]
|
|
18
|
-
[FormerlySerializedAs("startPosition")]
|
|
19
|
-
[FormerlySerializedAs("startRotation")]
|
|
20
|
-
[FormerlySerializedAs("startFade")]
|
|
21
|
-
public T startValue;
|
|
22
|
-
|
|
23
|
-
/// <summary>
|
|
24
|
-
///
|
|
25
|
-
/// </summary>
|
|
26
|
-
[FormerlySerializedAs("endScale")]
|
|
27
|
-
[FormerlySerializedAs("endPosition")]
|
|
28
|
-
[FormerlySerializedAs("endRotation")]
|
|
29
|
-
[FormerlySerializedAs("endFade")]
|
|
30
|
-
public T endValue;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
/// <summary>
|
|
34
|
-
///
|
|
35
|
-
/// </summary>
|
|
36
|
-
/// <param name="startValue"></param>
|
|
37
|
-
public virtual void SetStartValue(T startValue) => this.startValue = startValue;
|
|
38
|
-
|
|
39
|
-
/// <summary>
|
|
40
|
-
///
|
|
41
|
-
/// </summary>
|
|
42
|
-
/// <param name="endValue"></param>
|
|
43
|
-
public virtual void SetEndValue(T endValue) => this.endValue = endValue;
|
|
44
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
using UnityEngine.Serialization;
|
|
4
|
+
|
|
5
|
+
namespace DREditor.PhraseAnimations
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
///
|
|
9
|
+
/// </summary>
|
|
10
|
+
/// <typeparam name="T"></typeparam>
|
|
11
|
+
[Serializable]
|
|
12
|
+
public abstract class PhraseAnimationCompact<T> : PhraseAnimationTypeBase
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[FormerlySerializedAs("startScale")]
|
|
18
|
+
[FormerlySerializedAs("startPosition")]
|
|
19
|
+
[FormerlySerializedAs("startRotation")]
|
|
20
|
+
[FormerlySerializedAs("startFade")]
|
|
21
|
+
public T startValue;
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
[FormerlySerializedAs("endScale")]
|
|
27
|
+
[FormerlySerializedAs("endPosition")]
|
|
28
|
+
[FormerlySerializedAs("endRotation")]
|
|
29
|
+
[FormerlySerializedAs("endFade")]
|
|
30
|
+
public T endValue;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
///
|
|
35
|
+
/// </summary>
|
|
36
|
+
/// <param name="startValue"></param>
|
|
37
|
+
public virtual void SetStartValue(T startValue) => this.startValue = startValue;
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
///
|
|
41
|
+
/// </summary>
|
|
42
|
+
/// <param name="endValue"></param>
|
|
43
|
+
public virtual void SetEndValue(T endValue) => this.endValue = endValue;
|
|
44
|
+
}
|
|
45
45
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: fa6154fbae76c6c43b4a61c4e222956d
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: fa6154fbae76c6c43b4a61c4e222956d
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using DREditor.Minigames.Debates;
|
|
3
|
-
using DREditor.Processables;
|
|
4
|
-
using TMPro;
|
|
5
|
-
using UnityEngine;
|
|
6
|
-
|
|
7
|
-
namespace DREditor.PhraseAnimations
|
|
8
|
-
{
|
|
9
|
-
/// <summary>
|
|
10
|
-
///
|
|
11
|
-
/// </summary>
|
|
12
|
-
[ClassHeader(nameof(IPhraseAnimationComponent) + ", " + nameof(IPhraseHandlerComponent) + ", " +
|
|
13
|
-
nameof(IPhraseShatterListener) + ", " + nameof(IPhraseResetter) + ", " + nameof(IPrioritizable) +
|
|
14
|
-
"\n\n")]
|
|
15
|
-
public class PhraseAnimationHandler : MonoBehaviour, IPhraseAnimationComponent, IPhraseShatterListener, IPrioritizable
|
|
16
|
-
{
|
|
17
|
-
/// <summary>
|
|
18
|
-
///
|
|
19
|
-
/// </summary>
|
|
20
|
-
[Tooltip("")]
|
|
21
|
-
[SerializeField] protected int priority = 0;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/// <summary>
|
|
25
|
-
///
|
|
26
|
-
/// </summary>
|
|
27
|
-
[Header("")]
|
|
28
|
-
[Divider]
|
|
29
|
-
[Tooltip("")]
|
|
30
|
-
[SerializeField] protected Animation compiledAnimation;
|
|
31
|
-
|
|
32
|
-
public int Priority { get => priority; set => priority = value; }
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/// <summary>
|
|
36
|
-
///
|
|
37
|
-
/// </summary>
|
|
38
|
-
protected readonly string animationClipName = "transform";
|
|
39
|
-
|
|
40
|
-
/// <summary>
|
|
41
|
-
///
|
|
42
|
-
/// </summary>
|
|
43
|
-
protected float duration;
|
|
44
|
-
|
|
45
|
-
/// <summary>
|
|
46
|
-
///
|
|
47
|
-
/// </summary>
|
|
48
|
-
protected PhraseAnimation phraseAnimation = null;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
protected virtual void Awake() => compiledAnimation = GetComponent<Animation>();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/// <inheritdoc/>
|
|
55
|
-
public virtual void StartPhrase<T>(T phrase) where T : PhraseBase
|
|
56
|
-
{
|
|
57
|
-
InitializePhraseAnimation(phrase);
|
|
58
|
-
|
|
59
|
-
if (phraseAnimation != null)
|
|
60
|
-
{
|
|
61
|
-
InitializeText();
|
|
62
|
-
|
|
63
|
-
CompilePhraseAnimation();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/// <summary>
|
|
68
|
-
///
|
|
69
|
-
/// </summary>
|
|
70
|
-
/// <param name="phrase"></param>
|
|
71
|
-
protected virtual void InitializePhraseAnimation(PhraseBase phrase)
|
|
72
|
-
{
|
|
73
|
-
phraseAnimation = null;
|
|
74
|
-
|
|
75
|
-
foreach (var architecture in phrase.animations)
|
|
76
|
-
if (architecture is PhraseAnimation phraseDataAnimation)
|
|
77
|
-
phraseAnimation = phraseDataAnimation;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/// <summary>
|
|
81
|
-
///
|
|
82
|
-
/// </summary>
|
|
83
|
-
protected virtual void InitializeText()
|
|
84
|
-
{
|
|
85
|
-
var tmpText = GetComponent<TMP_Text>();
|
|
86
|
-
|
|
87
|
-
tmpText.transform.localScale = Vector3.one;
|
|
88
|
-
|
|
89
|
-
//Below makes it to where using the dolly track only works once
|
|
90
|
-
if (phraseAnimation.spawnPoint == Vector3.zero || phraseAnimation.spawnPoint == null)
|
|
91
|
-
tmpText.transform.position = phraseAnimation.spawnPoint;
|
|
92
|
-
else
|
|
93
|
-
tmpText.transform.localPosition = phraseAnimation.spawnPoint;
|
|
94
|
-
|
|
95
|
-
Vector4 rot = phraseAnimation.spawnAngle;
|
|
96
|
-
|
|
97
|
-
tmpText.transform.localEulerAngles = new(rot.x, rot.y, rot.z);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/// <summary>
|
|
101
|
-
///
|
|
102
|
-
/// </summary>
|
|
103
|
-
protected virtual void CompilePhraseAnimation()
|
|
104
|
-
{
|
|
105
|
-
compiledAnimation.enabled = true;
|
|
106
|
-
|
|
107
|
-
AnimationClip animationClip = new()
|
|
108
|
-
{
|
|
109
|
-
legacy = true
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
phraseAnimation.Initialize(animationClip);
|
|
113
|
-
|
|
114
|
-
compiledAnimation.AddClip(animationClip, animationClipName);
|
|
115
|
-
|
|
116
|
-
compiledAnimation.Play(animationClipName);
|
|
117
|
-
|
|
118
|
-
duration = animationClip.length;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
/// <inheritdoc/>
|
|
123
|
-
public virtual void OnShattered()
|
|
124
|
-
{
|
|
125
|
-
compiledAnimation.Stop();
|
|
126
|
-
|
|
127
|
-
compiledAnimation.enabled = false;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/// <inheritdoc/>
|
|
131
|
-
public virtual float GetPhraseDuration() => duration;
|
|
132
|
-
|
|
133
|
-
/// <inheritdoc/>
|
|
134
|
-
public virtual void Reset() => compiledAnimation.enabled = false;
|
|
135
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Minigames.Debates;
|
|
3
|
+
using DREditor.Processables;
|
|
4
|
+
using TMPro;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.PhraseAnimations
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
[ClassHeader(nameof(IPhraseAnimationComponent) + ", " + nameof(IPhraseHandlerComponent) + ", " +
|
|
13
|
+
nameof(IPhraseShatterListener) + ", " + nameof(IPhraseResetter) + ", " + nameof(IPrioritizable) +
|
|
14
|
+
"\n\n")]
|
|
15
|
+
public class PhraseAnimationHandler : MonoBehaviour, IPhraseAnimationComponent, IPhraseShatterListener, IPrioritizable
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[Tooltip("")]
|
|
21
|
+
[SerializeField] protected int priority = 0;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
///
|
|
26
|
+
/// </summary>
|
|
27
|
+
[Header("")]
|
|
28
|
+
[Divider]
|
|
29
|
+
[Tooltip("")]
|
|
30
|
+
[SerializeField] protected Animation compiledAnimation;
|
|
31
|
+
|
|
32
|
+
public int Priority { get => priority; set => priority = value; }
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/// <summary>
|
|
36
|
+
///
|
|
37
|
+
/// </summary>
|
|
38
|
+
protected readonly string animationClipName = "transform";
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
///
|
|
42
|
+
/// </summary>
|
|
43
|
+
protected float duration;
|
|
44
|
+
|
|
45
|
+
/// <summary>
|
|
46
|
+
///
|
|
47
|
+
/// </summary>
|
|
48
|
+
protected PhraseAnimation phraseAnimation = null;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
protected virtual void Awake() => compiledAnimation = GetComponent<Animation>();
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
/// <inheritdoc/>
|
|
55
|
+
public virtual void StartPhrase<T>(T phrase) where T : PhraseBase
|
|
56
|
+
{
|
|
57
|
+
InitializePhraseAnimation(phrase);
|
|
58
|
+
|
|
59
|
+
if (phraseAnimation != null)
|
|
60
|
+
{
|
|
61
|
+
InitializeText();
|
|
62
|
+
|
|
63
|
+
CompilePhraseAnimation();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
///
|
|
69
|
+
/// </summary>
|
|
70
|
+
/// <param name="phrase"></param>
|
|
71
|
+
protected virtual void InitializePhraseAnimation(PhraseBase phrase)
|
|
72
|
+
{
|
|
73
|
+
phraseAnimation = null;
|
|
74
|
+
|
|
75
|
+
foreach (var architecture in phrase.animations)
|
|
76
|
+
if (architecture is PhraseAnimation phraseDataAnimation)
|
|
77
|
+
phraseAnimation = phraseDataAnimation;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
///
|
|
82
|
+
/// </summary>
|
|
83
|
+
protected virtual void InitializeText()
|
|
84
|
+
{
|
|
85
|
+
var tmpText = GetComponent<TMP_Text>();
|
|
86
|
+
|
|
87
|
+
tmpText.transform.localScale = Vector3.one;
|
|
88
|
+
|
|
89
|
+
//Below makes it to where using the dolly track only works once
|
|
90
|
+
if (phraseAnimation.spawnPoint == Vector3.zero || phraseAnimation.spawnPoint == null)
|
|
91
|
+
tmpText.transform.position = phraseAnimation.spawnPoint;
|
|
92
|
+
else
|
|
93
|
+
tmpText.transform.localPosition = phraseAnimation.spawnPoint;
|
|
94
|
+
|
|
95
|
+
Vector4 rot = phraseAnimation.spawnAngle;
|
|
96
|
+
|
|
97
|
+
tmpText.transform.localEulerAngles = new(rot.x, rot.y, rot.z);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// <summary>
|
|
101
|
+
///
|
|
102
|
+
/// </summary>
|
|
103
|
+
protected virtual void CompilePhraseAnimation()
|
|
104
|
+
{
|
|
105
|
+
compiledAnimation.enabled = true;
|
|
106
|
+
|
|
107
|
+
AnimationClip animationClip = new()
|
|
108
|
+
{
|
|
109
|
+
legacy = true
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
phraseAnimation.Initialize(animationClip);
|
|
113
|
+
|
|
114
|
+
compiledAnimation.AddClip(animationClip, animationClipName);
|
|
115
|
+
|
|
116
|
+
compiledAnimation.Play(animationClipName);
|
|
117
|
+
|
|
118
|
+
duration = animationClip.length;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
/// <inheritdoc/>
|
|
123
|
+
public virtual void OnShattered()
|
|
124
|
+
{
|
|
125
|
+
compiledAnimation.Stop();
|
|
126
|
+
|
|
127
|
+
compiledAnimation.enabled = false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// <inheritdoc/>
|
|
131
|
+
public virtual float GetPhraseDuration() => duration;
|
|
132
|
+
|
|
133
|
+
/// <inheritdoc/>
|
|
134
|
+
public virtual void Reset() => compiledAnimation.enabled = false;
|
|
135
|
+
}
|
|
136
136
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 97def5bdb68fbc441b85059609b0125d
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 97def5bdb68fbc441b85059609b0125d
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|