mlnv / Energysuite
Projects that are alternatives of or similar to Energysuite
EnergySuite
This is a simple time system for your Unity3D game to manage different kinds of goods that depend on time. It works without internet connection and does not depend on the system time of the device (if user change device system time - it won't change anything for this system), tested on iOS / Android.
Installation
- Apply last available unitypackage to your project
- Place EnergySuiteBehaviour prefab on your first scene (it's DontDestroyOnLoad script)
- Edit Password and PasswordSalt fields in EnergySuiteConfig.cs
- Add your time values to TimeValue enum
- Place you time values to StoredInfo field in EnergySuiteConfig.cs
- PROFIT
Example Code
Don't forget to add this at the top of the script:
using EnergySuite;
Get current time value amount:
EnergySuiteManager.GetAmount(timeValueType)
Get max time value amount:
EnergySuiteManager.GetMaxAmount(timeValueType)
Manually add amount of time value:
EnergySuiteManager.Add(timeValueType, amount);
Manually use amount of time value:
(returns false if currentAmount < amountToUse)
EnergySuiteManager.Use(timeValueType, amount);
Subscribe on time value amount changed action:
EnergySuiteManager.OnAmountChanged += OnAmountChanged;
void OnAmountChanged(int amount, TimeBasedValue timeBasedValue) {
string text = amount + "/" + timeBasedValue.MaxAmount;
switch (timeBasedValue.Type) {
case TimeValue.Life:
CurrentLifeAmountText.text = text;
break;
case TimeValue.Key:
CurrentKeyAmountText.text = text;
break;
default:
break;
}
}
Subscribe on time left tick action :
(updated every sec if not full)
EnergySuiteManager.OnTimeLeftChanged += OnTimeLeftChanged;
void OnTimeLeftChanged(TimeSpan timeLeft, TimeBasedValue timeBasedValue) {
string formatString = string.Format("{0:00}:{1:00}", timeLeft.Minutes, timeLeft.Seconds);
switch (timeBasedValue.Type) {
case TimeValue.Life:
LifeTimeLeftText.text = formatString;
break;
case TimeValue.Key:
KeyTimeLeftText.text = formatString;
break;
default:
break;
}
}
Convert time left value to slider value:
TimeLeftSlider.value = EnergySuiteManager.ConvertToSliderValue(timeLeft, timeBasedValue);
All examples you can find at Example folder.
TODO
- [x] Encrypted PlayerPrefs
- [x] Native iOS/Android time check
- [x] Make system handle many simultaneous timers
- [ ] Add Custom Editor
- [ ] Simple handler solution for web server
- [ ] Native iOS/Android notification system
Contribution
Yes, please
Dependencies
This asset use Secured PlayerPrefs and StateKit, so if you already have one of this asset in your project - just delete one copy of it.
Developed By
Maksym Yemelianov

License
Attribution-NonCommercial-ShareAlike 3.0 Unported with simple explanation with the attribution clause waived. You are free to use EnergySuite in any and all games that you make. You cannot sell EnergySuite directly or as part of a larger game asset.