This is a simple real-time energy based system for your Unity3d game. It depends on real-time, so even when the phone is not in the game. It works without an internet connection and is not depends on the time of the device (if you change time - nothing will change), iOS / Android.
- 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
using EnergySuite;
EnergySuiteManager.GetAmount(timeValueType)
EnergySuiteManager.GetMaxAmount(timeValueType)
EnergySuiteManager.Add(timeValueType, amount);
(returns false if currentAmount < amountToUse)
EnergySuiteManager.Use(timeValueType, amount);
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;
}
}
(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;
}
}
TimeLeftSlider.value = EnergySuiteManager.ConvertToSliderValue(timeLeft, timeBasedValue);
All examples you can find at Example folder.
- Encrypted PlayerPrefs
- Native iOS/Android time check
- Make system handle many simultaneous timers
- Add Custom Editor
- Simple handler solution for web server
- Native iOS/Android notification system
Yes, please
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.
Maksym Yemelianov
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.