Esempio n. 1
0
    void Start()
    {
        anim        = GetComponent <Animator>();
        spike       = GetComponentInChildren <NonPlayerPushPullController>();
        spikeRb     = spike.GetComponent <Rigidbody>();
        spikeTarget = spike.transform.parent;
        SpikeSpline[] splines = GetComponentsInChildren <SpikeSpline>();
        splineDragging   = splines[0];
        splineReturnHome = splines[1];

        spike.LinesAreVisibleWhenNotBurning = true;

        facingPlayer      = false;
        tracingPlayer     = false;
        chasingPlayer     = false;
        spikingPlayer     = false;
        tracingPath       = false;
        releasingPlayer   = false;
        returningHome     = false;
        startTime         = 0;
        slerpTime         = 0;
        slerpTimeRotation = 0;
        progress          = 0;
    }
    private void FixedUpdate()
    {
        if (allomancerTop && !PauseMenu.IsPaused)
        {
            if (counter > 2)
            {
                Rigidbody[] rbs = GetComponentsInChildren <Rigidbody>();
                foreach (Rigidbody rb in rbs)
                {
                    rb.useGravity = true;
                }
                allomancerTop.SteelPushing = true;
                allomancerTop.SteelBurnPercentageTarget    = 1;
                allomancerBottom.SteelPushing              = true;
                allomancerBottom.SteelBurnPercentageTarget = 1;
            }
            else
            {
                counter += Time.deltaTime / Time.timeScale;
            }

            // Lower the timescale until the coin hits the ground
            if (coinTop.transform.position.y - groundHeight - .125f > .01f)
            {
                TimeController.CurrentTimeScale = .05f;
            }
            else
            {
                TimeController.CurrentTimeScale = SettingsMenu.settingsData.timeScale;
            }
            texts[texts.Length - 3].text = "Time scale: " + HUD.RoundStringToSigFigs(Time.timeScale);



            float threshold = 0;
            if (SettingsMenu.settingsData.anchoredBoost == 1)
            {
                threshold = 300;
            }
            else if (SettingsMenu.settingsData.anchoredBoost == 2)
            {
                threshold = 50;
            }
            else
            {
                threshold = 8000;
            }

            // Force

            if (allomancerTop.LastNetForceOnAllomancer.magnitude < .01f)
            {
                texts[0].text = "0";
                texts[1].text = "0";
            }
            else
            {
                if (allomancerTop.LastNetForceOnAllomancer.magnitude > threshold)
                {
                    texts[0].text = TextCodes.Red(HUD.ForceString(allomancerTop.LastNetForceOnAllomancer.magnitude, allomancerTop.Mass, 3));
                }
                else
                {
                    texts[0].text = HUD.ForceString(allomancerTop.LastNetForceOnAllomancer.magnitude, allomancerTop.Mass, 3);
                }
                texts[1].text = HUD.AllomanticSumString(allomancerTop.LastAllomanticForce, allomancerTop.LastAnchoredPushBoost, allomancerTop.Mass, 3);
            }

            if (allomancerBottom.LastNetForceOnAllomancer.magnitude < .01f)
            {
                texts[0 + right].text = "0";
                texts[1 + right].text = "0";
            }
            else
            {
                if (allomancerBottom.LastNetForceOnAllomancer.magnitude > threshold)
                {
                    texts[0 + right].text = TextCodes.Red(HUD.ForceString(allomancerBottom.LastNetForceOnAllomancer.magnitude, allomancerBottom.Mass, 3));
                }
                else
                {
                    texts[0 + right].text = HUD.ForceString(allomancerBottom.LastNetForceOnAllomancer.magnitude, allomancerBottom.Mass, 3);
                }
                texts[1 + right].text = HUD.AllomanticSumString(allomancerBottom.LastAllomanticForce, allomancerBottom.LastAnchoredPushBoost, allomancerBottom.Mass, 3);
            }


            // Velocity

            if (allomancerTop.GetComponent <Rigidbody>().velocity.magnitude < .01f)
            {
                texts[2].text = "0";
            }
            else
            {
                texts[2].text = HUD.RoundStringToSigFigs(allomancerTop.GetComponent <Rigidbody>().velocity.magnitude *Mathf.Sign(Vector3.Dot(allomancerTop.GetComponent <Rigidbody>().velocity, Vector3.up)), 2);
            }
            if (coinTop.GetComponent <Rigidbody>().velocity.magnitude < .01f)
            {
                texts[4].text = "0";
            }
            else
            {
                texts[4].text = HUD.RoundStringToSigFigs(coinTop.GetComponent <Rigidbody>().velocity.magnitude *Mathf.Sign(Vector3.Dot(coinTop.GetComponent <Rigidbody>().velocity, Vector3.up)), 2);
            }

            if (allomancerBottom.GetComponent <Rigidbody>().velocity.magnitude < .01f)
            {
                texts[2 + right].text = "0";
            }
            else
            {
                texts[2 + right].text = HUD.RoundStringToSigFigs(allomancerBottom.GetComponent <Rigidbody>().velocity.magnitude *Mathf.Sign(Vector3.Dot(allomancerBottom.GetComponent <Rigidbody>().velocity, Vector3.up)), 2);
            }
            if (coinBottom.GetComponent <Rigidbody>().velocity.magnitude < .01f)
            {
                texts[4 + right].text = "0";
            }
            else
            {
                texts[4 + right].text = HUD.RoundStringToSigFigs(coinBottom.GetComponent <Rigidbody>().velocity.magnitude *Mathf.Sign(Vector3.Dot(coinBottom.GetComponent <Rigidbody>().velocity, Vector3.up)), 2);
            }


            // Distance
            if (allomancerTop.transform.position.y - groundHeight - .5f < .01f)
            {
                texts[3].text = "0";
            }
            else
            {
                texts[3].text = HUD.RoundStringToSigFigs(allomancerTop.transform.position.y - groundHeight - .5f, 3);
            }
            if (coinTop.transform.position.y - groundHeight - .125f < .01f)
            {
                texts[5].text = "0";
            }
            else
            {
                texts[5].text = HUD.RoundStringToSigFigs(coinTop.transform.position.y - groundHeight - .125f, 3);
            }
            if (allomancerBottom.transform.position.y - groundHeight - .5f < .01f)
            {
                texts[3 + right].text = "0";
            }
            else
            {
                texts[3 + right].text = HUD.RoundStringToSigFigs(allomancerBottom.transform.position.y - groundHeight - .5f, 3);
            }
            if (coinBottom.transform.position.y - groundHeight - .125f < .01f)
            {
                texts[5 + right].text = "0";
            }
            else
            {
                texts[5 + right].text = HUD.RoundStringToSigFigs(coinBottom.transform.position.y - groundHeight - .125f, 3);
            }


            // EwV factor
            if (SettingsMenu.settingsData.anchoredBoost == 2)
            {
                texts[18].text = "e^-v/V Factor:";

                if (allomancerTop.LastAnchoredPushBoost.magnitude / allomancerTop.LastAllomanticForce.magnitude < .0001f)
                {
                    texts[19].text = "0%";
                }
                else
                {
                    string percent = HUD.RoundStringToSigFigs(100 * allomancerTop.LastAnchoredPushBoost.magnitude / allomancerTop.LastAllomanticForce.magnitude) + "%";

                    if (Vector3.Dot(allomancerTop.LastAnchoredPushBoost, allomancerTop.LastAllomanticForce) > 0)
                    {
                        percent = TextCodes.Blue("+" + percent);
                    }
                    else
                    {
                        if (allomancerTop.LastAnchoredPushBoost.magnitude / allomancerTop.LastAllomanticForce.magnitude > .5f)
                        {
                            percent = TextCodes.Red("-" + percent);
                        }
                        else
                        {
                            percent = ("-" + percent);
                        }
                    }
                    texts[19].text = percent;
                }

                texts[18 + right].text = "e^-v/V Factor:";

                if (allomancerBottom.LastAnchoredPushBoost.magnitude / allomancerBottom.LastAllomanticForce.magnitude < .0001f)
                {
                    texts[19 + right].text = "0%";
                }
                else
                {
                    string percent = HUD.RoundStringToSigFigs(100 * allomancerBottom.LastAnchoredPushBoost.magnitude / allomancerBottom.LastAllomanticForce.magnitude) + "%";

                    if (Vector3.Dot(allomancerBottom.LastAnchoredPushBoost, allomancerBottom.LastAllomanticForce) > 0)
                    {
                        percent = TextCodes.Blue("+" + percent);
                    }
                    else
                    {
                        if (allomancerBottom.LastAnchoredPushBoost.magnitude / allomancerBottom.LastAllomanticForce.magnitude > .5f)
                        {
                            percent = TextCodes.Red("-" + percent);
                        }
                        else
                        {
                            percent = ("-" + percent);
                        }
                    }
                    texts[19 + right].text = percent;
                }
            }
            else
            {
                texts[18].text         = "";
                texts[19].text         = "";
                texts[18 + right].text = "";
                texts[19 + right].text = "";
            }
        }
    }
    private void FixedUpdate()
    {
        if (allomancer && allomancer.HasPushTarget && !PauseMenu.IsPaused)
        {
            counter += Time.deltaTime;
            if (counter > .5f)
            {
                allomancer.SteelPushing = true;
                allomancer.SteelBurnPercentageTarget = 1;
                if (counter > 4 && counter < 6)
                {
                    texts[texts.Length - 5].text = "Wall: " + TextCodes.Gray("Unanchored");
                    texts[texts.Length - 6].text = "Coin: " + TextCodes.Blue("Partially Anchored");
                    coinWall.isKinematic         = false;
                }
                else if (counter > 6 && counter < 8)
                {
                    texts[texts.Length - 5].text = "Wall: Removed";
                    texts[texts.Length - 6].text = "Coin: " + TextCodes.Gray("Unanchored");
                    coinWall.gameObject.SetActive(false);
                }
                else if (counter > 8 && counter < 10)
                {
                    alloWall.gameObject.SetActive(false);
                    texts[texts.Length - 8].text = "Wall: Removed";
                }
                else if (counter > 10 && counter < 12 && !cleared)
                {
                    cleared = true;
                    coinWall.gameObject.SetActive(true);
                    coinWall.isKinematic             = true;
                    coinWall.transform.localPosition = new Vector3(0, 0, -4f);
                    coin.transform.localPosition     = new Vector3(0, 0, 3.35f);
                    coin.Clear();
                    texts[texts.Length - 5].text = "Wall: " + TextCodes.LightBlue("Anchored");
                }
            }


            float threshold = 0;
            if (SettingsMenu.settingsData.anchoredBoost == 1)
            {
                threshold = 300;
            }
            else if (SettingsMenu.settingsData.anchoredBoost == 2)
            {
                threshold = 50;
            }
            else
            {
                threshold = 8000;
            }

            if (allomancer.LastNetForceOnAllomancer.magnitude < .01f)
            {
                texts[3].text = "0";
                texts[9].text = "0";
            }
            else
            {
                if (allomancer.LastNetForceOnAllomancer.magnitude > threshold)
                {
                    texts[3].text = TextCodes.Red(HUD.ForceString(allomancer.LastNetForceOnAllomancer.magnitude, allomancer.Mass, 3));
                }
                else
                {
                    texts[3].text = HUD.ForceString(allomancer.LastNetForceOnAllomancer.magnitude, allomancer.Mass, 3);
                }
                texts[9].text = HUD.AllomanticSumString(allomancer.LastAllomanticForce, allomancer.LastAnchoredPushBoost, allomancer.Mass, 3);
            }

            if (allomancer.GetComponent <Rigidbody>().velocity.magnitude < .01f)
            {
                texts[4].text = "0";
                texts[texts.Length - 7].text = "Allomancer: " + TextCodes.LightBlue("Anchored");
            }
            else
            {
                texts[4].text = HUD.RoundStringToSigFigs(allomancer.GetComponent <Rigidbody>().velocity.magnitude, 2);
                texts[texts.Length - 7].text = "Allomancer: " + TextCodes.Gray("Unanchored");
            }
            if (coin.GetComponent <Rigidbody>().velocity.magnitude < .01f)
            {
                texts[5].text = "0";
                texts[texts.Length - 6].text = "Coin: " + TextCodes.LightBlue("Anchored");
            }
            else
            {
                if (counter < 2)
                {
                    texts[texts.Length - 6].text = "Coin: " + TextCodes.Gray("Unanchored");
                }
                texts[5].text = HUD.RoundStringToSigFigs(coin.GetComponent <Rigidbody>().velocity.magnitude, 2);
            }
            if (SettingsMenu.settingsData.anchoredBoost == 2)
            {
                texts[10].text = "e^-v/V Factor:";
                texts[11].text = "";
                texts[12].text = "";
                texts[16].text = "";
                texts[17].text = "";
                texts[18].text = "";

                string percent = HUD.RoundStringToSigFigs(100 * allomancer.LastAnchoredPushBoost.magnitude / allomancer.LastAllomanticForce.magnitude) + "%";

                if (Vector3.Dot(allomancer.LastAnchoredPushBoost, allomancer.LastAllomanticForce) > 0)
                {
                    percent = TextCodes.Blue("+" + percent);
                }
                else
                {
                    if (allomancer.LastAnchoredPushBoost.magnitude / allomancer.LastAllomanticForce.magnitude > .5f)
                    {
                        percent = TextCodes.Red("-" + percent);
                    }
                    else
                    {
                        percent = ("-" + percent);
                    }
                }
                texts[13].text = percent;
            }
            else if (SettingsMenu.settingsData.anchoredBoost == 3)
            {
                texts[10].text = "Allomancer ΔKE:";
                texts[11].text = "Coin ΔKE:";
                texts[12].text = "Total ΔKE:";
                texts[16].text = "J";
                texts[17].text = "J";
                texts[18].text = "J";


                float alloEnergy = .5f * allomancer.Mass * (allomancer.LastAllomancerVelocity - allomancer.GetComponent <Rigidbody>().velocity).sqrMagnitude / (Time.timeScale * Time.timeScale);
                float coinEnergy = .5f * coin.MagneticMass * (coin.LastVelocity - coin.GetComponent <Rigidbody>().velocity).sqrMagnitude / (Time.timeScale * Time.timeScale);
                if (alloEnergy < .001f)
                {
                    alloEnergy = 0;

                    texts[13].text = "0";
                    if (coinEnergy > .001f)
                    {
                        texts[14].text = TextCodes.Red(HUD.RoundStringToSigFigs(coinEnergy));
                    }
                    else
                    {
                        texts[14].text = "0";
                    }
                }
                else
                {
                    if (coinEnergy > .001f)
                    {
                        texts[13].text = HUD.RoundStringToSigFigs(alloEnergy);
                        texts[14].text = HUD.RoundStringToSigFigs(coinEnergy);
                    }
                    else
                    {
                        coinEnergy = 0;

                        texts[13].text = TextCodes.Red(HUD.RoundStringToSigFigs(alloEnergy));
                        texts[14].text = "0";
                    }
                }
                //Debug.Log(.5f * coinWall.GetComponent<Rigidbody>().mass * (wallLastVelocity - coinWall.GetComponent<Rigidbody>().velocity).sqrMagnitude / (Time.timeScale * Time.timeScale));
                //wallLastVelocity = coinWall.GetComponent<Rigidbody>().velocity;
                if (alloEnergy + coinEnergy < 99)
                {
                    texts[15].text = HUD.RoundStringToSigFigs(alloEnergy + coinEnergy);
                }
                else
                {
                    texts[15].text = TextCodes.Red(HUD.RoundStringToSigFigs(alloEnergy + coinEnergy));
                }
            }
        }
    }