153 lines
3.9 KiB
C#
153 lines
3.9 KiB
C#
using SK.Framework;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
public class HomeView : UIView
|
||
{
|
||
public Button enterBtn;
|
||
public TextMeshProUGUI textMeshProUGUI;
|
||
public Variables variables;
|
||
private Clock clock;
|
||
|
||
protected override void OnInit(IViewData data)
|
||
{
|
||
base.OnInit(data);
|
||
|
||
|
||
|
||
enterBtn = variables.Get<Button>("enterBtn");
|
||
enterBtn.gameObject.SetActive(false);
|
||
variables.Set<HomeView>("myHome",this);
|
||
string[] exampleArray = new string[] { "AAA", "BBB" };
|
||
//Array合并
|
||
string[] target = new string[] { "CCC", "DDD" };
|
||
string[] merge = exampleArray.Merge(target);
|
||
|
||
Test();
|
||
|
||
textMeshProUGUI.fontStyle = FontStyles.Strikethrough;
|
||
//创建分数组合 记录标识
|
||
string[] flags = Score.CreateGroup("选择题", ValueMode.Additive,
|
||
ScoreIDConstant.QUESTION_1,
|
||
ScoreIDConstant.QUESTION_2
|
||
);
|
||
string[] flag1s = Score.CreateGroup("判断", ValueMode.Additive,
|
||
ScoreIDConstant.QUESTION_3,
|
||
ScoreIDConstant.QUESTION_4
|
||
);
|
||
//通过标识获取分数
|
||
Score.Obtain("选择题", flags[0]);
|
||
Score.Obtain("判断", flag1s[1]);
|
||
|
||
//创建单项分数,通过getsun获取所有单项分数的得分总和
|
||
string score1= Score.Create(ScoreIDConstant.QUESTION_1);
|
||
Score.Obtain(score1);
|
||
Score.GetSum();
|
||
|
||
|
||
//Score.GetSum();
|
||
//Debug.Log("总分为:"+ Score.GetSum()) ;
|
||
Debug.Log($"选择题:{Score.GetGroupSum("选择题")}+判断:{Score.GetGroupSum("判断")}");
|
||
|
||
Score.Cancle("判断", flag1s[1]);
|
||
Debug.Log($"选择题:{Score.GetGroupSum("选择题")}+判断:{Score.GetGroupSum("判断")}");
|
||
|
||
//消息订阅机制
|
||
Messenger.Subscribe<Variables>("model", Messaggetest);
|
||
Messenger.Subscribe("12", delegate {
|
||
|
||
Debug.Log("12号消息订阅");
|
||
});
|
||
//Resources.Load<WebInterfaceProfile>("WebInterface Profile");
|
||
|
||
//注册接口
|
||
WebRequester.RegisterInterface<TextResponseWebInterface>("北京时间", out var hourStatistics);
|
||
|
||
//设置回调函数
|
||
hourStatistics.OnCompleted(response => Debug.Log(response));
|
||
hourStatistics.SendWebRequest();
|
||
|
||
clock = Timer.Clock();
|
||
clock.Launch();
|
||
|
||
//clock.ElapsedTime
|
||
//clock.Begin(this);
|
||
clock.OnStop(() => {
|
||
|
||
Debug.Log(clock.ElapsedTime);
|
||
|
||
Debug.Log(TimeUtility.ToMSTimeFormat(clock.ElapsedTime));
|
||
});
|
||
|
||
//SceneLoader.LoadAsync("01")
|
||
// .OnBegan(() =>
|
||
// {
|
||
|
||
// })
|
||
// .OnCompleted(() => { })
|
||
// .OnLoading((s) => { Debug.Log(s); });
|
||
|
||
TestA a = Singleton<TestA>.Instance;
|
||
a.myStr = string.Empty;
|
||
//单例释放
|
||
Singleton<TestA>.Dispose();
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
void Click()
|
||
{
|
||
this.Unload();
|
||
}
|
||
private void Update()
|
||
{
|
||
|
||
if (Input.GetKeyDown(KeyCode.A))
|
||
{
|
||
Messenger.Publish("model", variables);
|
||
|
||
Messenger.Publish("12");
|
||
clock.Stop();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
public void Messaggetest(Variables var)
|
||
{
|
||
Debug.Log(var.Get<Button>("enterBtn").name);
|
||
|
||
}
|
||
|
||
private IActionChain ac;
|
||
void Test()
|
||
{
|
||
ac= this.Sequence()
|
||
.Delay(3f)
|
||
.Events(() =>
|
||
{
|
||
enterBtn.gameObject.SetActive(true);
|
||
|
||
})
|
||
.Append(new ConcurrentActionChain()//嵌套一个并发事件链
|
||
|
||
.Delay(1f, () => Debug.Log("1f"))
|
||
.Delay(2f, () => Debug.Log("2f"))
|
||
.Delay(3f, () => Debug.Log("3f")) as IAction)
|
||
.Until(() => Input.GetKeyDown(KeyCode.Space))
|
||
.Event(
|
||
() =>
|
||
{
|
||
enterBtn.gameObject.SetActive(false);
|
||
})
|
||
|
||
.Begin();
|
||
}
|
||
|
||
}
|