Skip to content

itcOnlineGaming/GA_25_P3_Adrian_Sokolowski

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Upgrade System
This Unity package allows for the addition of a modular and customizable Upgrade System with example Economic and Experience Systems to accompany it.

Link To Google Doc of Guide Original Google Doc

Setup the component

Quick Start

Using the component

Upgrade System Setup

Creating Upgrade Objects

Upgrade Panel

Upgrade Object

Upgrade System using Experience System

Features Spec

Upgrade System

Value Requirement Integration

Upgrade Object Behavior

Panel & UI Management

Dynamic and Manual Setup Options

Setup the component {#setup-the-component}

You need to add the component to your project using the Package Manager. Open the Package Manager (Windows > Package Manager), click on the + icon and select “Add package from git URL...” and enter:
https://github.com/itcOnlineGaming/GA_25_P3_Adrian_Sokolowski.git?path=/UpgradeSystemComponent/Packages/ie.setu.upgradesystem#v1.0.3
Note that the URL specifies the complete path to the package and a git tag. The package should now be visible in your project.

Quick Start Demo {#quick-start-demo}

Upgrade System Demo Step 1: Turn On the Demo:

Enable DemoGuideUpgradeSystem  

Guide

Step 2: Try Using the Object and See the Differences Between them:

Play the game.

Using the Economic System I gave you 10000 to play with.

Guide

There are two different Upgrade Objects in your Scene. They look different and using them is different.

Guide

If you Press Buy on this object.

Guide

300 Economic Value will go away and an X will become a checkmark.

Guide

If you press Buy on this object, the Economic Value will Decrease by 100 for the first time.

This will continue to double as you press Buy again.

Guide

Unlike the other object, this Upgrade Object has a Sell button. If you click this button, some Economic Value will be refunded to you — but not all.

Step 3: Change the Objects:

These are all options I set in the UpgradeSystem Object in the DemoGuideUpgradeSystem Prefab.

Guide

UpgradeSystem Object has the script Upgrade System Controller.

Guide

For the sake of the Demo, the Script comes with two predefined Upgrade Objects you saw in Step 2.

For the Arrow Upgrade Object in the Upgrade Data List, try to change these parameters:

  • Max Upgrade Amount → from 5 to 10
  • Upgrade Cost → from 100 to 1000
  • Upgrade Cost Multiplier → from 2 to 1
  • Selling Cost Devaluation → from 0.5 to 1

Or any combination you desire.

Guide

Press Play.

Guide

Now the Arrow Upgrade Object has 5 more Upgrade Items.
When you press Buy, you are deducted 1000 Economic Value.
Consecutive Buy presses don't cost more because the Multiplier is 1.

When you press Sell, you receive the full Economic Value of the upgrade cost back.

Step 4: Add New Functionality To The Object:
Try pressing the Buy button for the Gun Upgrade Object.

Guide

Try moving the player with WASD.

Guide

As you press Buy more times, you will notice that the player increases in speed.

Guide

This is because, in the Gun Upgrade Data List Upgrade Object, the OnBuy() event calls PlayerController.AddSpeed().

Now, add a new OnSell() function:

  • Drag and drop the Player object into the slot
  • Pick the RemoveSpeed function from PlayerController

Guide Guide Guide

Before testing, make sure you uncheck Hide Selling for the Gun Upgrade Object to see the Sell button:

Guide

Play the game again.

Buy Gun upgrades (player speeds up), then sell them (player slows down).
Guide

You can customize Buy/Sell actions by assigning functions in the inspector.


Experience System Demo {#experience-system-demo}

Step 1: Turn On the Demo:

Enable DemoGuideExperienceSystem

Guide

Step 2: Try Leveling:

Play the game.
Click this button:

Guide

Walk into this object:
Guide

Notice how you are gaining experience and leveling up:

Guide

This bar and level number will increase:

Guide

Both systems use the EventManager package to Add Experience.

Step 3: Using Experience:

Open the Upgrade Panel:

Guide

Try buying upgrades:

Guide

You can’t buy more upgrades than your level allows.

Try selling upgrades:

Guide

After selling, you can buy again:

Guide

Step 4: Modifying the Experience Needed:
Change the Experience Amount Multiplier in the ExperienceSystemController:
Guide

Example: changing from 1.5 → 2.

Now your next Experience threshold doubles:

Guide Guide Guide

Step 5: Setting Your Own Experience Amounts:

Turn off the game:

Guide

Activate Use List Of Experience Thresholds:

Guide

Add values to the list:

Guide

Play the game:

Guide

Now your first few levels have custom XP requirements:

Guide

After the list ends, XP needed increases based on the multiplier:

Guide

This way you can tailor make your users experience for the first levels and then let the experience needed for more levels ramp up or slow down in cost.

Upgrade Object Demo

Step 1: Turn On The Demo

Enable DemoGuideUpgradeObject  

Guide

Step 2: Select The Object Too Modify

Pick One of the Two UpgradeObjects Assigned in the Demo

Guide

Step 3: See Dynamic Inspector Changes

Play Around with the Total Upgrades slider in the Upgrade Object Spawner

Guide

See how the amount of items in the Upgrade Object is changing dynamically in the Inspector. This way you can see how the Upgrade Object will look in the game without the need of playing.  

Guide

With 6 Total Upgrades

Guide

With 18 Total Upgrades

Step 4: Modify The Look Of The Upgrades

Change the Full Item object and Empty item objects 

Guide

See how the Upgrade Object Changes its upgrade icons dynamically in the inspector

Guide Guide

Once you pick the Full Item and Empty Item Objects you want to use in game.  

Guide

Change the Full Upgrade Item Texture and Empty Upgrade Item Texture in the Upgrade Controller Script to the textures you desire.  

Step 5: Add More Upgrade Objects

From the Upgrade System Prefab Folder. Drag a UpgradeObject Prefab into UpgradeHolder Object in your UpgradePanel

Guide

This is how you can Manually add more Upgrade Objects into your Upgrade Panel. You will notice that The New Upgrade Object will automatically be seen Underneath the other objects previously added.  

Guide

Using the component {#using-the-component}

  1. You have 3 different options for using the component. You are either able to use one of the two premade systems for value gathering ( EconomicSystem or ExperienceSystem ) or you can use the UpgradeSystem on its own and add your own value gathering system.
  2. If you wish to use one of the premade systems go to UpgradeSystem -> Runtime -> Prefabs -> EconomicSystem / Experience System and drag them into the scene Hierarchy and go to UpgradeSystem -> Runtime -> Prefabs -> UpgradeSystem and add it to the canvas in your scene.!Guide

Upgrade System Setup {#upgrade-system-setup}

Add the UpgradeSystem Prefab from UpgradeSystem -> Runtime -> Prefabs into your Canvas Object in your scene.

You are required to have a Value System Script using the IUpgradeRequirementChecker

( If You add the ExperienceSystemPrefab or the EconomySystem Prefab. They come with a script, with a fully implemented IUpgradeRequirementChecker )

public interface IUpgradeRequirementChecker
{
bool CanBuyOrSellUpgrade(int upgradeCost, bool isBuying);
void OnUpgradeBought(int upgradeCost);
void OnUpgradeSold(int upgradeCost);
}

Implement your Value System with these functions in mind.
They Control how your upgrade objects interact when adding or removing upgrades during gameplay.

Example Implementation from ExperienceSystemController
public bool CanBuyOrSellUpgrade(int upgradeCost, bool isBuying)
if (isBuying)
{
if (levelsUsed + upgradeCost > CurrentLevel)
return false;
}
else
{
if (levelsUsed - upgradeCost < 0)
return false;
}
return true;

public void OnUpgradeBought(int upgradeCost)
levelsUsed += (int)upgradeCost;

public void OnUpgradeSold(int upgradeCost)
levelsUsed -= (int)upgradeCost;

The UpgradeSystemController Script in the UpgradeSystem Prefab will find and assign the Requirement Checker Behaviour in the Scene if one is assigned. You may assign it yourself.
Guide

In order to add your first Upgrade Item into the game. Press the + button on “Upgrades” in the Upgrade System Controller in the Inspector
Guide

This is your first Upgrade Object Element. Which will be created when you run the game.
Guide Guide

Without assigning your own Icons / Sprites this is how the default Upgrade object looks like.

Creating Upgrade Objects {#creating-upgrade-objects}

Hide Selling - Used to hide the sell button if you don't desire it to be an option with your Value System.
Upgrade Icon - Used to identify which upgrade this Upgrade Object corresponds with ( Bow In the Image )
Selling Icon - Used to change the look of the selling button.
Buying Icon - Used to change the look of the buying button.
Full Upgrade Item Icon - Used to change the look of all upgraded Upgrade Items in the Upgrade Object ( Yellow Star in the Image )
Empty Upgrade Item Icon - Used to change the look of all empty Upgrade Items in the Upgrade Object ( White Star in the Image )
OnBuy() - Assign what function you wish to run when the buy button is clicked ( This is what determines what is being upgraded )
OnSell() - Assign what function you wish to run when the sell button is clicked ( This is what determines what is being downgraded )
Guide

By changing the Upgrade Icon in the Inspector.
Guide I am able to change what the Upgrade Icon looks like in the game, inside of my Upgrade Object from the default ( Bow Icon ) to the updated Sword Icon.
Guide Max Upgrade Amount - The Amount of Upgrades possible for this Upgrade Object ( This is what determines the amount of Upgrade Items ( Default Stars ) Inside of the Upgrade Object during runtime.
Upgrade Cost - The Amount of Value it costs for a single Upgrade to be bought.
Upgrade Cost Multiplier - The Cost Multiplier of consecutive upgrades in this Upgrade Object.

Upgrade Panel {#upgrade-panel}

Upgrade Panel Open - This holds the Upgrade Scroll Controller Script. Here you are able to specify the height of the Visible Area where the Upgrade Objects reside and the Content Height, the height where Upgrade Objects are.
Guide

Using this You are able to limit the height of the Upgrade Panel in the game. While adding more Upgrade Objects then the height of the panel allows.
Guide I have 3 Upgrade Objects. While only 2 are visible.
Guide When I use the Slider on the side I am able to see the other Upgrade Object which is in the Scene.

Using this you are able to have more Upgrade Objects while maintaining how much space the Upgrade Panel takes in your game.

In the UpgradeHolder GameObject you will see the UpgradeObjects which you created beforehand.
Guide

Upgrade Object {#upgrade-object}

If you wish to Manually Add Upgrade Objects Into the Scene.
Add the Upgrade System into the Scene as beforehand and leave the Upgrade Data List empty.
Go to UpgradeSystem -> Runtime -> Prefabs -> Upgrade System Prefabs ->
Folder where you will find the UpgradeObject prefab.
Drag and Drop this prefab as a child into the UpgradeHolder object. Your Upgrade Object prefab should appear in the Upgrade Panel, in the scene.

In the UpgradeObject prefab you are dragged into the scene. You are able to dynamically change the amount of Upgrade Items In the Scene which will update in the Inspector. This allows you to gauge the look of the Upgrade Object during Runtime.
Guide This happens by using the slider Total Upgrades in the Upgrade Object Spawner Script, in the Upgrade Object prefab

When not using the Upgrade System to dynamically add Upgrade Objects. You need to assign the Requirement Checker Behaviour script to the Upgrade Objects Manually.
Guide

Upgrade System using Experience System {#upgrade-system-using-experience-system}

From UpgradeSystem -> Runtime -> Prefabs Drag the ExperienceSystem prefab into the scene. Using the Experience System, in the ExperienceSystem Prefab Object You will see the Experience System Controller Script which will allow you to specify and modify the following.

  1. Using the premade Experience System you are able to specify the maximum level you want possible in your game.
  2. A starting Experience amount needed to level up.
  3. Experience Amount Multiplier which will increase the experience needed to level up each level.
  4. Use a List of Experience Thresholds needed to level up. By stating exact experience necessary for each level ( If you wish to do this for only the first couple levels. The experience amount multiplier will take over for the rest of the levels until the max level is achieved )
  5. You can add your own slider to use for showcasing how much experience the player currently has by dragging it into the Experience Slider variable slot.
    Guide

Features Spec {#features-spec}

Upgrade System {#upgrade-system}

  • Allows adding customizable Upgrade Objects into the game dynamically or manually.

  • Each Upgrade Object can represent an upgradeable feature in the game (e.g., Weapon upgrades, Abilities, Skills).

Value Requirement Integration {#value-requirement-integration}

  • Works with any value system (like Experience Points, Currency, etc.) through the IUpgradeRequirementChecker interface.

  • Premade support for Experience System and Economic System included.

  • Requirement checking happens before upgrades or downgrades are allowed.

Upgrade Object Behavior {#upgrade-object-behavior}

  • Each Upgrade Object can have multiple Upgrade Items (e.g., stars) showing upgrade progress.

  • Upgrade Items update visually between Full and Empty based on upgrades bought/sold.

  • Upgrades and downgrades trigger customizable Unity Events (OnBuy, OnSell).

Panel & UI Management {#panel-&-ui-management}

  • Upgrade Panel can scroll dynamically if Upgrade Objects overflow the visible area.

  • Visual customization for:

    • Upgrade Icon

    • Buy Button Icon

    • Sell Button Icon

    • Full Upgrade Item Icon

    • Empty Upgrade Item Icon

  • Sell Button visibility can be toggled off for specific upgrades.

Dynamic and Manual Setup Options {#dynamic-and-manual-setup-options}

  • Dynamically create Upgrade Objects through the Upgrade System Controller.

  • Alternatively, manually place Upgrade Objects under the Upgrade Holder for full manual control.

  • Manual objects require manual assignment of requirement checkers.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published