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.
- 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.