Example #1
0
        public IEnumerator SpawnShockwave(CastHand hand, float delay)
        {
            Transform handT;

            if (hand == CastHand.RightHand)
            {
                handT = rightHand;
            }
            else
            {
                handT = leftHand;
            }

            yield return(new WaitForSeconds(delay));

            GameObject newShockwave = Instantiate(spellPrefab, handT.position, Quaternion.identity);

            Transform t = newShockwave.transform;

            t.position = new Vector3(t.position.x, 0.001f, t.position.z);

            if (hand == CastHand.RightHand)
            {
                if (castEffectR != null)
                {
                    Destroy(castEffectR);
                }
            }
            else
            {
                if (castEffectL != null)
                {
                    Destroy(castEffectL);
                }
            }



            yield return(new WaitForSeconds(3f));

            Renderer r = newShockwave.GetComponent <Renderer>();

            Color initColor = r.material.GetColor("_Color");
            Color endColor  = new Color(initColor.r, initColor.g, initColor.b, 0);

            float i = 0;

            while (i < 1)
            {
                i += Time.deltaTime * 5f;
                r.material.SetColor("_Color", Color.Lerp(initColor, endColor, i));
                yield return(0);
            }



            Destroy(t.gameObject);
        }
Example #2
0
        public IEnumerator SpawnHealing(CastHand hand, float delay)
        {
            Transform handT;

            if (hand == CastHand.RightHand)
            {
                handT = rightHand;
            }
            else
            {
                handT = leftHand;
            }

            yield return(new WaitForSeconds(delay));

            GameObject newHealing = Instantiate(spellPrefab, handT.position, Quaternion.identity);

            Transform t = newHealing.transform;

            t.rotation *= Quaternion.Euler(0, 180f, 0);

            t.localScale    = new Vector3(0.25f, 0.25f, 0.25f);
            t.localPosition = new Vector3(t.localPosition.x, t.localPosition.y, t.localPosition.z);

            if (hand == CastHand.RightHand)
            {
                if (castEffectR != null)
                {
                    Destroy(castEffectR);
                }
            }
            else
            {
                if (castEffectL != null)
                {
                    Destroy(castEffectL);
                }
            }


            Vector3 startSize = t.localScale;

            float i = 0;

            while (i < 1)
            {
                i           += Time.deltaTime * 8f;
                t.localScale = Vector3.Lerp(startSize, Vector3.one, i);
                yield return(0);
            }

            yield return(new WaitForSeconds(1f));

            Destroy(t.gameObject);
        }
Example #3
0
 public void SpawnEffect(CastHand hand)
 {
     if (hand == CastHand.RightHand)
     {
         castEffectR = Instantiate(castEffectPrefab, rightHand);
         castEffectR.transform.localPosition = castEffectR.transform.localPosition + handOffset;
     }
     else
     {
         castEffectL = Instantiate(castEffectPrefab, leftHand);
         castEffectL.transform.localPosition = castEffectL.transform.localPosition + handOffset;
     }
 }
Example #4
0
        public IEnumerator SpawnFireball(CastHand hand, float delay)
        {
            Transform handT;

            if (hand == CastHand.RightHand)
            {
                handT = rightHand;
            }
            else
            {
                handT = leftHand;
            }

            yield return(new WaitForSeconds(delay));

            GameObject newFireball = Instantiate(spellPrefab, handT.position, Quaternion.identity);

            newFireball.transform.rotation *= Quaternion.Euler(0, 180f, 0);

            newFireball.transform.localScale    = new Vector3(0.25f, 0.25f, 0.25f);
            newFireball.transform.localPosition = new Vector3(newFireball.transform.localPosition.x, newFireball.transform.localPosition.y, newFireball.transform.localPosition.z + spellOffset);

            StartCoroutine(AppearFireball(newFireball.transform));
            StartCoroutine(MoveFireball(newFireball.transform));


            if (hand == CastHand.RightHand)
            {
                if (castEffectR != null)
                {
                    Destroy(castEffectR);
                }
            }
            else
            {
                if (castEffectL != null)
                {
                    Destroy(castEffectL);
                }
            }
        }
Example #5
0
 public void ThrowShockwave(CastHand hand, float delay)
 {
     StartCoroutine(SpawnShockwave(hand, delay));
 }
Example #6
0
 public void ThrowHealing(CastHand hand, float delay)
 {
     StartCoroutine(SpawnHealing(hand, delay));
 }
Example #7
0
 public void ThrowFireball(CastHand hand, float delay)
 {
     StartCoroutine(SpawnFireball(hand, delay));
 }