Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by simone9725 · Mar 19, 2016 at 01:36 PM · playerprefsscore system

Unlock a level if score in the previous level is right

Well I have created a system that stores all the score but I would that net level is avaible olny if I reached the desired score in the previous one

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 public class GestioneLivelli : MonoBehaviour {
     private int score;
     public int PuntiNecessari;
     public int CurrentLevel;
     public Button Livello1;
     public Button Livello2;
     public Button Livello3;
     public Button Livello4;
     public Button Livello5;
     public Button Livello6;
     public Button Livello7;
     public Button Livello8;
     public Button Livello9;
     public Button Livello10;
     public Button Livello11;
     public Button Livello12;
     bool Lev1 = false;
     bool Lev2=false;
     bool Lev3=false;
     bool Lev4=false;
     bool Lev5 = false;
     bool Lev6=false;
     bool Lev7=false;
     bool Lev8=false;
     bool Lev9 = false;
     bool Lev10=false;
     bool Lev11=false;
     bool Lev12=false;
     bool completo1;
     bool completo2;
     bool completo3;
     bool completo4;
     bool completo5;
     bool completo6;
     bool completo7;
     bool completo8;
     bool completo9;
     bool completo10;
     bool completo11;
     bool completo12;
     public BossLaury Laura;
     public BossSara Sara;
     public BossZimZim Zimmy;
     // Use this for initialization
     void Start () {
         score =  PlayerPrefs.GetInt("bestScore");
         Lev1 = PlayerPrefs.GetInt("Lev1", 0) == 1;
         Lev2 = PlayerPrefs.GetInt("Lev2", 0) == 1;
         Lev3 = PlayerPrefs.GetInt("Lev3", 0) == 1;
         Lev4 = PlayerPrefs.GetInt("Lev4", 0) == 1;
         Lev5 = PlayerPrefs.GetInt("Lev5", 0) == 1;
         Lev6 = PlayerPrefs.GetInt("Lev6", 0) == 1;
         Lev7 = PlayerPrefs.GetInt("Lev7", 0) == 1;
         Lev8 = PlayerPrefs.GetInt("Lev8", 0) == 1;
         Lev9 = PlayerPrefs.GetInt("Lev9", 0) == 1;
         Lev10 = PlayerPrefs.GetInt("Lev10", 0) == 1;
         Lev11= PlayerPrefs.GetInt("Lev11", 0) == 1;
         Lev12 = PlayerPrefs.GetInt("Lev12", 0) == 1;
         bool completo1=false;
         bool completo2=false;
         bool completo3=false;
         bool completo4=false;
         bool completo5=false;
         bool completo6=false;
         bool completo7=false;
         bool completo8=false;
         bool completo9=false;
         bool completo10=false;
         bool completo11=false;
         bool completo12=false;
      
     }
     void Update () 
     {
         CheckLevels ();
     }
     // Update is called once per frame
     void CheckLevels () {
         // Have we enough cash to buy them?
         if (score >= 20000)
         {
             
             Livello1.enabled = true;
             Livello1.GetComponent<Image>().color = Color.white;
             Lev1=true;
 
         }else{
             Livello1.enabled=false;
             Livello1.GetComponent<Image>().color = Color.black;
             completo1 = false;
         }
         if (score >= 30000&&completo1==true)
         {
             
             Livello2.enabled = true;
             Livello2.GetComponent<Image>().color = Color.white;
             Lev2=true;
 
         }else{
             Livello2.enabled=false;
             Livello2.GetComponent<Image>().color = Color.black;
             completo2=false;
         }
         if (score >= 40000&&completo2)
         {
             Livello3.enabled = true;
             Livello3.GetComponent<Image>().color = Color.white;
             Lev3=true;
 
         }else{
             Livello3.enabled=false;
             Livello3.GetComponent<Image>().color = Color.black;
 
         }
         if (score >=50000&&completo3==true)
         {
             Livello4.enabled = true;
             Livello4.GetComponent<Image>().color = Color.white;
             Lev4=true;
         
         }
         else{
             Livello4.enabled=false;
             Livello4.GetComponent<Image>().color = Color.black;
 
 
         }
         if (score >= 60000)
         {
             Livello5.enabled = true;
             Livello5.GetComponent<Image>().color = Color.white;
             Lev5=true;
         }
         else{
             Livello5.enabled=false;
             Livello5.GetComponent<Image>().color = Color.black;
         }
         if (score >= 65000)
         {
             Livello6.enabled = true;
             Livello6.GetComponent<Image>().color = Color.white;
             Lev6=true;
         }
         else{
             Livello6.enabled=false;
             Livello6.GetComponent<Image>().color = Color.black;
         }
         if (score >= 70000)
         {
             Livello7.enabled = true;
             Livello7.GetComponent<Image>().color = Color.white;
             Lev7=true;
             //boss
         }
         else{
             Livello7.enabled=false;
             Livello7.GetComponent<Image>().color = Color.black;
         }
         if (score >= 75000)
         {
             Livello8.enabled = true;
             Livello8.GetComponent<Image>().color = Color.white;
             Lev8=true;
         }
         else{
             Livello8.enabled=false;
             Livello8.GetComponent<Image>().color = Color.black;
         }
         if (score >= 76000)
         {
             Livello9.enabled = true;
             Livello9.GetComponent<Image>().color = Color.white;
             Lev9=true;
         }
         else{
             Livello9.enabled=false;
             Livello9.GetComponent<Image>().color = Color.black;
         }
         if (score >= 77000)
         {
             Livello10.enabled = true;
             Livello10.GetComponent<Image>().color = Color.white;
             Lev10=true;
         }
         else{
             Livello10.enabled=false;
             Livello10.GetComponent<Image>().color = Color.black;
         }
         if (score >= 80000)
         {
             Livello11.enabled = true;
             Livello11.GetComponent<Image>().color = Color.white;
             Lev11=true;
             //boss
         }
         else{
             Livello11.enabled=false;
             Livello11.GetComponent<Image>().color = Color.black;
         }
         if (score >= 90000)
         {
             Livello12.enabled = true;
             Livello12.GetComponent<Image>().color = Color.white;
             Lev11=true;
         }
         else{
             Livello12.enabled=false;
             Livello12.GetComponent<Image>().color = Color.black;
         }
     }
     void OnDestroy()
     {
         PlayerPrefs.SetInt ("Lev1", Lev1 ? 1 : 0);
         PlayerPrefs.SetInt ("Lev2", Lev2 ? 1 : 0);
         PlayerPrefs.SetInt ("Lev3", Lev3 ? 1 : 0);
         PlayerPrefs.SetInt ("Lev4", Lev4 ? 1 : 0);
         PlayerPrefs.SetInt ("Lev5", Lev5 ? 1 : 0);
         PlayerPrefs.SetInt ("Lev6", Lev6 ? 1 : 0);
         PlayerPrefs.SetInt ("Lev7", Lev7 ? 1 : 0);
         PlayerPrefs.SetInt ("Lev8", Lev8 ? 1 : 0);
         PlayerPrefs.SetInt ("Lev9", Lev9 ? 1 : 0);
         PlayerPrefs.SetInt ("Lev10", Lev10 ? 1 : 0);
         PlayerPrefs.SetInt ("Lev11", Lev11 ? 1 : 0);
         PlayerPrefs.SetInt ("Lev12", Lev12 ? 1 : 0);
         PlayerPrefs.Save();
    }
 }

Pls I don't want destroy hours of work could someone help on this

Ps:If there is a problem and it isn't approved could you say where is my mistake)

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image simone9725 · Mar 19, 2016 at 04:20 PM 0
Share

Pls any ideas?

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

52 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Hi Everyone i need to get the high score but i get last score player achieve it ,Hi Everyone i want to get The High Score of level but i get last Score Can you help me 1 Answer

Saving highscore for each levels 0 Answers

In the next scene tell player there score out of total using player prefab before next level 1 Answer

Highscore and PlayerPrefs unity C# 1 Answer

In the next scene show the score using player prefab before next level 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges