Search Unity

need help for my idle Game

Discussion in 'Scripting' started by Reyok95, Apr 27, 2015.

  1. Reyok95

    Reyok95

    Joined:
    Apr 27, 2015
    Posts:
    5
    soo i have 2 questions i want to ask :
    first i have floors and i want a boss apears every 5 lvl my code was this :

    Code (JavaScript):
    1. function Update()
    2. {
    3.         if(floor == 5 * Random.Range(1, 100))
    4.         {
    5.          //but i dont want it to be random so just calculate if floor is equls 5 or numbers multiplaed by 5
    6.          
    7.          }
    8. }
    second one is that i want my gold show in billions and triillions etc
    for example if i have 100,000,000 show it as 100M

    thats all hope my thread was understandable
    thx

    EDIT :
    also i want to know how to make the game work offline which means that players will keep progressing while offline and get gold etc
     
    Last edited: Apr 29, 2015
  2. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
  3. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    Depending on how far you are going to go, one thing to think about: what happens when you're score is 100,000,000,000,000,000,000,000,000 ...? after a while you can't represent the numbers with just one datatype. You'll need to work out a way hold the values and doing math with only the most pertinent significant figures. You'll note with many idle games you only ever handle values within a few 0's of each other.
     
  4. Reyok95

    Reyok95

    Joined:
    Apr 27, 2015
    Posts:
    5
    okay thanks to fluzing the wiki page you gived me helped
    so this is what i typed

    Code (JavaScript):
    1. if(floor % 5)
    2.     {
    3.         Debug.Log("Normal Enemy");
    4.     }else {
    5.         Debug.Log("Boss Time");
    6.     }
    now every 5 floors a boss will come
     
  5. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    You are almost there, but you forgot the == 0.

    Code (csharp):
    1.  
    2. if(floor % 5 == 0)
    3. {
    4.     //do boss time!
    5. }
    6.  
     
  6. Reyok95

    Reyok95

    Joined:
    Apr 27, 2015
    Posts:
    5
    your code did work too anyway do u know what does the % mean i was wondering
     
  7. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    It is the mod operator. It divides the first number with the second one and gives you the remainder.

    109 % 20 = 9
     
  8. Reyok95

    Reyok95

    Joined:
    Apr 27, 2015
    Posts:
    5
    but why is the = ?
     
  9. Reyok95

    Reyok95

    Joined:
    Apr 27, 2015
    Posts:
    5
    why you didnt type (floor % 5 == 1) soo if the remainder is 1 then spawn boss
    and typed if(floor % 5 == 0) the remainder here == to 1 soo why it did work