Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Purchasing multiple items to unlock a main item and affect currencies?

Discussion in 'Scripting' started by brutal_trifle, Feb 15, 2018.

  1. brutal_trifle

    brutal_trifle

    Joined:
    Feb 15, 2018
    Posts:
    19
    Hello, I am new to scripting so bare with me. I am currently developing a 2d clicker / idle game that has alot more than your standard clicker game. You can purchase computer parts, 10 parts total I also have 3 methods of income / outgoing.
    Money:
    Crypto:
    Electric:

    Basically I have it set so when you purchase an item it increases your crypto by 0.0001, takes the cost from your money and shows a count of how many you have. The price of the item also goes up by 10% each purchase. My main question is, how do I code the computer box to show 1 once all the other 10 items have been purchased. But once you gain 1 computer I would like it to show -$10 in Electric and for it to deduct the -$10 every minute or so. I also want the 1 computer to create 0.0001 crypto every 30 seconds or so. But I also need, if the money is less than what the electric cost is everything stops until your money is above the cost of electric.

    Hope this makes sense and I hope someone could help.
     
    Last edited: Feb 15, 2018
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    So...what is your scripting issue?

    Looking at your description, yes, I could set this up, but it's not a simple do this small few lines of code. This is an entire system, and most likely you're not going to get that from someone on here.

    If you have tried something and are stuck, come back with some code, ask a question about where you're stuck and continue from there. There is a lot of conditional stuff here, tracking of data, etc that you'll need to be dealing with.

    If your question is about electric value, you need to track the number of whole computers, multiply that by 10, check the value of money, subtract if there is enough. Trigger this off a timer. If your crypto generation is based on if you paid your electric, then you track that as well. If electric was paid, then when the crypto timer triggers, generate, otherwise display some message about not paying your bill. If money is ever not enough, you do something else instead or do nothing, changing a variable to track if you paid or not most likely.
     
  3. brutal_trifle

    brutal_trifle

    Joined:
    Feb 15, 2018
    Posts:
    19
    Thank you for replying. I would post some scripts but I haven't done one for the computer as I have no clue where to start. Only scripts I have are for the click me button and purchasing each item. My main question was how do I code the computer box to show 1 once all the other 10 items have been purchased, then for the 1 computer to change all currencies etc.
    Thank you again Brathnann.
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    Well, you're probably tracking purchasing of the computer. Once 10 parts are bought, you can increment a value computersOwned. Then start a timer that subtracts computersOwned x electric cost.(should verify if you have enough first). Then if paid, set a bool for electric paid to true or false if not paid. You should also start a second timer for the crypto when you complete your first computer. Then it checks if electric paid, if so, generate computersOwned x crypto generated.
     
  5. brutal_trifle

    brutal_trifle

    Joined:
    Feb 15, 2018
    Posts:
    19
    Thank you very much., big help. I'll get on it.