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 Shivang_Purwar · Aug 23, 2018 at 08:23 PM · 3dprogramminglogic

How to make a 3D bowling scoreboard for each 10 frames?

Hey, I am making a 3D bowling game but i don't know how to add each score for each frames. Foreg.. in 1st frame 9 or 7 pins fall i got 9 or 7 points for that then again if 1 or 3 pins fall then 10 will be total score for that frame. So on... up to 10 frames how can i add all 10 frames score. I want some logical help on this. Currently when my single pin falls i got 1 point.

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 eses · Aug 24, 2018 at 07:49 AM 0
Share

@Shivang_Purwar - You'd better post an image of your intended behavior and design, no use for people start googling for some bowling related stuff - it will be guesswork.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by kalen_08 · Aug 26, 2018 at 11:52 PM

Well you need to track each throw and also each frame.

  • I would use a List of type Vector3int as this accomplishes both.

  • Then keep track of how many throws they are on. (1, 2, 3), this will need to be reset after every frame.

  • Convert these then into vector3ints and add to the list.

  • At the end have a method that would total up everything. in fact I would create a custom struct just for all of this.

Here is a solution. Use it or not, this is as far as I go in this. Figure out whatever else you need, it should be easy to build on this given the properties I put in.

 public class Score : MonoBehaviour 
 {
     int frame = 0;
     int attempt = 0;
     int[] frameData = new int[3];
     Frame currentFrame;
     List<Frame> gameSummary = new List<Frame> ();
 
 
     public void AddScore (int pins)
     {
         frameData[attempt] = pins;
 
         NextAttempt();
     }
 
     void NextAttempt ()
     {
         currentFrame = new Frame (frameData[0], frameData[1], frameData[2]);
 
         attempt++;
 
         bool finished = attempt == 3 || currentFrame.IsStrike || currentFrame.IsSpare;
 
         if (finished)
         {
             gameSummary.Add(currentFrame);
             attempt = 0;
             frame++;
         }
     }
 
     int GetTotalScore ()
     {
         int score = 0;
         foreach (var frame in gameSummary) {
             score += frame.Total;
         }
         return score;
     }
 
     struct Frame
     {
         int a;
         int b;
         int c;
 
         Frame (int a, int b, int c)
         {
             this.a = a;
             this.b = b;
             this.c = c;
         }
 
         public int Total { get { return a + b + c;}}
 
         public bool IsStrike { get { return a == 10;}}
         public bool IsSpare { get { return a + b == 10;}}
     }
 }



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.

Follow this Question

Answers Answers and Comments

171 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

Related Questions

Detect all object are touching as one cluster 0 Answers

Using coroutine and texture array to randomly associate textures? 1 Answer

Hiding part of mesh 0 Answers

how to make a succession(n+1,5n,etc) that work in if statement? 0 Answers

Having An Issue Getting Level Lock System To Function Properly 0 Answers


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