Exemple #1
0
	IEnumerator _HitTarget(UnitTB target, AttackInstance attInstance){
		//HitResult hitResult=null;
		
		//apply the attackInfo to the target, get the hit result info in return
		if(target!=null){
			attInstance=target.ApplyHitEffect(attInstance);
		}
		
		yield return new WaitForSeconds(0.1f);
		actionQueued-=1;
		if(actionQueued<=0){
			actionQueued=0;
			
			if(attInstance!=null){
				//~ if(!hitResult.counterAttack){
					if(attInstance.type!=_AttackType.Melee_Counter && attInstance.type!=_AttackType.Range_Counter){
						//if the attack is not counter attack, complete the action using delay based on if the target is destroyed
						if(attInstance.destroyed) StartCoroutine(ActionComplete(attInstance.destroyEffectDuration));
						else if(!attInstance.counterAttacking){
							//complete action if target is not counterAttacking
							//otherwise waiting for counter attack to complete, CounterAttackComplete will be called
							StartCoroutine(ActionComplete(0.25f));
						}
					}
					//if the attack is counter attack, tell the attacker that the counter attack has been completed
					else target.CounterAttackComplete(attInstance);
				//~ }
			}
			else{
				StartCoroutine(ActionComplete(0.25f));
			}
		}
	}