Beispiel #1
0
    public void SetHitstun(DoubleTime hitstun)
    {
        switch (knockbackRecipient)
        {
        case KnockbackRecipient.Player:
        {
            print("Player Hitstun set: " + hitstun.cancelTime + " , " + hitstun.defaultTime);
            _fighter.SetHitstunTimer(hitstun);
        }
        break;

        case KnockbackRecipient.AI:
        {
            _ai.SetHitstunTimer(hitstun);
        }
        break;
        }
    }
Beispiel #2
0
    IEnumerator MultiCast(Attack attack)
    {
        for (int i = 0; i < attack.multiFireCount; i++)
        {
            if (!recentlyAttacked)
            {
                if (attack.coolDown.defaultTime == 0 && attack.coolDown.cancelTime == 0)
                {
                    movementFreezeLength = new DoubleTime(attack.animationCancelLength, attack.animationLength);
                }
                else
                {
                    //movementFreezeLength = new DoubleTime();
                    movementFreezeLength = attack.coolDown;
                }



                if (attack.attackType == Attack.AttackType.Special)
                {
                    if (attack.attackPath == Attack.AttackPath.Homing)
                    {
                        //attack.offset.x = FindObjectOfType<Vortex>().transform.position.x;
                    }
                }

                StartAttack(attack);

                yield return(new WaitForSeconds(attack.multiFireRate));
            }
            else
            {
                StopCoroutine(multicastCoroutine);
            }
        }
        StopCoroutine(multicastCoroutine);
    }
Beispiel #3
0
    public void StartAttack(Attack attack)
    {
        print("Cast projectile + " + attack.name);
        GameObject   attackObject = new GameObject("Projectile");
        AttackScript spell        = attackObject.AddComponent <AttackScript>();

        if (attack.attackType == Attack.AttackType.Special && attack.attackPath == Attack.AttackPath.Homing)
        {
        }

        anim.SetInteger("element", (int)attack.element);
        anim.SetTrigger("cast");

        cc.FreezeVelocity();
        // Cast animation goes here... probably
        anim.SetFloat("speed", 0);

        if (attack.attackPath != Attack.AttackPath.CrashDown || attack.attackPath != Attack.AttackPath.Meteor)
        {
            spell.flipped = !cc.m_FacingRight;
        }

        spell.attack       = attack;
        spell.usingFighter = this;

        if (attack.chargeType == Attack.ChargeType.Instant)
        {
            if (attack.hasSpecialChargeFunction)
            {
                if (attack.attackPath == Attack.AttackPath.Homing)
                {
                    attackIsSpecialHeld = true;
                    specialHold         = spell;
                }
            }
        }



        if (attack.attackPath == Attack.AttackPath.Meteor || attack.attackPath == Attack.AttackPath.CrashDown)
        {
            spell.origin = meteorSpellCastPoint.position;

            if (attack.attackType == Attack.AttackType.MultipleBlast)
            {
                if (attack.attackPath == Attack.AttackPath.Meteor)
                {
                    spell.origin.x = meteorSpellCastPoint.position.x + Random.Range(0, attack.xPositionalDisplacement) + (spell.attack.offset.x * spell.direction);
                }
                else if (attack.attackPath == Attack.AttackPath.CrashDown)
                {
                    spell.origin.x = meteorSpellCastPoint.position.x + Random.Range(0, attack.xPositionalDisplacement);
                }
            }
        }
        else if (attack.attackPath == Attack.AttackPath.Homing)
        {
            spell.origin = backSpellCastPoint.position;
        }
        else
        {
            spell.origin = spellCastPoint.position;
        }

        spell.direction = cc.m_FacingRight ? 1 : -1;
        spell.user      = gameObject.name;
        spell.origin   += new Vector2(attack.offset.x * spell.direction, attack.offset.y);

        spell.transform.position = spell.origin;

        if (attack.simultaneousAttack != null)
        {
            if (attack.attackType == Attack.AttackType.Melee)
            {
                StartMeleeAttack(attack.simultaneousAttack);
            }
            else
            {
                StartAttack(attack.simultaneousAttack);
            }
        }

        if (attack.coolDown.defaultTime == 0 && attack.coolDown.cancelTime == 0)
        {
            movementFreezeLength = new DoubleTime(attack.animationCancelLength, attack.animationLength);
        }
        else
        {
            //movementFreezeLength = new DoubleTime();
            movementFreezeLength = attack.coolDown;
        }
        //movementFreezeLength = new DoubleTime(attack.attackLength, attack.attackLength);

        //print("xDisp: " + attack.xDisplacement + comboCount);

        if (attack.xDisplacement + comboCount != 0)
        {
            //rb.AddForce(new Vector2(rb.velocity.x + attack.xDisplacement * spell.direction, rb.velocity.y), ForceMode2D.Impulse);
            if (attack.attackType != Attack.AttackType.MultipleBlast)
            {
                rb.velocity = new Vector2(Mathf.Abs(rb.velocity.x + attack.xDisplacement + comboCount) * -spell.direction, rb.velocity.y);
            }
            else
            {
                if (attack.attackPath == Attack.AttackPath.Straight)
                {
                    //rb.velocity = new Vector2(rb.velocity.x)
                }
            }

            //print("force applied");
        }
    }
Beispiel #4
0
 public void SetHitstunTimer(DoubleTime recovery)
 {
     recoveryTimer = recovery.defaultTime;
     recoveryTime  = recovery.cancelTime;
 }