コード例 #1
0
 protected override IEnumerator TickUntilDone()
 {
     yield return(CoroutineComposer.MakeParallel(this,
                                                 DelayedBolt(0, 1),
                                                 DelayedBolt(.1f, -2),
                                                 DelayedBolt(.2f, 2),
                                                 DelayedBolt(.3f, -1),
                                                 DelayedBolt(.4f, 0)
                                                 ));
 }
コード例 #2
0
    protected IEnumerator MoveCrew(Vector3 from, Vector3 to)
    {
        var effects = Game.Instance.effects;

        yield return(CoroutineComposer.MakeParallel(
                         this,
                         CoroutineComposer.MakeDelayed(0, effects.Create <EffectSpark>("Spark").Setup(from, to, 1).Run()),
                         CoroutineComposer.MakeDelayed(0.25f, effects.Create <EffectSpark>("Spark").Setup(from, to, 1).Run()),
                         CoroutineComposer.MakeDelayed(0.5f, effects.Create <EffectSpark>("Spark").Setup(from, to, 1).Run())
                         ));
    }
コード例 #3
0
    private void OnActivateTorpedo()
    {
        Vector3 torpedoEmit      = visuals.torpedoEmit.position;
        Vector3 torpedoReceive   = opponent.visuals.weaponReceiveHull.position;
        var     torpedoAnimation = Game.Instance.effects.Create <EffectTorpedo>("Torpedo").Setup(torpedoEmit, torpedoReceive).Run();

        bool evaded = false;

        if (opponent.AbilityEvade.IsActive)
        {
            float attackerRoll  = Stats.RollAttack();
            float defenderRoll  = opponent.Stats.RollDefense();
            float defenderBonus = opponent.Status.engines / (float)VesselStatus.MaxSystemStatus;
            evaded = (attackerRoll <= (defenderRoll + defenderBonus));
        }

        if (evaded)
        {
            owner.EnqueueAnimation(CoroutineComposer.MakeParallel(
                                       owner,
                                       torpedoAnimation,
                                       Game.Instance.effects.Create <EffectEvade>("Evade").Setup(opponent.visuals).Run()
                                       ));

            Debug.LogFormat("{0} firing evaded torpedo", name);
        }
        else
        {
            owner.EnqueueAnimation(torpedoAnimation);

            int damage = GetSystemDependentRollEffect(
                Stats.RollAttack(),
                Status.weapons,
                balance.torpedoDamageMin,
                balance.torpedoDamageMax);

            Debug.LogFormat("{0} firing torpedo with {1} damage", name, damage);

            // damage applied to health
            opponent.Status.ApplyHullDamage(damage, true);
        }

        // whether we evaded or not, evade ability deactivates
        if (opponent.AbilityEvade.IsActive)
        {
            opponent.AbilityEvade.Deactivate();
        }

        // consume ammo
        --Status.ammo;

        FinishTurn();
    }
コード例 #4
0
 protected override IEnumerator TickUntilDone()
 {
     for (int i = 0; i < 3; ++i)
     {
         Game.Instance.audioManager.Play("scan");
         yield return(CoroutineComposer.MakeParallel(this,
                                                     DelayedWave(0, 8),
                                                     DelayedWave(.05f, 0),
                                                     DelayedWave(.1f, -8)
                                                     ));
     }
 }
コード例 #5
0
    protected override IEnumerator TickUntilDone()
    {
        List <IEnumerator> sparks = new List <IEnumerator>();

        for (int i = 0; i < sparkCount; ++i)
        {
            sparks.Add(DelayedSpark(Random.value));
        }

        sparks.Add(CoroutineComposer.MakeDelayed(.2f, CoroutineComposer.MakeAction(() => Game.Instance.audioManager.Play("repair"))));
        sparks.Add(CoroutineComposer.MakeDelayed(.6f, CoroutineComposer.MakeAction(() => Game.Instance.audioManager.Play("repair"))));

        yield return(CoroutineComposer.MakeParallel(this, sparks.ToArray()));
    }
コード例 #6
0
    protected override IEnumerator TickUntilDone()
    {
        yield return(base.TickUntilDone());

        Destroy(bolt.gameObject);

        IEnumerator[] sparks = new IEnumerator[sparkCount];
        for (int i = 0; i < sparkCount; ++i)
        {
            Vector3 movement = Vector3.Scale(Random.onUnitSphere, new Vector3(1, 1, 0)).normalized *sparkRange;
            Vector3 origin   = sparksOrigin;
            Vector3 target   = sparksOrigin + movement;
            sparks[i] = Game.Instance.effects.Create <EffectSpark>("Spark").Setup(origin, target).Run();
        }

        yield return(CoroutineComposer.MakeParallel(this, sparks));
    }
コード例 #7
0
    protected override IEnumerator TickUntilDone()
    {
        yield return(base.TickUntilDone());

        Destroy(torpedo.gameObject);

        IEnumerator[] sparks = new IEnumerator[sparkCount];
        for (int i = 0; i < sparkCount; ++i)
        {
            Vector3 movement = (Vector3)Random.insideUnitCircle * sparkRange;
            Vector3 origin   = torpedoTarget;
            Vector3 target   = torpedoTarget + movement;
            sparks[i] = Game.Instance.effects.Create <EffectSpark>("Spark").Setup(origin, target, .5f).Run();
        }

        Game.Instance.audioManager.Play("torpedo_impact");
        yield return(CoroutineComposer.MakeParallel(this, sparks));
    }
コード例 #8
0
    public void OnVesselEndTurn(VesselEncounter vessel)
    {
        Debug.Assert(turnState == TurnState.Deciding);

        // disable input
        pageEncounter.IsInputEnabled = false;

        // enqueue health bar animations
        EnqueueAnimation(CoroutineComposer.MakeParallel(
                             this,
                             pageEncounter.healthBarPlayer.AnimateFill(owner.playerStatus.GetHealthPercentage(), 1),
                             pageEncounter.healthBarOpponent.AnimateFill(opponentStatus.GetHealthPercentage(), 1)
                             ));

        // luck roll to prevent player death
        if (playerEncounter.Status.health <= 0)
        {
            float luckRoll = playerEncounter.Stats.RollLuck();
            Debug.Log($"Anti-death luck roll: {luckRoll}");
            if (luckRoll > 0.9f)
            {
                // repair
                playerEncounter.Status.Repair(true);

                // repair and health bar animations
                EnqueueAnimation(CoroutineComposer.MakeParallel(this,
                                                                Game.Instance.effects.Create <EffectRepair>("Repair").Setup(pageEncounter.playerVisuals.transform.position, pageEncounter.playerVisuals.hull.sprite.rect).Run(),
                                                                pageEncounter.healthBarPlayer.AnimateFill(owner.playerStatus.GetHealthPercentage(), 1)
                                                                ));
            }
        }

        // enqueue end of turn
        pendingCoroutines.Add(CoroutineComposer.MakeAction(OnFinishAnimating));

        // run coroutines
        turnState = TurnState.Animating;
        StartCoroutine(CoroutineComposer.MakeSequence(pendingCoroutines.ToArray()));
    }