修该json
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3808b39e00871be43bda11114e415f3f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Example.Counter
|
||||
{
|
||||
public interface IAchievementSystem : ISystem
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class AchievementSystem : AbstractSystem, IAchievementSystem
|
||||
{
|
||||
public IArchitecture Architecture { get; set; }
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
var counterData = this.GetData<ICounterData>();
|
||||
|
||||
var previousCount = counterData.Count.Value;
|
||||
|
||||
counterData.Count.Register(newCount =>
|
||||
{
|
||||
if (newCount >= 10 && previousCount < 10)
|
||||
{
|
||||
Debug.Log("解锁 10 次点击成就");
|
||||
}
|
||||
else if (newCount >= 20 && previousCount < 20)
|
||||
{
|
||||
Debug.Log("解锁 20 次点击成就");
|
||||
}
|
||||
|
||||
previousCount = newCount;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f241abf86b6647ea93571ad2f92c913a
|
||||
timeCreated: 1624955512
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
|
||||
namespace Stary.Evo.Example.Counter
|
||||
{
|
||||
public class CommandAnd : AbstractCommand
|
||||
{
|
||||
protected override void OnExecute()
|
||||
{
|
||||
this.GetData<ICounterData>().Count.Value++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca5d6aa1e6bbab64dbbdeace6b015b23
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
namespace Stary.Evo.Example.Counter
|
||||
{
|
||||
public class CommandSub : AbstractCommand
|
||||
{
|
||||
protected override void OnExecute()
|
||||
{
|
||||
CounterApp.Interface.GetData<ICounterData>().Count.Value--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b07fd1086f5d247448c730438ab61e75
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
namespace Stary.Evo.Example.Counter
|
||||
{
|
||||
public class CounterApp : Architecture<CounterApp>
|
||||
{
|
||||
protected override void Init()
|
||||
{
|
||||
RegisterSystem<IAchievementSystem>(new AchievementSystem());
|
||||
RegisterData<ICounterData>(new CounterData());
|
||||
RegisterUtility<IStorage>(new PlayerPrefsStorage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b9e1b9962882b647b727dc4749d40dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
|
||||
namespace Stary.Evo.Example.Counter
|
||||
{
|
||||
|
||||
public interface ICounterData : IData
|
||||
{
|
||||
BindableProperty<int> Count { get; }
|
||||
}
|
||||
|
||||
public class CounterData : AbstractData, ICounterData
|
||||
{
|
||||
public override void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
var storage = this.GetUtility<IStorage>();
|
||||
Count.Value = storage.LoadInt("COUNTER_COUNT", 0);
|
||||
|
||||
Count.Register( count => { storage.SaveInt("COUNTER_COUNT", count); });
|
||||
}
|
||||
|
||||
public BindableProperty<int> Count { get; } = new BindableProperty<int>()
|
||||
{
|
||||
Value = 0
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10c86a7a3c934d4796a6ec85a27f5a81
|
||||
timeCreated: 1624948547
|
||||
@@ -0,0 +1,53 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Stary.Evo.Example.Counter
|
||||
{
|
||||
public class CounterViewController : MonoBehaviour, IController
|
||||
{
|
||||
private Text _countText;
|
||||
private ICounterData mCounterData;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// 获取
|
||||
mCounterData = this.GetData<ICounterData>();
|
||||
mCounterData.Count.Register(UpdateView);
|
||||
_countText = transform.Find("CountText").GetComponent<Text>();
|
||||
_countText.text = mCounterData.Count.Value.ToString();
|
||||
transform.Find("ButtonAdd").GetComponent<Button>()
|
||||
.onClick.AddListener(() =>
|
||||
{
|
||||
// 交互逻辑
|
||||
this.SendCommand<CommandAnd>();
|
||||
});
|
||||
|
||||
transform.Find("ButtonSub").GetComponent<Button>()
|
||||
.onClick.AddListener(() =>
|
||||
{
|
||||
// 交互逻辑
|
||||
this.SendCommand<CommandSub>();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//表现逻辑
|
||||
void UpdateView(int countValue)
|
||||
{
|
||||
_countText.text = countValue.ToString();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
mCounterData.Count.Register(UpdateView);
|
||||
mCounterData = null;
|
||||
}
|
||||
|
||||
IArchitecture IBelongToArchitecture.GetArchitecture()
|
||||
{
|
||||
return CounterApp.Interface;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 856a6da247744b64e940e39f89e90657
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Example.Counter
|
||||
{
|
||||
public interface IStorage:IUtility
|
||||
{
|
||||
void SaveInt(string key, int value);
|
||||
|
||||
int LoadInt(string key, int defaultValue = 0);
|
||||
}
|
||||
|
||||
public class PlayerPrefsStorage : IStorage
|
||||
{
|
||||
public void SaveInt(string key, int value)
|
||||
{
|
||||
Debug.Log("PlayerPrefsStorage执行");
|
||||
PlayerPrefs.SetInt(key, value);
|
||||
}
|
||||
|
||||
public int LoadInt(string key, int defaultValue = 0)
|
||||
{
|
||||
return PlayerPrefs.GetInt(key, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
public class EditorPrefsStorage : IStorage
|
||||
{
|
||||
public void SaveInt(string key, int value)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("EditorPrefsStorage执行");
|
||||
EditorPrefs.SetInt(key, value);
|
||||
#endif
|
||||
}
|
||||
|
||||
public int LoadInt(string key, int defaultValue = 0)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return EditorPrefs.GetInt(key, defaultValue);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 888277c00f124f46b4aede962dea86c2
|
||||
timeCreated: 1624936004
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf353055f2d28804f98d546c9f04ddcf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1281
Assets/00.StaryEvo/~Samples/Runtime/CounterApp/Sence/Counter.unity
Normal file
1281
Assets/00.StaryEvo/~Samples/Runtime/CounterApp/Sence/Counter.unity
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a98d5b4bbdf7a41428d28563f2282a7d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user