Ejemplo n.º 1
0
        private void Slash()
        {
            IEnumerator DoSlash()
            {
                FlyMoveTo fm = gameObject.AddComponent <FlyMoveTo>();

                fm.enabled       = false;
                fm.target        = _target;
                fm.distance      = 3;
                fm.speedMax      = 12;
                fm.acceleration  = 0.75f;
                fm.targetsHeight = true;
                fm.height        = 0;
                fm.enabled       = true;
                yield return(new WaitWhile(() =>
                                           Vector2.Distance(_target.transform.position, transform.position) > 5f));

                Log("ATTACKING TIME");
                _anim.Play("Slash Antic");
                yield return(new WaitWhile(() => _anim.IsPlaying("Slash Antic")));

                Destroy(fm);
                //float dir = FaceHero();
                _rb.velocity = new Vector2(8f * side, 0f);
                _anim.Play("Slash Antic");
                _slash.SetActive(true);
                tk2dSpriteAnimator tk = _slash.GetComponent <tk2dSpriteAnimator>();

                _slash.GetComponent <PolygonCollider2D>().enabled = true;
                tk.Play("Slash Effect");
                yield return(null);

                _anim.Play("Slash");
                yield return(new WaitForSeconds(0.083f));

                yield return(new WaitWhile(() => _anim.IsPlaying("Slash")));

                _slash.GetComponent <PolygonCollider2D>().enabled = false;
                _slash.SetActive(false);
                _anim.Play("Slash CD");
                yield return(new WaitWhile(() => _anim.IsPlaying("Slash CD")));

                _anim.Play("Fly");
                StartCoroutine(AttackChooser());
            }

            //FaceHero();
            StartCoroutine(DoSlash());
        }
Ejemplo n.º 2
0
        private void Fireball()
        {
            IEnumerator DoFire()
            {
                ParticleSystem.EmissionModule em = _shadePartic.emission;
                em.rate = 900f;
                FlyMoveTo fm = gameObject.AddComponent <FlyMoveTo>();

                fm.enabled       = false;
                fm.target        = _target;
                fm.distance      = 12;
                fm.speedMax      = 12;
                fm.acceleration  = 0.75f;
                fm.targetsHeight = true;
                fm.height        = 0;
                fm.enabled       = true;
                yield return(new WaitWhile(() =>
                                           !FastApproximately(_target.transform.position.x, transform.position.x, 12f)));

                yield return(new WaitWhile(() =>
                                           !FastApproximately(_target.transform.position.y, transform.position.y, 0.4f)));

                ParticleSystem.EmissionModule em2 = _chargePartic.emission;
                em2.rate = 50;
                _anim.Play("Cast Antic");
                Destroy(fm);
                float time = 0.08f;

                while (time > 0f)
                {
                    _rb.velocity = new Vector2(_rb.velocity.x * 0.8f, _rb.velocity.y * 0.8f);
                    time        -= Time.fixedDeltaTime;
                    yield return(null);
                }
                yield return(new WaitForSeconds(0.05f));

                _rb.velocity = Vector2.zero;
                em.rate      = 20;
                em2.rate     = 0;
                _anim.Play("Cast Charge");
                GameObject effect = Instantiate(_ring);

                effect.SetActive(true);
                Vector3 tmp = effect.transform.localScale;

                effect.transform.position   = transform.position + new Vector3(side * 1.664f, 0.12f, -0.112f);
                effect.transform.localScale = new Vector3(tmp.x * 2 * side, tmp.y * 2, tmp.z);
                yield return(new WaitForSeconds(0.05f));

                GameObject ball = Instantiate(LordOfShade.preloadedGO["ball"]);

                ball.SetActive(true);
                tmp = ball.transform.localScale;
                ball.transform.position   = transform.position;
                ball.transform.localScale = new Vector3(side * 2f, tmp.y * 2f, tmp.z);
                Rigidbody2D rb = ball.GetComponent <Rigidbody2D>();

                rb.velocity = new Vector2(side * 30f, 0f);
                GameCameras.instance.cameraShakeFSM.SendEvent("AverageShake");
                _anim.Play("Cast");
                _rb.velocity = new Vector2(side * -10, 0);
                yield return(null);

                while (_anim.IsPlaying("Cast"))
                {
                    _rb.velocity = new Vector2(_rb.velocity.x * 0.9f, _rb.velocity.y * 0.9f);
                    yield return(null);
                }
                _anim.Play("Fly");
                time = 0.1f;
                while (time > 0f)
                {
                    _rb.velocity = new Vector2(_rb.velocity.x * 0.9f, _rb.velocity.y * 0.9f);
                    time        -= Time.fixedDeltaTime;
                    yield return(null);
                }
                StartCoroutine(AttackChooser());
            }

            _mana--;
            StartCoroutine(DoFire());
        }