summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Effects/AfterImage
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-11-04 08:59:59 +0800
committerchai <chaifix@163.com>2020-11-04 08:59:59 +0800
commitd02d8779f4c36d4aec58a5d2d460f482894af3b8 (patch)
tree800881bfaff28115eb063a5795f0343905ed7c20 /Assets/Scripts/Effects/AfterImage
parentef739e3c4d66007fb9c2ced195edb539eb92f3a4 (diff)
*after image
Diffstat (limited to 'Assets/Scripts/Effects/AfterImage')
-rw-r--r--Assets/Scripts/Effects/AfterImage/AfterImage.cs79
-rw-r--r--Assets/Scripts/Effects/AfterImage/AfterImage.cs.meta11
-rw-r--r--Assets/Scripts/Effects/AfterImage/AfterImagePool.cs50
-rw-r--r--Assets/Scripts/Effects/AfterImage/AfterImagePool.cs.meta11
4 files changed, 151 insertions, 0 deletions
diff --git a/Assets/Scripts/Effects/AfterImage/AfterImage.cs b/Assets/Scripts/Effects/AfterImage/AfterImage.cs
new file mode 100644
index 00000000..1e1d0393
--- /dev/null
+++ b/Assets/Scripts/Effects/AfterImage/AfterImage.cs
@@ -0,0 +1,79 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class AfterImage : MonoBehaviour
+{
+ public Animator myAnimator;
+ //public CharacterControl myCharacterControl;
+ public Renderer myRenderer;
+
+ public Animator targetAnimator;
+ public GameObject targetObject;
+
+ public float time;
+ public float intensity;
+ public float pow;
+ public float timeMax = 45;
+
+ public bool active;
+
+ // Use this for initialization
+ void Start()
+ {
+ //targetObject =
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+ if (time > 0)
+ {
+ time--;
+ active = true;
+ intensity = (time / timeMax) * 10 * pow;
+ UpdateRenderer();
+ }
+ else
+ {
+ active = false;
+ intensity = 0;
+ }
+ }
+
+ void UpdateRenderer()
+ {
+ myRenderer.material.SetFloat("_Intensity", intensity);
+ myRenderer.material.SetFloat("_MKGlowPower", intensity);
+ }
+
+ public void Activate()
+ {
+ active = true;
+ transform.position = targetObject.transform.position;
+ transform.localScale = targetObject.transform.lossyScale;
+ transform.rotation = targetObject.transform.rotation;
+
+ myAnimator.Play(targetAnimator.GetCurrentAnimatorStateInfo(0).shortNameHash, 0, targetAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime);
+ //myAnimator.Play(myCharacterControl.animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
+ //myAnimator.no
+
+ //foreach (AnimatorControllerParameter param in targetAnimator.parameters)
+ //{
+ // if (param.type == AnimatorControllerParameterType.Float)
+ // {
+ // myAnimator.SetFloat(param.name, targetAnimator.GetFloat(param.name));
+ // }
+ // if (param.type == AnimatorControllerParameterType.Int)
+ // {
+ // myAnimator.SetInteger(param.name, targetAnimator.GetInteger(param.name));
+ // }
+ //}
+
+ myAnimator.speed = 0.02f;
+ myAnimator.Update(1/60f);
+ time = timeMax + 1;
+ Update();
+ }
+
+} \ No newline at end of file
diff --git a/Assets/Scripts/Effects/AfterImage/AfterImage.cs.meta b/Assets/Scripts/Effects/AfterImage/AfterImage.cs.meta
new file mode 100644
index 00000000..cd1fd19a
--- /dev/null
+++ b/Assets/Scripts/Effects/AfterImage/AfterImage.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5912e1e5f1e32ea429bf6a9ec2d11a0f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs b/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs
new file mode 100644
index 00000000..f9d033fd
--- /dev/null
+++ b/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs
@@ -0,0 +1,50 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class AfterImagePool : MonoBehaviour
+{
+
+ //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;
+ public List<AfterImage> afterImages;
+
+ public int interval = 10;
+
+ public int time = 0;
+
+ // Use this for initialization
+ void Start()
+ {
+ //myCharacterControl = transform.root.GetComponent<CharacterControl>();
+ //Debug.Log("START AFTER IMAGE POOL");
+ afterImages = new List<AfterImage>(poolSize);
+ for (int i = 0; i < poolSize; i++)
+ {
+ GameObject nextAfterImage = Instantiate(prefab);
+ afterImages.Add(nextAfterImage.GetComponent<AfterImage>());
+
+ nextAfterImage.GetComponent<AfterImage>().targetObject = targetObject; //Game Object Target
+ nextAfterImage.GetComponent<AfterImage>().targetAnimator = targetAnimator; //Animator Target
+ }
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+ //if (CitadelDeep.hitPause > 0 || CitadelDeep.debugPause) { return; }
+ time++;
+ if (time > interval) { time = 0; AddAfterImage(); }
+ }
+
+ void AddAfterImage()
+ {
+ for (int i = 0; i < poolSize; i++)
+ {
+ if (!afterImages[i].active) { afterImages[i].Activate(); break; }
+ }
+ }
+} \ No newline at end of file
diff --git a/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs.meta b/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs.meta
new file mode 100644
index 00000000..78d84907
--- /dev/null
+++ b/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4aaea939b0abb3c4eb78963aedf4b2f3
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: