void OnSpellSwitched(SpellController newSpell) { if (newSpell != null) { newSpell.ShowSpell(true); } }
public SpellController ReadySpell(SpellController SpellPrefab) { SpellController SpellInstance = Instantiate(SpellPrefab, SpellParentSocket); SpellInstance.transform.localPosition = Vector3.zero; SpellInstance.transform.localRotation = Quaternion.identity; // Set owner to this gameObject so the Spell can alter projectile/damage logic accordingly SpellInstance.owner = gameObject; SpellInstance.sourcePrefab = SpellPrefab.gameObject; SpellInstance.ShowSpell(false); // Assign the first person layer to the Spell int layerIndex = Mathf.RoundToInt(Mathf.Log(FPSSpellLayer.value, 2)); // This function converts a layermask to a layer index foreach (Transform t in SpellInstance.gameObject.GetComponentsInChildren <Transform>(true)) { t.gameObject.layer = layerIndex; } return(SpellInstance); }