Ejemplo n.º 1
0
    void Update()
    {
        healthSlider.value = healthScript.GetHealth();
        manaSlider.value   = healthScript.GetMana();

        healthSlider.maxValue = healthScript.GetMaxHealth();
        manaSlider.maxValue   = healthScript.GetMaxMana();
    }
Ejemplo n.º 2
0
    //TODO - SPELL TYPES
    void Fire()
    {
        //Only allow swinging if the current swing is done
        if (!isFiring && healthmana.GetMana() > spell.manaCost)
        {
            isFiring = true;

            healthmana.ModMana(-1 * spell.manaCost);

            //If it's a projectile, targeting friendlies OR enemies
            if (!spell.isSelfSpell)
            {
                GameObject activeProjectile = (GameObject)Instantiate(projectilePrefab, handTransform.position, Quaternion.identity);
                activeProjectile.GetComponent <ProjectileSpell> ().SetSpellEffect(spell);
                activeProjectile.GetComponent <Rigidbody> ().AddForce(headTransform.forward * spell.projectileSpeed);

                //We no longer ignore the player, as we want AoE friendly spells to hit them, but their weapons *are* ignored
                //Physics.IgnoreCollision (activeProjectile.GetComponent<Collider> (), GetComponent<Collider>());
                Physics.IgnoreCollision(activeProjectile.GetComponent <Collider> (), transform.Find("CharacterHead").Find("RightWep").Find("RightWepHandle").GetComponent <Collider>());
                Physics.IgnoreCollision(activeProjectile.GetComponent <Collider> (), transform.Find("CharacterHead").Find("RightWep").Find("RightWepBlade").GetComponent <Collider>());
            }             //If it's a self spell that targets you (not an area around you or enemies)
            else if (spell.isSelfSpell && !spell.AoE && !spell.targetsEnemies)
            {
                charEffects.AddEffect(new SpellEffect(spell.effect));
                //Aesthetic spell spawn
                GameObject activeProjectile = (GameObject)Instantiate(projectilePrefab, handTransform.position, Quaternion.identity);
                //Set the spell to a blank one

                activeProjectile.GetComponent <ProjectileSpell> ().DestroySelf();
                activeProjectile.GetComponent <ProjectileSpell> ().SetSpellEffect(new Spell());
                //Apply knockback only if there's actually knockback to apply
                if (spell.effect.instantKnockback != 0)
                {
                    Vector3 force = headTransform.forward;
                    force.y += .5f;
                    force.Normalize();
                    force *= spell.effect.instantKnockback;
                    //Stop motion before applying knockback if the next line is uncommented
                    //move.StopMotion ();
                    move.AddKnockback(force);
                }
            }             //If it's a self spell that is AoE
            else if (spell.isSelfSpell && spell.AoE)
            {
                //Just spawn a projectile without any velocity
                GameObject activeProjectile = (GameObject)Instantiate(projectilePrefab, transform.position, Quaternion.identity);
                activeProjectile.GetComponent <ProjectileSpell> ().SetSpellEffect(spell);
                activeProjectile.GetComponent <ProjectileSpell> ().Explode();
            }
        }
    }