void SpawnSpellAttack()
 {
     SpellAttack.SetActive(true);
     if (gameObject.CompareTag(Tags.ENEMY_TAG))
     {
         enemy_Movement.enabled = false;
     }
 }
    IEnumerator StopSpellAttack()
    {
        yield return(new WaitForSeconds(5f));

        SpellAttack.SetActive(false);
        if (gameObject.CompareTag(Tags.ENEMY_TAG))
        {
            enemy_Movement.enabled = true;
        }
    }
Example #3
0
	void Update () {
		if (isFull () && !timerPause) {
			Step ();
			if (isFull () && !timerPause) {
				AttackStack = new SpellAttack (0, 5, person, null);
				RandomSlowpoke = Random.Range (0, Slowpoke);
				endTime = Time.time + RandomSlowpoke + Cooldown;
			}
		}
	}
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Q))
     {
         DoCast();
     }
     if (Input.GetKeyDown(KeyCode.Space))
     {
         DoAvoid();
     }
     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         StopAllCoroutines();
         Destroy(GetComponent <DamageAvoidance>());
         dmgAvoidBehavior = gameObject.AddComponent <Reduction>();
     }
     if (Input.GetKeyDown(KeyCode.Alpha2))
     {
         StopAllCoroutines();
         Destroy(GetComponent <DamageAvoidance>());
         dmgAvoidBehavior = gameObject.AddComponent <Dodge>();
     }
     if (Input.GetKeyDown(KeyCode.Alpha3))
     {
         StopAllCoroutines();
         Destroy(GetComponent <DamageAvoidance>());
         dmgAvoidBehavior = gameObject.AddComponent <NoDmgAvoid>();
     }
     if (Input.GetKeyDown(KeyCode.Alpha4))
     {
         Destroy(GetComponent <SpellAttack>());
         spellAttackbehavior = gameObject.AddComponent <Firebolt>();
     }
     if (Input.GetKeyDown(KeyCode.Alpha5))
     {
         Destroy(GetComponent <SpellAttack>());
         spellAttackbehavior = gameObject.AddComponent <Icespear>();
     }
     if (Input.GetKeyDown(KeyCode.Alpha6))
     {
         Destroy(GetComponent <SpellAttack>());
         spellAttackbehavior = gameObject.AddComponent <RockThrow>();
     }
     if (Input.GetKeyDown(KeyCode.Alpha7))
     {
         Destroy(GetComponent <SpellAttack>());
         spellAttackbehavior = gameObject.AddComponent <NoSpellAttack>();
     }
     if (Input.GetKeyDown(KeyCode.R))
     {
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     }
 }
    public void CastSpell(SpellResult spellResult)
    {
        SpellData   spellData   = spellHandler.GetSpellData(spellResult.Index);
        GameObject  spell       = Instantiate(spellData.Spell, magicCircle.transform.position, magicCircle.transform.rotation);
        SpellAttack spellAttack = spell.GetComponent <SpellAttack>();

        spellAttack.coverage = spellResult.Coverage;

        spellAttack.SetBattleManager(battleManager, experienceManager);

        cooldownShower.SetUpCoolDown(spellData.Cooldown);
        //Other option: Say: good, lame, awful etc
        SuccessCastSpellWithCoverage?.Invoke(spellResult.Coverage);
        SuccessCastSpellDelegateEvent?.Invoke();

        magicCircleInput.Reset();
        magicCircle.SetActive(false);

        castEffectHandler.CastSpellEffect(spellData.ElementType);
    }
	IEnumerator startAttack( SpellAttack attack ){
		Person.Progress.pause ();
		Enemy.pauseTimer ();

		Bounds EnemyBounds;

		if (attack._target == Person) {
			EnemyAnimator.SetBool ("isAttack", true);
			EnemyBounds = Person.GetComponent<SpriteRenderer> ().bounds;
			Person._attrs.Base ["hp_lost"] += attack._damage;
			Person.updateBars ();
			PersonAnimator.SetBool ("isAttacked", true);
		} else {
			PersonAnimator.SetBool ("isPrepare", true);
			if (attack._mana == 0) {
				PersonAnimator.SetBool ("isPhysics", true);
			} else {
				PersonAnimator.SetBool ("isMagick", true);
			}

			Enemy.Step ();
			EnemyBounds = Enemy.GetComponent<SpriteRenderer> ().bounds;
			Enemy._attrs.Base["hp_lost"] -= attack._damage;
			if ( attack._buff != null )
				Enemy.addBuff (attack._buff);
			EnemyAnimator.SetBool ("isKick", true);
		}


		float minX = EnemyBounds.max.x - EnemyBounds.size.x;
		float maxX = EnemyBounds.max.x;
		float y = EnemyBounds.extents.y;

		yield return new WaitForSeconds (2f);

		PersonAnimator.SetBool ("isAttacked", false);
		EnemyAnimator.SetBool ("isKick", false);

		GameObject label = Instantiate ( DamageLabel, new Vector3 (UnityEngine.Random.Range (minX, maxX), y, -0.1f), Quaternion.identity) as GameObject;
		label.GetComponent<TextMesh> ().text = "-" + attack._damage.ToString ();
		attack._target.transform.FindChild ("Fire").gameObject.SetActive (true);
		var color = attack._target.GetComponent<SpriteRenderer> ().color;
		attack._target.GetComponent<SpriteRenderer> ().color = Color.red;

		yield return new WaitForSeconds (1f);
		attack._target.transform.FindChild ("Fire").gameObject.SetActive (false);
		attack._target.GetComponent<SpriteRenderer> ().color = color;

		Destroy (label);

		yield return new WaitForSeconds (1f);

		PersonAnimator.SetBool ("isPhysics", false);
		PersonAnimator.SetBool ("isMagick", false);
		PersonAnimator.SetBool ("isPrepare", false);

		EnemyAnimator.SetBool ("isAttack", false);
		EnemyAnimator.SetBool ("isMagick", false);

		currentCoroutine = null;
		
		Person.Progress.play ();
		Enemy.continueTimer ();
	}
Example #7
0
	public void damageSpell ( SpellAttack attack ){
		if (Attrs ["mp"] >= attack._mana) {
			_attrs.Base ["mp_lost"] += attack._mana;
			AttackStack = attack;
		}
	}