Giter Site home page Giter Site logo

uclicker's Introduction

uClicker

uClicker is a clicker/idle game library that attempts to take the boilerplate out of clicker games made in Unity. Influenced heavily by the awesome Idle game maker.

  • Plug n' Play
  • (Probably) minimal code required
  • No allocations/garbage

uClicker is very ScriptableObject oriented. Every upgrade, building, currency is a scriptable object. This allows you to create new content without writing a line of code. A normal workflow would be

  • Create a currency (what we're incrementing)
  • Create a Clickable (how we're incrementing)
  • Create a manager (actually does the incrementing/logic)
  • Hook them together.
  • MyClickerManagerReference.Click() to make the numbers go up
  • Create upgrades and buildings to modify those values (And don't forget to periodically MyClickerManagerReference.Tick()

Installation

uClicker now comes in a package. You can add the github URL via the Package manager or download the source and put it into your projects Packages folder.

Example

In Unity 2019.3 and up you should be able to install the same via the package manager, otherwise copy and paste the contents of the uClicker/Sameples~/ to your Assets folder.

uclicker's People

Contributors

philipcass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

uclicker's Issues

Bug in ApplyBuildingPerks

This method logic always multiply current currency amount instead of multiply only current building amount. For example we have B1(building 1) - 10 amount, B2 - 10 and B - 10 and upgrade perk to have x2 to each only individualy, as it present in sample scene project. And lets say each building gives 1 rabbit per sec, which means we should have 10 * 2 + 10 * 2 + 10 * 2 = 60 income, but we not. Income will be 140, cuz this method do next: (0 + 10) * 2 = 20, then (20 + 10) * 2 = 60, then (60 + 10) * 2 = 140.

There is a fix

        private void ApplyBuildingPerks(Currency currency, ref float totalAmount)
        {
            float buildingAmount;
            foreach (KeyValuePair<Building, int> kvp in State.EarnedBuildings)
            {
                buildingAmount = 0f;
                Building building = kvp.Key;
                if (building.YieldAmount.Currency != currency)
                {
                    continue;
                }

                int buildingCount = kvp.Value;
                buildingAmount += building.YieldAmount.Amount * buildingCount;

                foreach (Upgrade upgrade in State.EarnedUpgrades)
                {
                    foreach (UpgradePerk upgradePerk in upgrade.UpgradePerk)
                    {
                        if (upgradePerk.TargetBuilding != building)
                        {
                            continue;
                        }

                        switch (upgradePerk.Operation)
                        {
                            case Operation.Add:
                                buildingAmount += upgradePerk.Amount;
                                break;
                            case Operation.Multiply:
                                buildingAmount *= upgradePerk.Amount;
                                break;
                        }
                    }
                }
                totalAmount += buildingAmount;
            }
        }

Sample project error

ArgumentException: Save 'save' is null
uClicker.ClickerManager.LoadProgress () (at Library/PackageCache/com.wwweh.uclicker@055b8168d8/Runtime/ClickerManager.cs:250)
ClickerRunner+d__1.MoveNext () (at Assets/Samples/uClicker/0.0.3/Example Project/Scripts/ClickerRunner.cs:12)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <07c89f7520694139991332d3cf930d48>:0)

OnTick callback issue in ClickerManager

public void Tick()
{
    bool updated = false;
    foreach (Currency currency in Config.Currencies)
    {
        float amount = PerSecondAmount(currency);

        updated = UpdateTotal(currency, amount);
    }

    UpdateUnlocks();
    if (updated)
    {
        OnTick.Invoke();
    }
}

Isn't the updated bool incorrectly assigned in the loop? If the last currency in an iteration isn't updated, it'll render no calls to OnTick events.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.