// Update is called once per frame
    public void FixedUpdate()
    {
        if (particleTime >= 1.3f)
        {
            particleTime = 0.0f;
            if (moveSpeed == 0.5f)
            {
                particleEffect = Resources.Load <GeneralEffect>("Effects/FreezeEffect");
                Instantiate(particleEffect, transform.position, transform.rotation);
                particleEffect.timeDeath = 0.6f;
            }
        }
        else
        {
            particleTime += Time.deltaTime;
        }

        if (doneSummon == false)//1.6s for animation to take place.
        {
            if (summonTime <= 1.0f)
            {
                summonTime += Time.deltaTime;
                //Debug.Log(summonTime);
            }
            else
            {
                doneSummon = true;
                startMove  = true;
            }
        }
        attackTime   += Time.deltaTime;
        particleTime += Time.deltaTime;
        Vector3 pointTowards = transform.position.normalized;

        pointTowards.z = 0.0f;
        Vector3 pointTarget = (mainTarget.transform.position - transform.position).normalized;

        pointTowards.z = 0.0f;
        float dotProduct  = Vector3.Dot(pointTarget, transform.right);
        float targetAngle = Vector3.Angle(pointTowards, pointTarget);
        //Debug.Log(targetAngle);
        Quaternion targetRotation = Quaternion.Euler(0, 0, -1 * Mathf.Sign(dotProduct) * targetAngle);

        transform.rotation = Quaternion.Slerp(transform.rotation, transform.rotation * targetRotation, moveSpeed * 3 * Time.deltaTime);
    }
Esempio n. 2
0
 void cardEffect(string effect, float power, List <GameObject> enemiesInRange)
 {
     foreach (GameObject enemy in enemiesInRange)
     {
         if (enemy)
         {
             if (effect == "Damage")
             {
                 enemy.GetComponent <EnemyBehavior>().OnHit((int)power);
                 //fumaça
                 particleEffect = Resources.Load <GeneralEffect>("Effects/FireEffect");
                 Instantiate(particleEffect, enemy.transform.position, enemy.transform.rotation);
             }
             if (effect == "Slow")
             {
                 enemy.GetComponent <EnemyBehavior>().ApplyEffect(effect);
             }
         }
     }
 }