コード例 #1
0
    IEnumerator WaitForAction()
    {
        if (coroutinePosition < actions.Length)
        {
            switch (actions[coroutinePosition])
            {
            case Action.MoveWASD: {
                while (Player.PlayerInstance.GetComponent <Rigidbody>().velocity == Vector3.zero)
                {
                    yield return(null);
                }
                break;
            }

            case Action.StartBurningIronSteel: {
                while (!Player.PlayerIronSteel.IsBurning)
                {
                    yield return(null);
                }
                break;
            }

            case Action.SelectSteel: {
                while (!Keybinds.SelectAlternateDown())
                {
                    yield return(null);
                }
                break;
            }

            case Action.PushPull: {
                bool pulled = false;
                bool pushed = false;
                while (!pulled || !pushed)
                {
                    pulled = pulled || Keybinds.IronPulling();
                    pushed = pushed || Keybinds.SteelPushing();
                    yield return(null);
                }
                break;
            }

            case Action.Deselect: {
                bool select    = false;
                bool alternate = false;
                while (!select || !alternate)
                {
                    select    = select || (Keybinds.Negate() && Keybinds.Select());
                    alternate = alternate || (Keybinds.Negate() && Keybinds.SelectAlternate());
                    yield return(null);
                }
                break;
            }

            case Action.Help: {
                while (!HUD.HelpOverlayController.IsOpen)
                {
                    yield return(null);
                }
                // Close Message
                Close();
                break;
            }

            case Action.ChangeNumberOfTargets: {
                while (Player.PlayerIronSteel.PullTargets.Size == 1)
                {
                    yield return(null);
                }
                break;
            }

            case Action.ChangeBurnPercentage: {
                while (Player.PlayerIronSteel.IronBurnPercentageTarget > .99f && Player.PlayerIronSteel.SteelBurnPercentageTarget > .99f)
                {
                    yield return(null);
                }
                break;
            }

            case Action.StopBurningIronSteel: {
                while (Player.PlayerIronSteel.IsBurning)
                {
                    yield return(null);
                }
                Close();
                break;
            }

            case Action.CollectCoin: {
                while (Player.PlayerInstance.CoinHand.Pouch.Count == 0)
                {
                    yield return(null);
                }
                break;
            }

            case Action.ThrowCoin: {
                while (!Keybinds.WithdrawCoinDown())
                {
                    yield return(null);
                }
                break;
            }

            case Action.ThrowCoinDown: {
                while (!Keybinds.WithdrawCoinDown() || !Keybinds.Jump())
                {
                    yield return(null);
                }
                FlagsController.HelpOverlayFull = true;
                break;
            }

            case Action.SelectIron: {
                while (!Keybinds.SelectDown())
                {
                    yield return(null);
                }
                break;
            }

            case Action.BurnPewter: {
                while (!Player.PlayerPewter.IsSprinting)
                {
                    yield return(null);
                }
                break;
            }
            }

            // When one TriggerBeadPopup is entered, make sure no other TriggerBead listeners are still running to update the MessageOverlay later on.
            if (HUD.MessageOverlayController.CurrentPopup == this)
            {
                coroutinePosition++;
                HUD.MessageOverlayController.MessageText.text = GetText();
                HUD.MessageOverlayController.HeaderText.text  = GetHeader();
                if (coroutinePosition < HUD.MessageOverlayController.TriggerBeadMessages[section].Count - 2 || coroutinePosition < actions.Length)
                {
                    StartCoroutine(WaitForAction());
                    yield break;
                }
            }
        }
        // End of this bead's actions
        if (nextBead)
        {
            nextBead.transform.parent.gameObject.SetActive(true);
        }
    }
コード例 #2
0
    /*
     * Read inputs for selecting targets.
     * Update burn percentages.
     * Update blue lines pointing from player to metal.
     */
    private void LateUpdate()
    {
        if (!PauseMenu.IsPaused)
        {
            // Start and Stop Burning metals
            if (IsBurning)
            {
                // Stop burning
                if (Keybinds.StopBurning())
                {
                    StopBurning();
                    timeToStopBurning = 0;
                }
                else
                if (Keybinds.Negate())
                {
                    timeToStopBurning += Time.deltaTime;
                    if (Keybinds.Select() && Keybinds.SelectAlternate() && timeToStopBurning > timeToHoldDown)
                    {
                        //if (Keybinds.IronPulling() && Keybinds.SteelPushing() && timeToStopBurning > timeToHoldDown) {
                        StopBurning();
                        timeToStopBurning = 0;
                    }
                }
                else
                {
                    timeToStopBurning = 0;
                }
            }
            else
            {
                // Start burning
                if (!Keybinds.Negate())
                {
                    if (Keybinds.SelectDown())
                    {
                        StartBurning(true);
                    }
                    else if (Keybinds.SelectAlternateDown())
                    {
                        StartBurning(false);
                    }
                }
            }

            // Could have stopped burning above. Check if the Allomancer is still burning.
            if (IsBurning)
            {
                // Change Burn Percentage Targets, Number of Targets
                // Check scrollwheel for changing the max number of targets and burn percentage, or DPad if using gamepad
                float scrollValue = 0;
                if (SettingsMenu.settingsData.controlScheme == SettingsData.Gamepad)   // Gamepad
                {
                    scrollValue = Keybinds.DPadYAxis();
                    if (SettingsMenu.settingsData.pushControlStyle == 1)
                    {
                        ChangeTargetForceMagnitude(Keybinds.DPadXAxis());
                    }
                }
                else     // Mouse and keyboard
                {
                    if (Keybinds.Negate())
                    {
                        scrollValue = Keybinds.ScrollWheelAxis();
                    }
                    else
                    {
                        if (SettingsMenu.settingsData.pushControlStyle == 0)
                        {
                            ChangeBurnPercentageTarget(Keybinds.ScrollWheelAxis());
                        }
                        else
                        {
                            ChangeTargetForceMagnitude(Keybinds.ScrollWheelAxis());
                        }
                    }
                }
                if (scrollValue > 0)
                {
                    IncrementNumberOfTargets();
                }
                if (scrollValue < 0)
                {
                    DecrementNumberOfTargets();
                }

                // Assign Burn percentage targets based on the previously changed burn percentage/target magnitudes
                if (SettingsMenu.settingsData.pushControlStyle == 0)                     // Percentage
                {
                    if (SettingsMenu.settingsData.controlScheme == SettingsData.Gamepad) // Gamepad
                    {
                        SetPullPercentageTarget(Keybinds.RightBurnPercentage());
                        SetPushPercentageTarget(Keybinds.LeftBurnPercentage());
                    }
                }
                else     // Magnitude
                {
                    if (HasPullTarget || HasPushTarget)
                    {
                        //Debug.Log(player.LastMaximumNetForce);

                        float maxNetForce = (LastMaximumNetForce).magnitude;
                        SetPullPercentageTarget(forceMagnitudeTarget / maxNetForce);
                        SetPushPercentageTarget(forceMagnitudeTarget / maxNetForce);
                    }
                    else
                    {
                        SetPullPercentageTarget(0);
                        SetPushPercentageTarget(0);
                    }
                }

                LerpToBurnPercentages();
                UpdateBurnRateMeter();

                if (Player.CanControlPlayer)
                {
                    // Could have stopped burning above. Check if the Allomancer is still burning.
                    if (IsBurning)
                    {
                        // Swap pull- and push- targets
                        if (Keybinds.NegateDown() && timeToSwapBurning > Time.time)
                        {
                            // Double-tapped, Swap targets
                            PullTargets.SwapContents(PushTargets);
                            // If vacuously targeting, swap statuses of vacuous targets
                            SwapVacuousTargets();
                        }
                        else
                        {
                            if (Keybinds.NegateDown())
                            {
                                timeToSwapBurning = Time.time + timeDoubleTapWindow;
                            }
                        }

                        // Search for Metals

                        bool pulling = Keybinds.IronPulling() && HasIron;// && !(Player.CoinshotMode && Keybinds.SteelPushing()); // in coinshot mode, you cannot push and pull simultaneously
                        bool pushing = Keybinds.SteelPushing() && HasSteel;
                        // If you are trying to push and pull and only have pullTargets, only push. And vice versa
                        if (!HasPushTarget && HasPullTarget)
                        {
                            if (pulling)
                            {
                                pushing = false;
                            }
                        }
                        else
                        if (!HasPullTarget && HasPushTarget)
                        {
                            if (pushing)
                            {
                                pulling = false;
                            }
                        }
                        IronPulling  = pulling;
                        SteelPushing = pushing;

                        // Check input for target selection
                        bool selecting = (Keybinds.Select() || Keybinds.SelectAlternate()) && !Keybinds.Negate();

                        Magnetic target = SearchForMetals();

                        if (target != null)
                        {
                            // highlight the potential target you would select, if you targeted it
                            if (target != HighlightedTarget)
                            {
                                // Remove old target
                                if (HasHighlightedTarget)
                                {
                                    HighlightedTarget.RemoveTargetGlow();
                                }
                                target.AddTargetGlow();
                                HighlightedTarget = target;
                            }
                        }
                        else
                        {
                            // no target near center of screen; remove highlighted target
                            if (HasHighlightedTarget)
                            {
                                HighlightedTarget.RemoveTargetGlow();
                            }
                            HighlightedTarget = null;
                        }

                        // Add/Remove Targets

                        // If vacuously targeting (or should be),
                        if (VacuouslyPullTargeting || !HasPullTarget)
                        {
                            // If starting to pull/push again, replace that old vacuous target with the new target
                            if (Keybinds.PullDown())
                            {
                                SetVacuousTarget(target, iron);
                            }
                            // If releasing push/pull, remove vacuous target
                            if (!Keybinds.IronPulling())
                            {
                                SetVacuousTarget(null, iron);
                            }
                        }
                        // Repeat for steel
                        if (VacuouslyPushTargeting || !HasPushTarget)
                        {
                            if (Keybinds.PushDown())
                            {
                                SetVacuousTarget(target, steel);
                            }
                            if (!Keybinds.SteelPushing())
                            {
                                SetVacuousTarget(null, steel);
                            }
                        }

                        // Manual target selection
                        if (Keybinds.Select() || Keybinds.SelectAlternate())
                        {
                            // Select or Deselect pullTarget and/or pushTarget
                            if (Keybinds.Select() && HasIron)   // Selecting pull target
                            {
                                if (selecting)
                                {
                                    AddPullTarget(target);
                                }
                                else
                                {
                                    if (RemovePullTarget(target))  // If the player is hovering over a pullTarget, instantly remove that one. Keep it highlighted.
                                    {
                                        target.AddTargetGlow();
                                    }
                                    else if (Keybinds.SelectDown() && !RemovePullTarget(target))     // If the highlighted Magnetic is not a pullTarget, remove the oldest pullTarget instead
                                    {
                                        RemovePullTargetAt(0);
                                    }
                                }
                            }
                            if (Keybinds.SelectAlternate() && HasSteel)
                            {
                                if (selecting)
                                {
                                    AddPushTarget(target);
                                }
                                else
                                {
                                    if (RemovePushTarget(target))
                                    {
                                        target.AddTargetGlow();
                                    }
                                    else if (Keybinds.SelectAlternateDown() && !RemovePushTarget(target))
                                    {
                                        RemovePushTargetAt(0);
                                    }
                                }
                            }
                        }
                        RefreshHUD();
                    }
                }
                else     // If the player is not in control, but still burning metals, show blue lines to metals.
                {
                    if (IsBurning)
                    {
                        SearchForMetals(false);
                        LerpToBurnPercentages();
                        UpdateBurnRateMeter();
                        RefreshHUD();
                    }
                }
            }
        }
    }