Ejemplo n.º 1
0
    //======================================================================================== FIREBALL

    public IEnumerator FireBallCoroutine()
    {
        isAttacking = true;

        anim.SetTrigger("LineFireBallShrink");

        FxFireLeft.SetActive(true);
        FxFireRight.SetActive(true);

        yield return(new WaitForSeconds(4.2f));

        FxFireLeft.SetActive(false);
        FxFireRight.SetActive(false);

        Vector3 target = aimedPlayer.transform.position;

        Vector3 fireBallStartingPoint = transform.position + new Vector3(0f, 8.5f, 0f);// + 2.8f * dir;

        GameObject projectileFireBall = Instantiate(fireBallPrefab, fireBallStartingPoint, Quaternion.identity);
        FireBall   fireBall           = projectileFireBall.GetComponent <FireBall>();

        float travelTime = 0;

        if (fireBall != null)
        {
            fireBall.Init(fireBallDamage, fireBallDamageExplosion, fireBallRangeExplosion, fireBallSpeed);
            travelTime = fireBall.Launch(target + new Vector3(0f, 1.5f, 0f), fireBallStartingPoint);//offset so the fireball aims for the body of the player and not his/her feet
        }

        soundEmitter.PlaySound(1);

        //show indicator feedback
        //instanciate the fireball indicator
        GameObject fireBallIndicator = Instantiate(fireBallProjector, target + new Vector3(0f, 1.5f, 0f), Quaternion.identity) as GameObject;

        projectorList.Add(fireBallIndicator);
        fireBallProjector.transform.GetChild(0).gameObject.GetComponent <Projector>().orthographicSize = fireBallRangeExplosion * toleranceCoef;
        float timeStamp = Time.time;
        Color tempColor = Color.red;

        while (Time.time - timeStamp < travelTime)
        {
            //alpha starting from 0 finishing to 0.5
            tempColor.a = ((Time.time - timeStamp) / electricAoeTimeBetweenFeedbackAndCast) / 2;
            fireBallIndicator.transform.GetChild(0).gameObject.GetComponent <Projector>().material.color = tempColor;
            yield return(new WaitForEndOfFrame());
        }


        yield return(new WaitUntil(() => fireBall.willBeDestroyed));

        Destroy(fireBallIndicator);
        soundEmitter.PlaySound(2);

        nextAttack  = Time.time + Random.Range(minWaitTime, maxWaitTime);
        isAttacking = false;
    }
Ejemplo n.º 2
0
 public override void AttackAction()
 {
     for (int i = -number + 1; i <= number - 1; i += 2)
     {
         FireBall fireBall = GameObject.Instantiate(Links.links.fireBall).GetComponent <FireBall>();
         fireBall.Attacker = attacker;
         fireBall.damage   = damage;
         fireBall.lifeTime = range / speed;
         fireBall.speed    = speed;
         float   ang       = i * angle / 2;
         Vector3 direction = Quaternion.AngleAxis(ang, Vector3.up) * attacker.transform.forward;
         fireBall.Launch(attacker.transform.position + 0.5f * direction + attacker.centerHeight * Vector3.up, direction);
     }
 }