Search Unity

Implementing Upgrade System

Discussion in 'Scripting' started by SirBoboHobo, Jul 3, 2015.

  1. SirBoboHobo

    SirBoboHobo

    Joined:
    Feb 26, 2015
    Posts:
    41
    Hey guys, I'm working on a game in which my player can shoot and move, and I want to make an upgrade system to upgrade his power/speed and some more attributes if I'll want to.
    I've seen on Unity Forums a topic about that with dictionaries, tho I cannot understand how to implement it exactly.
    I can't understand how to do it, I can only guess, I'd be thankful if anyone could direct me the right way.
    I was thinking about it and maybe the right way is to make the dictionary with power and speed, then in a different script use get set when a purchase from the in game store is made, in the main script use the get attribute to know what the current speed is, if bought then obviously it'll be higher.

    Does anyone know what to do here? I'm lost :(
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,531
    Before you start thinking about the implementation, think about how the upgrades will work.

    static leveling:
    Is this a level system where you have statically defined levels. Every new level is reached when the player gains so many experience points. There stats are then changed to some new predetermined value. This is how a lot of classic JRPGs work, where a level 12 character on your savegame has the same stats (ignoring stats granted by equipped items), as a level 12 character in my save game.

    This system usually has a formula to calculate the stats. Or it has a static table that defines the stats.

    point distribution:
    In a system like this you usually have some stats you set at the get go. And then every level you earn a certain amount of points that can be distributed by the player. This is how D&D works, or Fallout, I bet you've played Fallout.

    You have your base stats that you get to define. In Fallout it's your SPECIAL stats. In D&D it's your classic STR, DEX, CON, INT, WIS, CHA. From this your HP, MP, number of skill points earned per level, are all determined as some formula based on the current stats (and may be adjusted by race or items held).

    Every level the player gets to manually distribute the points into skills they may want to modify to specialize there character.

    This way a level 12 character in your save game may be VASTLY different from a level 12 character in my save game.


    There are more systems, but I'm not going to go through all of them. You've got hybrid leveling systems, very customized ones, all sorts.

    But before you can decide how to implement them... you need to pick one. For example, if your levels are formulaic, you have NO need for a dictionary. (honestly, most leveling systems I can think of don't need dictionaries...)
     
    NinjaMonkey06 and Kiwasi like this.
  3. SirBoboHobo

    SirBoboHobo

    Joined:
    Feb 26, 2015
    Posts:
    41
    What I'm trying to do is a simple game in which you have no levels, just one scene and basically a casual "Who will score more points" basically gems or coins or whatever spawn on the board, they pick it up and earn gold, then when lose a shop is opened, in which they can purchase whatever they want. or should i say Upgrade
     
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,531
    What are they buying?

    Are they buying equipment that upgrades stats?

    Or are they directly purchasing permanent stat upgrades to their base stats?

    Or are you saying they're upgrading existing equipment? Like those new upgrade systems they have in a lot of games with guns today where you can modify a weapon with a new scope, or new barrel, to modify its stats.

    What are all these stats? Strength of the player? Strength of the weapon? Dexterity of the player? Etc...



    Before you can solve a problem, you must be able to describe the problem!
     
    Kiwasi likes this.
  5. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    Thankfully Unity developers are blessed with easy to modify variables. A simple change in a damage variable can be considered an upgrade. Or a multiplier. If you want your upgrades to include more mechanics, you'll have to reveal those new mechanics when the upgrade is unlocked. Damage resistance, movement speed, jump height, all of these can be changed by just changing a simple number.
     
  6. SirBoboHobo

    SirBoboHobo

    Joined:
    Feb 26, 2015
    Posts:
    41
    Permanent stat upgrade, like the players health, armor, speed, ETC.
    I thought maybe making a dictionary Upgrades, in which I pass to the Player script the attributes I need, for example make something like this
    Void TakeDamage(int amount)
    {
    health -= amount;
    if(health =< 0)
    die();
    }
    do I need to use properties here, Get Set, how do I exactly switch between what did the player just buy. Or maybe I'm off and I should use Lists and not Dictionaries. Trying to understand this subject, but a bit hard for me, not much tutorials that cover this in game, everyone just explain it.