Ejemplo n.º 1
0
    protected virtual void InstantiateParticleEffect(FightingEntity user, FightingEntity target)
    {
        FighterPositions userPositions   = user.GetComponent <FighterPositions>();
        FighterPositions targetPositions = target.GetComponent <FighterPositions>();

        if (particleHitEffectPrefab != null && userPositions != null && targetPositions != null)
        {
            GameObject            hitEffect = Instantiate(particleHitEffectPrefab, targetPositions.damagePopup);
            ParticleSystemsHelper psh       = hitEffect.GetComponent <ParticleSystemsHelper>();
            hitEffect.GetComponent <DestroyAfterSeconds>().duration = GetAnimWindup();
            psh.SetDestroyDuration(GetAnimWindup());
            psh.SetRenderOrder(target.sortingOrder + 1);
            psh.PositionEffect(userPositions.damagePopup, targetPositions.damagePopup);
            psh.Play();
        }
    }
    private IEnumerator AnimateToTarget()
    {
        float counter = 0;

        while (counter < this.projectileMoveTime)
        {
            float t = counter / projectileMoveTime;

            Vector3 projectilePos = Vector3.Lerp(this._userTransform.position, this._targetTransform.position, t);  // May want a more refined lerp in the future
            this.transform.position = projectilePos;
            counter += GameManager.Instance.time.deltaTime;

            yield return(null);
        }

        base.Clear();
        base.Stop();
        ParticleSystemsHelper psh = Instantiate(explosionPrefab, this._targetTransform);

        // hitEffect.SetDestroyDuration(5f); // maybe let the animation handle this?
        psh.SetRenderOrder(this._orderInLayer);
        psh.PositionEffect(this._userTransform, this._targetTransform);
        psh.Play();
    }