• 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 g5fighter · Jun 25, 2019 at 03:10 PM · script.score systemscoreboard

How can I make a scoretable in which players with the same puntuatio have the same rate?

I am doing a game similar to Mario Party, but I have a problem and I don't know how to solve it. The problem is how can I make a scoretable in which players with the same puntuatio have the same rate? It´s a four local multiplayer game, of course.

For example: Player1 score 60 Player 2 score 30 Player 3 score 20 Player 4 score 30

I want to have for player 1 in first 100points player 2 and 4 in third position with 50 points player 3 in fourth postion with 25 points

Here is my sample code

     private List<HighscoreEntry> highScoreEntryList;//scoretable list
 
     public void AddToList()
     {
 //add score
         highScoreEntryList = new List<HighscoreEntry>() {
             new HighscoreEntry{score = player1score, name = "Player1" },
             new HighscoreEntry{score = player2score, name = "Player2" },
             new HighscoreEntry{score = player3score, name = "Player3" },
             new HighscoreEntry{score = player4score, name = "Player4" }
         };
 //order puntuations
         for (int i = 0; i < highScoreEntryList.Count; i++) {
             for (int j = i + 1; j < highScoreEntryList.Count; j++)
             {
                 if (highScoreEntryList[j].score > highScoreEntryList[i].score)
                 {
                     HighscoreEntry tmp = highScoreEntryList[i];
                     highScoreEntryList[i] = highScoreEntryList[j];
                     highScoreEntryList[j] = tmp;
                 }
             }
         }
 
     }
 
     private class HighscoreEntry //class for the list
     {
         public int score;
         public string name;
     }
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by g5fighter · Jun 25, 2019 at 11:07 PM

I tried to do it with this code:

         highScoreEntryList = new List<HighscoreEntry>() {
             new HighscoreEntry{score = player1score, name = "Player1" },
             new HighscoreEntry{score = player2score, name = "Player2" },
             new HighscoreEntry{score = player3score, name = "Player3" },
             new HighscoreEntry{score = player4score, name = "Player4" }
         };
 
         //order the puntuation
         for (int i = 0; i < highScoreEntryList.Count; i++)
         {
             for (int j = i + 1; j < highScoreEntryList.Count; j++)
             {
                 if (highScoreEntryList[j].score > highScoreEntryList[i].score)
                 {
                     HighscoreEntry tmp = highScoreEntryList[i];
                     highScoreEntryList[i] = highScoreEntryList[j];
                     highScoreEntryList[j] = tmp;
                 }
             }
         }
 
         for (int i = 0,tmp = 0; i < highScoreEntryList.Count; i++)
         {
             for (int j = i + 1; highScoreEntryList[i].score == highScoreEntryList[j].score; j++)
             {
                 tmp++;
                 iqual = true;
             }
             if (iqual == true)
             {
                 for (int j = i; j <= tmp; j++)
                 {
                     if (tmp==1)
                     {
                         highScoreEntryList[j].score = 75;
                     }
                     else if (tmp == 2)
                     {
                         highScoreEntryList[j].score = 50;
                     }
                     else if (tmp == 3)
                     {
                         highScoreEntryList[j].score = 25;
                     }
                     iqual = false;
                 }
             } else if (iqual == false)
             {
                 if (i==0)
                 {
                     highScoreEntryList[0].score = 125;
                 }else if (i == 1)
                 {
                     highScoreEntryList[1].score = 75;
                 }
                 else if (i == 2)
                 {
                     highScoreEntryList[2].score = 50;
                 }
                 else if (i == 3)
                 {
                     highScoreEntryList[3].score = 25;
                 }
 
                 tmp++;
             }
             i = tmp-1;
 
         }
Comment
Add comment · Share
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

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

193 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 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 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 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

Problem with counting score in 3D game 1 Answer

I need a leaderboard 0 Answers

Why isn't my C# code sending updates to my text scoreboard? 1 Answer

Problem with ScoreBoard in Ping Pong game 1 Answer

How do you make a scoreboard for a simple match three game?? 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