Example #1
0
    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;
        }
    }
Example #2
0
    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;
    }
Example #3
0
 protected void SetAttackPower(int power)
 {
     if (attackObject != null)
     {
         attackObject.Initialize(power);
     }
 }
Example #4
0
    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));
        }
    }