private void OnSuccesAttack(Attack_Result result, Damagetype dmg_type, EntityBase ent) // recibe el resultado del ataque y suma uno al contador. Si llega al ncesario, activa el skill
    {
        if (isActive)
        {
            return;
        }

        if (result == Attack_Result.sucessful)
        {
            cantDeGolpesExitosos++;
        }

        if (cantDeGolpesExitosos == hitsToActivate)
        {
            cantDeGolpesExitosos = 0;
            isActive             = true;
            //_characterAttack.currentWeapon.ModifyAttackrange(CalculateRangeAttackModifier(percentRangeModifier));
            _characterAttack.currentWeapon.BeginOverrideRange(NO_OVERRIDE_VALUE, RangeMultiplier);
            _characterAttack.currentWeapon.BeginOverrideAngle(NO_OVERRIDE_VALUE, AngleMultiplier);
            aura.position = charHead.transform.position + Vector3.up * .25f;
            aura.gameObject.SetActive(true);

            charHead.GetCharacterAttack().OnAttack += SetGhostSword;
        }
    }
Example #2
0
    public override Attack_Result TakeDamage(int dmg, Vector3 attackDir, Damagetype dmgtype)
    {
        if (InDash())
        {
            return(Attack_Result.inmune);
        }

        if (charBlock.IsParry(rot.position, attackDir, rot.forward))
        {
            Debug.LogWarning("PARRY perfect");
            PerfectParry();
            Main.instance.GetTimeManager().DoSlowMotion(timeScale, slowDuration);
            customCam.DoFastZoom(10);
            return(Attack_Result.parried);
        }
        else if (charBlock.IsBlock(rot.position, attackDir, rot.forward))
        {
            blockParticle.Play();
            charanim.BlockSomething();
            charBlock.SetBlockCharges(-1);
            lifesystem.Hit(dmg / 2);
            return(Attack_Result.blocked);
        }
        else
        {
            hitParticle.Play();
            lifesystem.Hit(dmg);
            Vector3 dir = (transform.position - attackDir).normalized;
            rb.AddForce(new Vector3(dir.x, 0, dir.z) * dmg * onHitRecall, ForceMode.Force);
            customCam.BeginShakeCamera();
            Main.instance.Vibrate();
            return(Attack_Result.sucessful);
        }
    }
Example #3
0
    public override Attack_Result TakeDamage(int dmg, Vector3 dir, Damagetype dmgtype)
    {
        greenblood.Play();
        bool death = lifesystem.Hit(dmg);

        return(death ? Attack_Result.death : Attack_Result.sucessful);
    }
Example #4
0
    public override Attack_Result TakeDamage(int dmg, Vector3 attack_pos, Damagetype damagetype, EntityBase owner_entity)
    {
        if (sm.Current.Name == "Dead")
        {
            return(Attack_Result.inmune);
        }

        if (entityTarget != owner_entity)
        {
            if (sm.Current.Name == "Idle" || sm.Current.Name == "Persuit")
            {
                if (!entityTarget)
                {
                    SetTarget(owner_entity);
                }

                attacking = false;
                //if (entityTarget == null) throw new System.Exception("entity target es null");//esto rompe cuando vengo desde el Damage in Room
                director.RemoveToAttack(this, entityTarget);
                SetTarget(owner_entity);
                director.AddToAttack(this, entityTarget);
            }
        }

        return(TakeDamage(dmg, attack_pos, damagetype));
    }
Example #5
0
    public override void Attack(Transform pos, float damage, Damagetype dmg_type)
    {
        var entities = Physics.OverlapSphere(pos.position, range)
                       .Where(x => x.GetComponent <EntityBase>())
                       .Where(x => x.GetComponent <EntityBase>() != Main.instance.GetChar())
                       .ToList();


        for (int i = 0; i < entities.Count; i++)
        {
            Debug.Log(entities[i].gameObject.name);

            Vector3 dir   = entities[i].transform.position - pos.position;
            float   angle = Vector3.Angle(pos.forward, dir);

            var current = entities[i].GetComponent <EntityBase>();

            if (dir.magnitude <= range && angle < base.angle)
            {
                var attackResult = current.TakeDamage(
                    (int)damage,
                    Main.instance.GetChar().transform.position,
                    Damagetype.parriable,
                    _head);

                AttackResult?.Invoke(attackResult, dmg_type, current);
            }
        }
    }
    public override Attack_Result TakeDamage(int dmg, Vector3 attack_pos, Damagetype dmgtype)
    {
        SetTarget(entityTarget);

        if (cooldown || Invinsible || sm.Current.Name == "Die")
        {
            return(Attack_Result.inmune);
        }

        // Debug.Log("damagetype" + dmgtype.ToString()); ;

        Vector3 aux = this.transform.position - attack_pos;

        aux.Normalize();
        rb = GetComponent <Rigidbody>();
        if (dmgtype == Damagetype.explosion)
        {
            Debug.Log(rb);
            rb.AddForce(aux * explosionForce, ForceMode.Impulse);
        }
        else
        {
            rb.AddForce(aux * forceRecall, ForceMode.Impulse);
        }

        sm.SendInput(DummyEnemyInputs.TAKE_DAMAGE);

        greenblood.Play();

        cooldown = true;

        bool death = lifesystem.Hit(dmg);

        return(death ? Attack_Result.death : Attack_Result.sucessful);
    }
Example #7
0
    public override Attack_Result TakeDamage(int dmg, Vector3 attack_pos, Damagetype dmgtype)
    {
        SetTarget(entityTarget);

        if (cooldown || Invinsible || sm.Current.Name == "Dead")
        {
            return(Attack_Result.inmune);
        }

        Debug.Log("damagetype" + dmgtype.ToString());

        Vector3 aux = (this.transform.position - attack_pos).normalized;

        if (dmgtype == Damagetype.explosion)
        {
            rb.AddForce(aux * explosionForce, ForceMode.Impulse);
        }
        else
        {
            rb.AddForce(aux * forceRecall, ForceMode.Impulse);
        }

        sm.SendInput(JabaliInputs.TAKE_DMG);

        greenblood.Play();
        cooldown = true;

        bool death = lifesystem.Hit(dmg);

        return(death ? Attack_Result.death : Attack_Result.sucessful);
    }
    void CALLBACK_DealDamage(Attack_Result attack_result, Damagetype damage_type, EntityBase entityToDamage)
    {
        callback_ReceiveEntity();
        FirstAttackReady(false);//esto tambien es de obligacion... tampoco debería estar aca

        if (entityToDamage.GetComponent <DestructibleBase>())
        {
            BreakObject.Invoke();
            return;
        }

        switch (attack_result)
        {
        case Attack_Result.sucessful:

            if (damage_type == Damagetype.heavy)
            {
                DealSuccesfullHeavy();
            }
            else
            {
                DealSuccesfullNormal();
            }

            break;

        case Attack_Result.blocked:
            break;

        case Attack_Result.parried:
            break;

        case Attack_Result.reflexed:
            break;

        case Attack_Result.inmune:
            break;

        case Attack_Result.death:

            if (damage_type == Damagetype.heavy)
            {
                KillSuccesfullHeavy();
            }
            else
            {
                KillSuccesfullNormal();
            }

            break;
        }
    }
    public override void Attack(Transform pos, float damage, Damagetype dmg_type)
    {
        var entities = Physics.OverlapSphere(pos.position, range)
                       .Where(x => x.GetComponent <EntityBase>())
                       .Where(x => x.GetComponent <EntityBase>() != Main.instance.GetChar())
                       .ToList();


        foreach (var v in entities)
        {
            Debug.Log("entity " + v.gameObject);
        }

        for (int i = 0; i < entities.Count; i++)
        {
            Debug.Log(entities[i].gameObject.name);

            Vector3 dir   = entities[i].transform.position - pos.position;
            float   angle = Vector3.Angle(pos.forward, dir);

            var current = entities[i].GetComponent <EntityBase>();

            if (dir.magnitude <= range && angle < base.angle)
            {
                var attackResult = current.TakeDamage(
                    (int)damage,
                    Main.instance.GetChar().transform.position,
                    Damagetype.parriable,
                    _head);

                AttackResult?.Invoke(attackResult, dmg_type, current);

                if (attackResult == Attack_Result.sucessful)
                {
                    oneshotSucsesfull = true;
                }

                Debug.Log("Attack result: " + attackResult.ToString());
            }
        }

        if (oneshotSucsesfull)
        {
            oneshotSucsesfull = false;
            Main.instance.Vibrate();
            Main.instance.CameraShake();
        }
    }
Example #10
0
    IEnumerator DoT(float duration, float timePerTick, int tickDamage, Damagetype damagetype, Action onFinishCallback)
    {
        float countTime     = 0;
        float tickTimeCount = 0;

        while (countTime <= duration)
        {
            countTime += Time.fixedDeltaTime;

            tickTimeCount += Time.fixedDeltaTime;

            if (tickTimeCount >= timePerTick)
            {
                Hit(tickDamage);
                tickTimeCount = 0;
            }

            yield return(null);
        }

        onFinishCallback.Invoke();
    }
Example #11
0
 public abstract void Attack(Transform pos, float damage, Damagetype dmg_type);
Example #12
0
 public virtual Attack_Result TakeDamage(int dmg, Vector3 attackDir, Damagetype damagetype, EntityBase owner_entity)
 {
     return(TakeDamage(dmg, attackDir, damagetype));
 }
Example #13
0
 public abstract Attack_Result TakeDamage(int dmg, Vector3 attackDir, Damagetype damagetype);
Example #14
0
 public void DoTSystem(float duration, float timePerTick, int tickDamage, Damagetype damagetype, Action onFinishCallback)
 {
     StartCoroutine(DoT(duration, timePerTick, tickDamage, damagetype, onFinishCallback));
 }
 public override Attack_Result TakeDamage(int dmg, Vector3 attack_pos, Damagetype damagetype)
 {
     throw new System.NotImplementedException();
 }