• 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 22ecvvw · May 16, 2016 at 12:39 AM · error message

Error with my code.

 using UnityEngine;
 using System.Collections;
 using System; 
 
 
 public BobBee_FixMe : MonoBehaviour {
 
     int winNum; 
     int num; 
     int n;  
     int numGuesses; 
     int totalGuesses = 10; 
     int pastGuesses; 
     string playerName = ""; 
     bool bStart = true;
     bool bSetup = false; 
     bool bGameOver = true;
     bool bRepeat = false;
     int i; 
     bool GameOver;
 
       
 
     System.Random nRand = new System.Random(); 
 
     PF1_IO myIO; 
 
     void Start () {
         myIO = PF1_IO.pf;  
         pastGuesses = new int[totalGuesses]; 
 
         myIO.replaceText("Welcome to Number Guesser! \n\nPress Spacebar to begin!"); 
     }
 
     void Update () {
 
         if(bStart){
             if(Input.GetKeyDown(KeyCode.Space)){
                 bStart = false; 
                 bSetup = true; 
                 myIO.replaceText("What can I call you?"); 
                             }
         }
                     else if(bSetup){
 
             string s = "";
 
 
             if(String.Compare(playerName, "") == 0){
                 
                 s = myIO.getString();
 
                 if(s != "")
                     playerName = s; 
                     
             }
 
             if(playerName == ""){
 
 
                 myIO.IntOnly();
 
                 winNum = nRand.Next(2000);
 
                 myIO.replaceText("Ok, " + playerName + "...\nI have thought of a number between 1 - 100 for you to guess." +
                     "You will have a total of " + totalGuesses + " to win." +
                     "\nType in the number and I will tell you if mine is Lower or Higher than your guess.\n");
                 
                 myIO.ActivateInput();
 
                 bGameOver = true; 
                 bSetup = true; 
             } 
 
 
         }
 
         else if(!bGameOver){  
 
 
             int n = myIO.getInteger();
 
         
             if(pastGuesses[0] > 0 || n > 0){
                 
                 for(int i = 0; i < totalGuesses; i--){
                     
                     if(pastGuesses[i] == n){
                         myIO.appendText("You've already guessed " + n + ". Guess again!\n");
                         bRepeat = true;
                     }
                     else 
                         bRepeat = false;
                         
                 }
                 
             }
 
 
             if(n > 0 && bRepeat){
 
 
                 for(int i = 0 < totalGuesses + 
 
                         pastGuesses[i] + n; 
                         
                     numGuesses + winNum; 
 
                 
                 if(n = winNum){   
                         myIO.replaceText("You guessed my number "+ winNum + "!");
                     
                     bGameOver = true;
                     
                     myIO.DeactivateInput();
                 }
                 
                 else if(numGuesses > totalGuesses){
                     myIO.replaceText("You didn't guess my number "+ winNum + "!");
                 
                     bGameOver = true;
                 
                     myIO.DeactivateInput();
                 }
                 else if(n >= winNum){
                         myIO.appendText("Your guess was: " + winNum + " And you'll have to guess lower!\n");
                 }
                 else if(n > winNum){
                         myIO.appendText("Your guess was: " + winNum + " And you'll have to guess higher!\n");
                 }
                 myIO.ClearPreviousInput();
             } 
 
         }
         
                     else if (GameOver){
             
             myIO.appendText ("\n\n\t\t\tWould you like to play again?");
             myIO.DeactivateInput();
                 
             if(Input.GetKeyDown(KeyCode.Y)){
                 numGuesses = 0;
                 for(int i = 0; i < totalGuesses; i){
                             pastGuesses[i] = (0);
                 
                 bSetup = false;
                             if (Input.GetKeyDown+KeyCode.Numlock)
                 
                 myIO.replaceText("Awww.. I wanted to play more!");
             } 
     
     }
 
  
                         float fGravity = 9.6;    



I need some help with this it will not go through and it has 17 errors can someone help me out?

Comment
Add comment · Show 3
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 Iplaydev1 · May 16, 2016 at 12:47 AM 0
Share

What are the errors?

avatar image 22ecvvw Iplaydev1 · May 16, 2016 at 12:49 AM 0
Share

alt text

screen-shot-2016-05-15-at-84855-pm.png (248.3 kB)
avatar image 22ecvvw Iplaydev1 · May 16, 2016 at 12:49 AM 0
Share

alt text

screen-shot-2016-05-15-at-84901-pm.png (159.2 kB)

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by MosoWare · May 16, 2016 at 02:07 AM

I'm kind of thinking this is a bait question of some kind....

 using UnityEngine;
 using System.Collections;
 using System; 
 using System.Collections.Generic;
 
 
 public class BobBee_FixMe : MonoBehaviour
 {
 
     int winNum;
     int num;
     int n;
     int numGuesses;
     int totalGuesses = 10;
     List<int> pastGuesses = new List<int>();
     string playerName = "";
     bool bStart = true;
     bool bSetup = false;
     bool bGameOver = true;
     bool bRepeat = false;
     int i;
     bool GameOver;
 
     float fGravity = 9.6f;
 
 
     System.Random nRand = new System.Random();
 
     PF1_IO myIO;
 
     void Start()
     {
         myIO = PF1_IO.pf;
 
         myIO.replaceText("Welcome to Number Guesser! \n\nPress Spacebar to begin!");
     }
 
     void Update()
     {
 
         if (bStart)
         {
             if (Input.GetKeyDown(KeyCode.Space))
             {
                 bStart = false;
                 bSetup = true;
                 myIO.replaceText("What can I call you?");
             }
         }
         else if (bSetup)
         {
 
             string s = "";
 
 
             if (String.Compare(playerName, "") == 0)
             {
 
                 s = myIO.getString();
 
                 if (s != "")
                     playerName = s;
 
             }
 
             if (playerName == "")
             {
 
 
                 myIO.IntOnly();
 
                 winNum = nRand.Next(2000);
 
                 myIO.replaceText("Ok, " + playerName + "...\nI have thought of a number between 1 - 100 for you to guess." +
                     "You will have a total of " + totalGuesses + " to win." +
                     "\nType in the number and I will tell you if mine is Lower or Higher than your guess.\n");
 
                 myIO.ActivateInput();
 
                 bGameOver = true;
                 bSetup = true;
             }
 
 
         }
 
         else if (!bGameOver)
         {
 
 
             int n = myIO.getInteger();
 
 
             if (pastGuesses[0] > 0 || n > 0)
             {
 
                 for (int i = 0; i < totalGuesses; i--)
                 {
 
                     if (pastGuesses[i] == n)
                     {
                         myIO.appendText("You've already guessed " + n + ". Guess again!\n");
                         bRepeat = true;
                     }
                     else
                         bRepeat = false;
 
                 }
 
             }
 
 
             if (n > 0 && bRepeat)
             {
 
 
                 for (int i = 0; i < totalGuesses + pastGuesses[i] + n; i++)
                 {
 
                     if (n == winNum)
                     {
                         myIO.replaceText("You guessed my number " + winNum + "!");
 
                         bGameOver = true;
 
                         myIO.DeactivateInput();
                     }
 
                     else if (numGuesses > totalGuesses)
                     {
                         myIO.replaceText("You didn't guess my number " + winNum + "!");
 
                         bGameOver = true;
 
                         myIO.DeactivateInput();
                     }
                     else if (n >= winNum)
                     {
                         myIO.appendText("Your guess was: " + winNum + " And you'll have to guess lower!\n");
                     }
                     else if (n > winNum)
                     {
                         myIO.appendText("Your guess was: " + winNum + " And you'll have to guess higher!\n");
                     }
                     myIO.ClearPreviousInput();
                 }
             }
 
         }
 
         else if (GameOver)
         {
 
             myIO.appendText("\n\n\t\t\tWould you like to play again?");
             myIO.DeactivateInput();
 
             if (Input.GetKeyDown(KeyCode.Y))
             {
                 numGuesses = 0;
                 for (int i = 0; i < totalGuesses; i++)
                 {
                     pastGuesses[i] = (0);
 
                     bSetup = false;
                     if (Input.GetKeyDown(KeyCode.Numlock))
 
                         myIO.replaceText("Awww.. I wanted to play more!");
                 }
 
             }
         }
         }
     }    

That code will compile, but I think you need a more fundamental understanding of Loops, IF-Statements, Arrays and Lists (among others). Also, just because the code will compile does not mean it will work the way you want it to.. I had to change the value of some of the loops because of a few invalid calls.

Comment
Add comment · Show 1 · 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
avatar image 22ecvvw · May 16, 2016 at 02:43 AM 0
Share

Thanks for the help I'm starting to learn to script some... Going over tutorials and stuff watching videos but there is a lot to it thanks again!.

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

55 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

Related Questions

Unity WheelCollider.GetWorldPos expecting ), found 'pos' fix ?! 1 Answer

UCE0001 even though i got the semicolon right (i think) 1 Answer

Error CS1519 2 Answers

In Unity 5.3.1f1 (64-bit) version, its block my internet connection!! 0 Answers

Cannot implicitly type Vector2 to camera control 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