Beispiel #1
0
 // same as cast magic for the player
 public void ShootMagic(Spell spell)
 {
     if (spell.spellPrefab == null)
     {
         Debug.LogWarning("Spell prefab is null");
     }
     else
     {
         GameObject spellObject = Instantiate(spell.spellPrefab, SpawnLoc.position, SpawnLoc.rotation); //Camera.main.GetComponent<Transform>().rotation);
         spellObject.AddComponent <Rigidbody>();
         spellObject.GetComponent <Rigidbody>().useGravity = false;
         spellObject.GetComponent <Rigidbody>().velocity   = spellObject.transform.forward * spell.ProjectileSpeed;
         spellObject.name             = spell.spellName;
         spellObject.transform.parent = GameObject.Find("RPGManager").transform;
         SpellCollision spellCollision = spellObject.GetComponent <SpellCollision>();
         if (spellCollision)
         {
             spellCollision.spell = spell;
             if (spell.elemental_Type == Spell.EleType.Water)
             {
                 spellCollision.CalculateImpactDamage();
             }
             if (spell.elemental_Type == Spell.EleType.Fire)
             {
                 spellCollision.CalculateImpactDamage();
                 spellCollision.CalculateElementDamage();
             }
         }
         Destroy(spellObject, 2);
     }
 }
Beispiel #2
0
	public void Setup (){ //(List<ElementManager> list) {
		//elements = new List<elementType> ();
		//foreach(ElementManager e in list){
		//	elements.Add(e.elementType);
		//}
		//Choose Texture
		spellMovement = instance.GetComponent<SpellMovement> ();
		spellCollision = instance.GetComponent<SpellCollision> ();
		spellCollision.id = id;
	}
Beispiel #3
0
    public void CastMagic(Spell spell)
    {
        if (spell.spellPrefab == null)                // if spell prefab is null
        {
            Debug.LogWarning("Spell prefab is null"); // warning
        }
        else
        {
            GameObject spellObject = Instantiate(spell.spellPrefab, SpawnLoc.position, SpawnLoc.rotation);             // spawns the object from the spawn loc on the player
            spellObject.AddComponent <Rigidbody>();                                                                    // adds a rigidbody to the spell object
            spellObject.GetComponent <Rigidbody>().useGravity = false;                                                 // sets the gravity to false so the object just doesnt fall to the ground
            spellObject.GetComponent <Rigidbody>().velocity   = spellObject.transform.forward * spell.ProjectileSpeed; // adds velocity based projectile speed value
            spellObject.name = spell.spellName;
            Debug.Log("Player used " + spell.ManaCost);                                                                // debug
            PlayerStats playerStats = GetComponent <PlayerStats>();                                                    // gets the player stats
            playerStats.currMana -= spell.ManaCost;
            Debug.Log(playerStats.currMana);                                                                           // debug

            spellObject.transform.parent = GameObject.Find("RPGManager").transform;
            SpellCollision spellCollision = spellObject.GetComponent <SpellCollision>();
            if (spellCollision) // spell collides
            {
                spellCollision.spell = spell;
                if (spell.elemental_Type == Spell.EleType.Water) // if spell type is water
                {
                    spellCollision.CalculateImpactDamage();      // calculate impact damage
                }
                if (spell.elemental_Type == Spell.EleType.Fire)  // if spell type is fire
                {
                    spellCollision.CalculateImpactDamage();      // calculate impact damage
                    spellCollision.CalculateElementDamage();     // calculate element damage
                }
            }


            Destroy(spellObject, 2); // destroies the object after 2 secs
        }
    }