Beispiel #1
0
    private void Start()
    {
        FrontCheckOffset = this.transform.position - frontCheck.transform.position;
        BackCheckOffset  = this.transform.position - BackCheck.transform.position;
        //  PlayerPrefs.DeleteAll();
        if (PlayerPrefs.GetFloat("BaseSpeed") == 0.0f)
        {
            PlayerPrefs.SetFloat("BaseSpeed", 25f);
            BaseSpeedtxt.text = "25";
        }
        else
        {
            BaseSpeed         = PlayerPrefs.GetFloat("BaseSpeed");
            BaseSpeedtxt.text = BaseSpeed.ToString();
        }


        if (PlayerPrefs.GetFloat("TargetSpeed") == 0.0f)
        {
            PlayerPrefs.SetFloat("TargetSpeed", 50f);
            TargetSpeedTxt.text = "50";
        }
        else
        {
            TargetSpeed         = PlayerPrefs.GetFloat("TargetSpeed");
            TargetSpeedTxt.text = TargetSpeed.ToString();
        }

        if (PlayerPrefs.GetFloat("MaxRunForce") == 0.0f)
        {
            PlayerPrefs.SetFloat("MaxRunForce", 100f);
            MaxRunForceTxt.text = "100";
        }
        else
        {
            MaxRunForce         = PlayerPrefs.GetFloat("MaxRunForce");
            MaxRunForceTxt.text = MaxRunForce.ToString();
        }


        if (PlayerPrefs.GetFloat("m_JumpForce") == 0.0f)
        {
            PlayerPrefs.SetFloat("m_JumpForce", 25f);
            GetComponent <CharacterController2D>().m_JumpForce         = 25f;
            GetComponent <CharacterController2D>().m_JumpForceTxt.text = "25";
        }
        else
        {
            GetComponent <CharacterController2D>().m_JumpForce         = PlayerPrefs.GetFloat("m_JumpForce");
            GetComponent <CharacterController2D>().m_JumpForceTxt.text = GetComponent <CharacterController2D>().m_JumpForce.ToString();
        }


        if (PlayerPrefs.GetFloat("playerGravityScale") == 0.0f)
        {
            PlayerPrefs.SetFloat("playerGravityScale", 5f);
            GetComponent <CharacterController2D>().playerGravityScaleTxt.text = "5";
            GetComponent <Rigidbody2D>().gravityScale = 5f;
        }
        else
        {
            GetComponent <CharacterController2D>().playerGravityScale         = PlayerPrefs.GetFloat("playerGravityScale");
            GetComponent <CharacterController2D>().playerGravityScaleTxt.text = GetComponent <CharacterController2D>().playerGravityScale.ToString();
            GetComponent <Rigidbody2D>().gravityScale = GetComponent <CharacterController2D>().playerGravityScale;
        }


        if (PlayerPrefs.GetFloat("terminalVelocity") == 0.0f)
        {
            PlayerPrefs.SetFloat("terminalVelocity", -100f);
            GetComponent <CharacterController2D>().terminalVelocityTxt.text = "-100";
        }
        else
        {
            GetComponent <CharacterController2D>().terminalVelocity         = PlayerPrefs.GetFloat("terminalVelocity");
            GetComponent <CharacterController2D>().terminalVelocityTxt.text = GetComponent <CharacterController2D>().terminalVelocity.ToString();
        }

        if (PlayerPrefs.GetFloat("m_WallJumpForce") == 0.0f)
        {
            PlayerPrefs.SetFloat("m_WallJumpForce", -50);
            GetComponent <CharacterController2D>().m_WallJumpForceTxt.text = "-50";
        }
        else
        {
            GetComponent <CharacterController2D>().m_WallJumpForce         = PlayerPrefs.GetFloat("m_WallJumpForce");
            GetComponent <CharacterController2D>().m_WallJumpForceTxt.text = GetComponent <CharacterController2D>().m_WallJumpForce.ToString();
        }

        if (PlayerPrefs.GetFloat("walljumpAmplitudeLeft") == 0.0f)
        {
            PlayerPrefs.SetFloat("walljumpAmplitudeLeft", 3);
            walljumpAmplitudeLeftTxt.text = "3";
            walljumpAmplitudeLeft         = 3;
        }
        else
        {
            walljumpAmplitudeLeft         = PlayerPrefs.GetFloat("walljumpAmplitudeLeft");
            walljumpAmplitudeLeftTxt.text = walljumpAmplitudeLeft.ToString();
        }

        if (PlayerPrefs.GetFloat("walljumpAmplitudeRight") == 0.0f)
        {
            PlayerPrefs.SetFloat("walljumpAmplitudeRight", 40);
            walljumpAmplitudeRightTxt.text = "40";
            walljumpAmplitudeRight         = 40;
        }
        else
        {
            walljumpAmplitudeRight         = PlayerPrefs.GetFloat("walljumpAmplitudeRight");
            walljumpAmplitudeRightTxt.text = walljumpAmplitudeRight.ToString();
        }

        if (PlayerPrefs.GetFloat("walljumpForceLeft") == 0.0f)
        {
            PlayerPrefs.SetFloat("walljumpForceLeft", 12.5f);
            walljumpForceLeftTxt.text = "12.5";
            walljumpForceLeft         = 12.5f;
        }
        else
        {
            walljumpForceLeft         = PlayerPrefs.GetFloat("walljumpForceLeft");
            walljumpForceLeftTxt.text = walljumpForceLeft.ToString();
        }

        if (PlayerPrefs.GetFloat("walljumpForceRight") == 0.0f)
        {
            PlayerPrefs.SetFloat("walljumpForceRight", 40);
            walljumpForceRightTxt.text = "40";
        }
        else
        {
            walljumpForceRight         = PlayerPrefs.GetFloat("walljumpForceRight");
            walljumpForceRightTxt.text = walljumpForceRight.ToString();
        }


        if (PlayerPrefs.GetFloat("WallSlideGravity") == 0.0f)
        {
            PlayerPrefs.SetFloat("WallSlideGravity", 10f);

            WallSlideGravityTxt.text = "10f";
            //  UnityEngine.SceneManagement.SceneManager.LoadScene(0);
        }
        else
        {
            WallSlideGravity         = PlayerPrefs.GetFloat("WallSlideGravity");
            WallSlideGravityTxt.text = WallSlideGravity.ToString();
        }
    }
Beispiel #2
0
    private void Start()
    {
        FrontCheckOffset = this.transform.position - frontCheck.transform.position;
        BackCheckOffset  = this.transform.position - BackCheck.transform.position;
        //PlayerPrefs.DeleteAll();
        if (PlayerPrefs.GetFloat("BaseSpeed") == 0.0f)
        {
            PlayerPrefs.SetFloat("BaseSpeed", 30f);
            BaseSpeedtxt.text     = "30";
            controldata.BaseSpeed = 30;
        }
        else
        {
            BaseSpeed             = PlayerPrefs.GetFloat("BaseSpeed");
            BaseSpeedtxt.text     = BaseSpeed.ToString();
            controldata.BaseSpeed = BaseSpeed;
        }


        if (PlayerPrefs.GetFloat("TargetSpeed") == 0.0f)
        {
            PlayerPrefs.SetFloat("TargetSpeed", 60f);
            TargetSpeedTxt.text     = "60";
            controldata.TargetSpeed = 60;
        }
        else
        {
            TargetSpeed             = PlayerPrefs.GetFloat("TargetSpeed");
            TargetSpeedTxt.text     = TargetSpeed.ToString();
            controldata.TargetSpeed = TargetSpeed;
        }

        if (PlayerPrefs.GetFloat("MaxRunForce") == 0.0f)
        {
            PlayerPrefs.SetFloat("MaxRunForce", 100f);
            MaxRunForceTxt.text     = "100";
            controldata.MaxRunForce = 100;
        }
        else
        {
            MaxRunForce             = PlayerPrefs.GetFloat("MaxRunForce");
            MaxRunForceTxt.text     = MaxRunForce.ToString();
            controldata.MaxRunForce = MaxRunForce;
        }


        if (PlayerPrefs.GetFloat("m_JumpForce") == 0.0f)
        {
            PlayerPrefs.SetFloat("m_JumpForce", 25f);
            GetComponent <cc>().m_JumpForce         = 25f;
            GetComponent <cc>().m_JumpForceTxt.text = "25";
            controldata.m_JumpForce = 25;
        }
        else
        {
            GetComponent <cc>().m_JumpForce         = PlayerPrefs.GetFloat("m_JumpForce");
            GetComponent <cc>().m_JumpForceTxt.text = GetComponent <cc>().m_JumpForce.ToString();
            controldata.m_JumpForce = GetComponent <cc>().m_JumpForce;
        }


        if (PlayerPrefs.GetFloat("playerGravityScale") == 0.0f)
        {
            PlayerPrefs.SetFloat("playerGravityScale", 5f);
            GetComponent <cc>().playerGravityScaleTxt.text = "5";
            GetComponent <Rigidbody2D>().gravityScale      = 5f;
            controldata.playerGravityScale = 5f;
        }
        else
        {
            GetComponent <cc>().playerGravityScale         = PlayerPrefs.GetFloat("playerGravityScale");
            GetComponent <cc>().playerGravityScaleTxt.text = GetComponent <cc>().playerGravityScale.ToString();
            GetComponent <Rigidbody2D>().gravityScale      = GetComponent <cc>().playerGravityScale;
            controldata.playerGravityScale = GetComponent <cc>().playerGravityScale;
        }


        if (PlayerPrefs.GetFloat("terminalVelocity") == 0.0f)
        {
            PlayerPrefs.SetFloat("terminalVelocity", -100f);
            GetComponent <cc>().terminalVelocityTxt.text = "-100";
            controldata.terminalVelocity = -100;
        }
        else
        {
            GetComponent <cc>().terminalVelocity         = PlayerPrefs.GetFloat("terminalVelocity");
            GetComponent <cc>().terminalVelocityTxt.text = GetComponent <cc>().terminalVelocity.ToString();
            controldata.terminalVelocity = GetComponent <cc>().terminalVelocity;
        }

        if (PlayerPrefs.GetFloat("walljumpAmplitudeLeft") == 0.0f)
        {
            PlayerPrefs.SetFloat("walljumpAmplitudeLeft", 3);
            walljumpAmplitudeLeftTxt.text     = "3";
            walljumpAmplitudeLeft             = 3;
            controldata.walljumpAmplitudeLeft = 3;
        }
        else
        {
            walljumpAmplitudeLeft             = PlayerPrefs.GetFloat("walljumpAmplitudeLeft");
            walljumpAmplitudeLeftTxt.text     = walljumpAmplitudeLeft.ToString();
            controldata.walljumpAmplitudeLeft = walljumpAmplitudeLeft;
        }

        if (PlayerPrefs.GetFloat("walljumpForceLeft") == 0.0f)
        {
            PlayerPrefs.SetFloat("walljumpForceLeft", 12.5f);
            walljumpForceLeftTxt.text     = "12.5";
            walljumpForceLeft             = 12.5f;
            controldata.walljumpForceLeft = walljumpForceLeft;
        }
        else
        {
            walljumpForceLeft             = PlayerPrefs.GetFloat("walljumpForceLeft");
            walljumpForceLeftTxt.text     = walljumpForceLeft.ToString();
            controldata.walljumpForceLeft = walljumpForceLeft;
        }
        if (PlayerPrefs.GetFloat("WallSlideGravity") == 0.0f)
        {
            PlayerPrefs.SetFloat("WallSlideGravity", 12f);

            WallSlideGravityTxt.text     = "12";
            controldata.WallSlideGravity = 12f;
            //  UnityEngine.SceneManagement.SceneManager.LoadScene(0);
        }
        else
        {
            WallSlideGravity             = PlayerPrefs.GetFloat("WallSlideGravity");
            WallSlideGravityTxt.text     = WallSlideGravity.ToString();
            controldata.WallSlideGravity = WallSlideGravity;
        }
    }