protected IEnumerator AttackCoroutine() { currentAttack = GetRandomAttack(); if (currentAttack != null) { SendMessage("OnAttackStart", currentAttack); StartCoroutine("ImpulsesCoroutine", currentAttack.impulses); curAttackState = AttackState.Casting; yield return(new WaitForSeconds(currentAttack.castTime)); curAttackState = AttackState.Attacking; try { GameObject o = Instantiate(currentAttack.attackModel, Body.position, Visual.rotation, transform); AttackObject ao = o.GetComponent <AttackObject>(); ao.Initialize(new HitInfos(EB, currentAttack)); } catch { Debug.LogError("No Prefab Found !"); } currentAttack.lastAttackTime = Time.time; yield return(new WaitForSeconds(currentAttack.attackTime)); curAttackState = AttackState.Recover; yield return(new WaitForSeconds(currentAttack.recoverTime)); SendMessage("OnAttackStop", currentAttack); currentAttack = null; curAttackState = AttackState.Normal; } }
IEnumerator AttackCoroutine(PlayerAttackStats attack) { currentAttack = attack; attackState = e_AttackState.Casting; yield return(new WaitForSeconds(attack.CastTime)); attackState = e_AttackState.Attacking; try { GameObject o = Instantiate(attack.attackModel, Body.position, Visual.rotation, transform); AttackObject ao = o.GetComponent <AttackObject>(); ao.Initialize(new HitInfos(PB, attack), GetWeightByThreshold(attack.weight)); } catch { Debug.LogError("No Prefab Found !"); } SendMessage("OnAttackStart", attack); yield return(new WaitForSeconds(attack.AttackTime)); SendMessage("OnAttackStop", attack); attackState = e_AttackState.Recovering; yield return(new WaitForSeconds(attack.RecoverTime)); attackState = e_AttackState.None; currentAttack = null; }
protected void SetAttackPower(int power) { if (attackObject != null) { attackObject.Initialize(power); } }
protected override void Awake() { base.Awake(); oPos = Body.position; linkedVirgo = Body.Find("Virgo"); if (linkedVirgo != null) { posInVirgo = linkedVirgo.Find("PosInVirgo"); virgoAnimator = linkedVirgo.GetComponent <Animator>(); grabAttack = linkedVirgo.Find("Grab").GetComponent <AttackObject>(); grabAttack.Initialize(new HitInfos(EB, grabAttackStats)); } }