Beispiel #1
0
    public IObservable <Unit> Attack(Dir8 dir)
    {
        tweensInAttack = new List <Tween>();

        isAttacking        = true;
        currentAttackEnded = new Subject <Unit>();

        tweensInAttack.Add(DOVirtual.DelayedCall(1f, () =>
        {
            tweensInAttack.Add
            (
                rigidBody.DOMove(dir.ToVec2() * attackMoveDistance, 0.5f)
                .SetRelative()
                .SetEase(Ease.Linear)
            );
        }));
        tweensInAttack.Add(DOVirtual.DelayedCall(1.6f, () => attackCollider.enabled = true).ReactsToHeroEye());
        tweensInAttack.Add(DOVirtual.DelayedCall(2.3f, () => attackCollider.enabled = false).ReactsToHeroEye());
        tweensInAttack.Add(DOVirtual.DelayedCall(2.5f, () => currentAttackEnded.OnNext(Unit.Default)).ReactsToHeroEye());
        tweensInAttack.Add(DOVirtual.DelayedCall(3f, () => isAttacking = false).ReactsToHeroEye());

        return(currentAttackEnded);
    }
Beispiel #2
0
 public static float ToAngleDeg(this Dir8 dir) => Vector2.SignedAngle(Vector2.right, dir.ToVec2());