Exemplo n.º 1
0
    void OnTriggerEnter(Collider other)
    {
        Rigidbody thisRigid = GetComponent <Rigidbody>();

        if (stuck && other.gameObject.tag.Equals("PlayerAttack"))
        {
            stuck = false;
            thisRigid.velocity = new Vector3(-lastChargeVelocity.x / 4, -lastChargeVelocity.y / 8, -lastChargeVelocity.z / 4);
        }

        if (charge)
        {
            charge = false;
            if (other.gameObject.tag.Equals("Player"))
            {
                thisRigid.velocity = new Vector3(-lastChargeVelocity.x / 4, -lastChargeVelocity.y / 8, -lastChargeVelocity.z / 4);
                HealthControl collided = other.GetComponent <HealthControl>();
                if (collided)
                {
                    collided.takeDamage(stats.modifiers.damage);
                }
            }
            else
            {
                //Stuck in object
                thisRigid.velocity = Vector3.zero;
                stuck = true;
            }
        }
    }
Exemplo n.º 2
0
    void enemyCollision(GameObject collidedObject)
    {
        if (collidedObject.tag.Equals("Player"))
        {
            HealthControl collidedHealth = collidedObject.GetComponent <HealthControl>();
            collidedHealth.takeDamage(modifiers.damage);

            if (modifiers.dot)
            {
                collidedHealth.applyDot(modifiers.dotTick, modifiers.dotLength);
            }
        }
    }
Exemplo n.º 3
0
    void OnTriggerStay(Collider other)
    {
        if (other.gameObject.tag.Equals("Enemy"))
        {
            if (!calcDamage)
            {
                timeCount += Time.deltaTime;
                calcDamage = true;
            }
            if (timeCount >= damageCooldown)
            {
                HealthControl collidedHealth = other.gameObject.GetComponent <HealthControl>();
                collidedHealth.takeDamage(modifiers.damage);

                timeCount -= Time.deltaTime;
            }
        }
    }
Exemplo n.º 4
0
    public override void fire(SpellMod modifiers, Transform firePoint, Camera mainCam)
    {
        GameObject temp = Instantiate(projectile, mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)) - mainCam.transform.forward.normalized * 10, firePoint.rotation);

        RaycastHit[] hits;

        ISpellCollision spellCollision = temp.GetComponent <ISpellCollision>();

        temp.GetComponent <Rigidbody>().velocity = mainCam.transform.forward.normalized * 500;
        hits = Physics.SphereCastAll(mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)), 0.5f, mainCam.transform.forward);
        Debug.DrawRay(mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)), mainCam.transform.forward);
        if (hits.Length > 0)
        {
            hits = raycastSort(hits, firePoint.position);
            foreach (RaycastHit hit in hits)
            {
                if (hit.collider.tag == "Enemy")
                {
                    HealthControl collidedHealth = hit.collider.GetComponent <HealthControl>();
                    collidedHealth.takeDamage(modifiers.damage * modifiers.damagePercent);

                    if (modifiers.dot)
                    {
                        collidedHealth.applyDot(modifiers.dotTick, modifiers.dotLength);
                    }
                }
                else if (hit.collider.tag == "EnemyAttack")
                {
                    Destroy(hit.collider.gameObject);
                }
                else if (hit.collider.gameObject.layer == 0)
                {
                    //modifiers.range = (hit.point - temp.transform.position).magnitude / 250;
                    return;
                }
            }
            spellCollision.setModifiers(modifiers);
        }
    }