summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Effects
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-11-06 20:41:04 +0800
committerchai <chaifix@163.com>2020-11-06 20:41:04 +0800
commit79ff94365b572d0e64ba945dcef2641ee508faa7 (patch)
tree063b2f29aa312885725e3ac203f9355d303f754d /Assets/Scripts/Effects
parent6118fbc482417cdd44f21748fc02b093a3e0ac7b (diff)
*空中攻击
Diffstat (limited to 'Assets/Scripts/Effects')
-rw-r--r--Assets/Scripts/Effects/AfterImage/AfterImage.cs3
-rw-r--r--Assets/Scripts/Effects/AfterImage/AfterImagePool.cs27
-rw-r--r--Assets/Scripts/Effects/Effect.cs30
-rw-r--r--Assets/Scripts/Effects/Effect.cs.meta11
-rw-r--r--Assets/Scripts/Effects/EffectsManager.cs73
-rw-r--r--Assets/Scripts/Effects/EffectsManager.cs.meta11
6 files changed, 148 insertions, 7 deletions
diff --git a/Assets/Scripts/Effects/AfterImage/AfterImage.cs b/Assets/Scripts/Effects/AfterImage/AfterImage.cs
index 445a16c2..123c0300 100644
--- a/Assets/Scripts/Effects/AfterImage/AfterImage.cs
+++ b/Assets/Scripts/Effects/AfterImage/AfterImage.cs
@@ -48,9 +48,6 @@ public class AfterImage : MonoBehaviour
{
for(int i = 0;i < renderer.materials.Length; ++i)
{
- renderer.materials[i].SetColor("_Color", Color.red);
- renderer.materials[i].SetColor("_Color1", Color.white);
- renderer.materials[i].SetColor("_Color2", Color.white);
renderer.materials[i].SetFloat("_Intensity", intensity);
renderer.materials[i].SetFloat("_MKGlowPower", intensity);
}
diff --git a/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs b/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs
index 8b32fe38..38d3488d 100644
--- a/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs
+++ b/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs
@@ -4,9 +4,10 @@ using UnityEngine;
public class AfterImagePool : MonoBehaviour
{
-
- //public CharacterControl myCharacterControl;
- public GameObject targetObject; //Set these manually to the character object you're copying
+ public static AfterImagePool Instance;
+
+ //public CharacterControl myCharacterControl;
+ public GameObject targetObject; //Set these manually to the character object you're copying
public Animator targetAnimator; //Set these manually to the character object you're copying
public GameObject prefab; //This is the prefab you made in the scene. It's a parent transform with an animator and AfterImage script on it, with Armature and SkinnedMeshRenderer children
public int poolSize = 10;
@@ -16,6 +17,8 @@ public class AfterImagePool : MonoBehaviour
public int time = 0;
+ private bool isActive = false;
+
// Use this for initialization
void Start()
{
@@ -32,13 +35,17 @@ public class AfterImagePool : MonoBehaviour
afterImages.Add(nextAfterImage.GetComponent<AfterImage>());
}
+ Instance = this;
}
// Update is called once per frame
void Update()
{
+ if (!isActive)
+ return;
+
time++;
- if (time > interval)
+ if (time >= interval)
{
time = 0;
AddAfterImage();
@@ -56,4 +63,16 @@ public class AfterImagePool : MonoBehaviour
}
}
}
+
+ public void Activate(bool isActive)
+ {
+ this.isActive = isActive;
+ time = isActive ? interval : 0;
+ }
+
+ public void SetInterval(int interval)
+ {
+ this.interval = interval;
+ }
+
} \ No newline at end of file
diff --git a/Assets/Scripts/Effects/Effect.cs b/Assets/Scripts/Effects/Effect.cs
new file mode 100644
index 00000000..a8f0d37f
--- /dev/null
+++ b/Assets/Scripts/Effects/Effect.cs
@@ -0,0 +1,30 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Effect : MonoBehaviour
+{
+ public string Name;
+ public float LifeTime;
+
+ private float time;
+
+ private void Awake()
+ {
+ }
+
+ private void OnEnable()
+ {
+ time = 0;
+ }
+
+ private void Update()
+ {
+ time += Time.deltaTime;
+ if(time > LifeTime)
+ {
+ EffectsManager.Instance.CycleEffect(this);
+ }
+ }
+
+}
diff --git a/Assets/Scripts/Effects/Effect.cs.meta b/Assets/Scripts/Effects/Effect.cs.meta
new file mode 100644
index 00000000..ea99b00a
--- /dev/null
+++ b/Assets/Scripts/Effects/Effect.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a0f48b3d527ef6c49999e8a4b9892cd9
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Effects/EffectsManager.cs b/Assets/Scripts/Effects/EffectsManager.cs
new file mode 100644
index 00000000..f62b0bdb
--- /dev/null
+++ b/Assets/Scripts/Effects/EffectsManager.cs
@@ -0,0 +1,73 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using System;
+
+public class EffectsManager : MonoBehaviour
+{
+ public static EffectsManager Instance;
+
+ public Effect[] EffectTemplates;
+
+ public Transform Root_Pool;
+
+ List<Effect> m_Pool = new List<Effect>();
+
+ private void Awake()
+ {
+ Instance = this;
+ }
+
+ Effect GetEffectTemplate(string name)
+ {
+ foreach(var effect in EffectTemplates)
+ {
+ if(effect != null && effect.Name == name)
+ {
+ return effect;
+ }
+ }
+ return null;
+ }
+
+ Effect RecycleEffect(string name)
+ {
+ foreach(var effect in m_Pool)
+ {
+ if (effect != null && effect.Name == name)
+ {
+ return effect;
+ }
+ }
+ return null;
+ }
+
+ public void PlayEffect(string name, Vector3 position, Vector3 rotation, Vector3 scale)
+ {
+ Effect effect = RecycleEffect(name);
+ if(effect == null)
+ {
+ Effect temp = GetEffectTemplate(name);
+ effect = UnityEngine.Object.Instantiate(temp);
+ }
+ else
+ {
+ m_Pool.Remove(effect);
+ }
+
+ effect.transform.position = position;
+ effect.transform.rotation = Quaternion.Euler(rotation);
+ effect.transform.localScale = scale;
+ effect.transform.SetParent(this.transform);
+ effect.gameObject.SetActive(true);
+ }
+
+ // 回收特效
+ public void CycleEffect(Effect effect)
+ {
+ effect.gameObject.SetActive(false);
+ effect.transform.SetParent(Root_Pool);
+ m_Pool.Add(effect);
+ }
+
+}
diff --git a/Assets/Scripts/Effects/EffectsManager.cs.meta b/Assets/Scripts/Effects/EffectsManager.cs.meta
new file mode 100644
index 00000000..b8dd8f96
--- /dev/null
+++ b/Assets/Scripts/Effects/EffectsManager.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: db461c57209f8a241a28d33730ad12ef
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: