Esempio n. 1
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;
    }
Esempio n. 2
0
    public void InterruptAttack()
    {
        StopCoroutine("AttackCoroutine");
        StopCoroutine("ImpulsesCoroutine");

        attackState   = e_AttackState.None;
        currentAttack = null;
    }
Esempio n. 3
0
    void MutilateHandler()
    {
        if (currentAttack != null)
        {
            return;
        }

        if (C.MutilateDown)
        {
            //Start Mutilate
            mutilateStartTime = Time.time;
            attackState       = e_AttackState.Mutilating;
        }
        else if (mutilateStartTime != null)
        {
            if (C.MutilateHeld)
            {
                if (mutilateStartTime + mutilateCastTime > Time.time)
                {
                    //Mutilate progress
                    PostProcess.SetMutilatePP((Time.time - (float)mutilateStartTime) / mutilateCastTime);
                }
                else if (mutilateStartTime + mutilateCastTime + mutilateRecoverTime > Time.time)
                {
                    //Reset mutilate
                    if (attackState != e_AttackState.MutilateRecover)
                    {
                        if (PB.CurHealth > mutilateHealthCost)
                        {
                            PB.AddHealth(-mutilateHealthCost);
                            PB.AddBlood(mutilateMinBloodGain + mutilateBloodGain);
                        }
                        else
                        {
                            if (PB.CurHealth > 1)
                            {
                                PB.AddBlood(mutilateBloodGain * ((PB.CurHealth - 1) / mutilateHealthCost));
                                PB.AddHealth(-PB.CurHealth + 1);
                            }

                            PB.AddBlood(mutilateMinBloodGain);
                        }


                        PB.AddMadness(mutilateMadnessGain);

                        PostProcess.SetMutilatePP(0);
                        FX.SpawnHitFX(BodyRaycastOrigin.position + Visual.forward * BodyColl.radius, Visual.forward, transform);
                        attackState = e_AttackState.MutilateRecover;
                    }
                }
                else
                {
                    PostProcess.SetMutilatePP(0);
                    attackState       = e_AttackState.None;
                    mutilateStartTime = null;
                }
            }
            else if (attackState != e_AttackState.MutilateRecover || (float)mutilateStartTime + mutilateCastTime + mutilateRecoverTime <= Time.time)
            {
                PostProcess.SetMutilatePP(0);
                attackState       = e_AttackState.None;
                mutilateStartTime = null;
            }
        }
    }