Example #1
0
    public void ChangeIceFire()
    {
        ice_fire = (ice_fire == Constants.SpellMode.Fire) ?
                   Constants.SpellMode.Ice : Constants.SpellMode.Fire;


        if (ice_fire == Constants.SpellMode.Fire)
        {
            GameObject toFireSEPrefab = Resources.Load(Constants.AudioFileDir + "Swap2FireSE") as GameObject;
            GameObject toFireSE       = GameObject.Instantiate(toFireSEPrefab)   as GameObject;
        }
        else
        {
            GameObject toIceSEPrefab = Resources.Load(Constants.AudioFileDir + "Swap2IceSE") as GameObject;
            GameObject toIceSE       = GameObject.Instantiate(toIceSEPrefab)     as GameObject;
        }

        // HACK change special attack as well
        if (SpecialSpellID == SpellDB.AttackID.meteor && ice_fire == Constants.SpellMode.Ice)
        {
            SpecialSpellID = SpellDB.AttackID.iceBurst;
        }
        if (SpecialSpellID == SpellDB.AttackID.iceBurst && ice_fire == Constants.SpellMode.Fire)
        {
            SpecialSpellID = SpellDB.AttackID.meteor;
        }


        Debug.Log("[Spell] spell id now is : " + spellID);
    }
    public IEnumerator Attack(SpellDB.AttackID id, Vector3 to = default(Vector3))
    {
        wizardAnimator.SetBool("Attack", true);
        yield return(new WaitForSeconds(1.0f));

        magicSpell = magicPool[(int)id];

        StartCoroutine(magicSpell.castMagic(gameObject, to));

        Debug.Log("Attack using " + SpellDB.attackIDnames[(int)id]);


        wizardAnimator.SetBool("Attack", false);
    }
Example #3
0
    // Update is called once per frame
    public void onSpellTrigger(Vector3 spellPos, SpellDB.AttackID spellId)
    {
        // if fireball, deduct health
        Debug.Log("[Spell] " + SpellDB.attackIDnames[(int)spellId] + "   on spell trigger");
        if (spellId == SpellDB.AttackID.iceball || spellId == SpellDB.AttackID.bigiceball ||
            spellId == SpellDB.AttackID.iceBurst)
        {
            playerData.DamageHP(SpellDB.GetSpellDamage(spellId));
            StartCoroutine(GetFrozen());
        }

        if (spellId == SpellDB.AttackID.meteor)
        {
            playerData.DamageHP(SpellDB.GetSpellDamage(spellId));
        }

        if (spellId == SpellDB.AttackID.fireball || spellId == SpellDB.AttackID.bigfireball)
        {
            Debug.Log("[Spell] fireball is hit on " + this.name);
            Vector3 direction    = transform.position - spellPos;
            Vector3 appliedForce = direction.normalized * Globals.FORCE_MULTIPLIER;
            StartCoroutine(addTimeDecayForce(GetComponent <Rigidbody>(), appliedForce, 1f));
//			StartCoroutine(addDistanceDecayForce(GetComponent<Rigidbody>(), appliedForce, 16f, spellPos));

            playerData.DamageHP(SpellDB.GetSpellDamage(spellId));
            Debug.Log("[Spell] hit " + GetComponent <Collider>().name);
        }

//		if (spellID == 1){ // iceball id is 1
//			playerData.DamageHP(SpellDB.SPELL_DAMAGE[spellID]);
//			StartCoroutine(GetFrozen());
//		}


//		if (spellID == 2){ // iceburst id is 2
//			playerData.DamageHP(SpellDB.SPELL_DAMAGE[spellID]);
//			StartCoroutine(GetFrozen());
//		}

//		if (spellID == 3) { // meteor
//			playerData.DamageHP(SpellDB.SPELL_DAMAGE[spellID]);
//		}
    }
Example #4
0
    private IEnumerator AttackByPosition(SpellDB.AttackID id, Vector3 to = default(Vector3))
    {
//		id = SpellDB.AttackID.iceBurst;
        magicSpell = magicPool[(int)id];
        PlayerData pD = GetComponent <PlayerData>();

        if (pD.DecreaseMana(Constants.FIREBALL_MANA_COST))           // TODO Mana cost is constant now
        {
            wizardAnimator.SetBool("isCasting", true);
            yield return(new WaitForSeconds(Constants.MIN_CAST_COOL_DOWN));

            StartCoroutine(magicSpell.castMagic(gameObject, to));

            Debug.Log("[Spell] Attack using " + SpellDB.attackIDnames [(int)id]);

            wizardAnimator.SetBool("isCasting", false);
        }
        else
        {
            Debug.Log("[Spell] not enough mana!");
        }
        yield return(new WaitForSeconds(0.5f));
    }
Example #5
0
 public void AttackByDiretion(SpellDB.AttackID id, Vector3 diretion,
                              float distance = Constants.DEFAULT_ATTACK_RADIUS)
 {
     StartCoroutine(AttackByPosition(id, gameObject.transform.position + distance * diretion.normalized));
 }
Example #6
0
 public void AttackToPosition(SpellDB.AttackID id, Vector3 to = default(Vector3))
 {
     StartCoroutine(AttackByPosition(id, to));
 }