Ejemplo n.º 1
0
    private IEnumerator _ChargeAttack(AttackAction attackAction)
    {
        if (_repelCirclePart.energy < ActivationEnergy)
        {
            attackAction.EndAttack(dontFade: true);
            yield break;
        }

        while (_chargeAmount < chargeMinLength || //At least charge to min
               (attackAction.inH != 0 && _ctrl.attackHorizontal == attackAction.inH ||
                attackAction.inV != 0 && _ctrl.attackVertical == attackAction.inV) && _chargeAmount < chargeMaxLength)
        {
            _dir += 2 * chargeMaxLength * Time.fixedDeltaTime *
                    new Vector2(_ctrl.attackHorizontal, _ctrl.attackVertical);
            var   right  = _repelCirclePart.transform.right;
            float rotAmt = Vector2.SignedAngle(attackAction.inH >= 0 ? right : -right, _dir);
            _repelCirclePart.transform.Rotate(Vector3.forward, rotAmt * Time.fixedDeltaTime * 10);
            _rb.gravityScale = 0;
            _rb.velocity    -= Time.fixedDeltaTime * 10 * _rb.velocity;
            _chargeAmount   += Time.fixedDeltaTime;
            yield return(Yields.WaitForFixedUpdate);
        }
        attackAction.state = AttackState.Attacking;
        attackAction.BeginAttacking();
    }
Ejemplo n.º 2
0
    private IEnumerator _SlowDown(AttackAction attackAction)
    {
        bool exploded = false;

        _rb.gravityScale = _initGravity;
        if (_repelCirclePart.touchingHittable)
        {
            if (_isparticleTrailNotNull)
            {
                var emissionModule = _repelCirclePart.particleTrail.emission;
                emissionModule.rateOverDistance = 0;
            }
            _repelCirclePart.StartCoroutine(_repelCirclePart._Explode(
                                                (int)(_chargeAmount * attackAction.attackDefinition.damage),
                                                _chargeAmount * attackAction.attackDefinition.knockback, _ctrl,
                                                weapon.holder.movement));
            exploded = true;
        }
        else
        {
            attackAction.EndAttack();
        }

        _chargeAmount = 0;
        float start = Time.time;

        while (Time.time < start + .6f)
        {
            _rb.velocity -= Time.fixedDeltaTime * 3 * _rb.velocity.Projected(_dir);
            yield return(Yields.WaitForFixedUpdate);
        }
        _rb.collisionDetectionMode = CollisionDetectionMode2D.Discrete;

        if (exploded)
        {
            yield return(new WaitWhile(() => _repelCirclePart.exploded));

            attackAction.EndAttack(dontFade: true);
        }
    }
Ejemplo n.º 3
0
    private IEnumerator _GroundedEndCheck(AttackAction attackAction)
    {
        yield return(new WaitWhile(() => attackAction.state == AttackState.WindingUp ||
                                   attackAction.state == AttackState.Attacking && !weapon.mvmt.grounded));

        if (alsoEndRestOfAttackWhenGrounded)
        {
            attackAction.EndAttack();
        }
        else
        {
            weapon.StopCoroutine(_attackDash);
            weapon.mvmt.rb.gravityScale = 1;
        }
    }
Ejemplo n.º 4
0
 /// <summary> Receives events from weapon animations. </summary>
 /// <param name="e"> The object sent from the animation </param>
 /// <param name="duration"> An optional duration that some events need </param>
 public void ReceiveAnimationEvent(AnimationEventObject e, float duration)
 {
     if (primaryAttack.state == AttackState.Ended)
     {
         return;
     }
     if (e == _animEventObjs.attackFadeIn && primaryAttack.state == AttackState.WindingUp)
     {
         FadeAttackIn(duration);
     }
     else if (e == _animEventObjs.attackAttackingStart && primaryAttack.state == AttackState.WindingUp)
     {
         primaryAttack.BeginAttacking();
     }
     else if (e == _animEventObjs.attackAttackingEnd && primaryAttack.state == AttackState.Attacking)
     {
         primaryAttack.BeginRecovering();
     }
     else if (e == _animEventObjs.attackFadeOut && primaryAttack.state == AttackState.Recovering)
     {
         primaryAttack.EndAttack(duration);
     }
 }