BattleInfo
private Dictionary<string, UILabel> mLabels;
private Dictionary<string,UISprite> mSprites;
Coroutine myTimer;
protected pverride void OnAwake()
{
mLabels = UI.GetElement<UILabel>(transform);
mSprites = UI.GetElement<UISprite>(transform);
Register();
transform.Find("grid").localPosition = GetTop(); //在游戏上方显示
}
private void OnDestory()
{
UnRegister();
}
private void Register()
{
EventManager.AddListener(EventConst.StartBattleTime,StartTime);
EventManager.AddListener(EventConst.RefreshBattleNum,RefreshAliveNum);
EventManager.AddListener(EventConst.RefreshBattleName,RefreshHonourValue);
EventManager.AddListener(EventConst.RefreshBattleHonourValue,RefreshHonourValue);
EventManager.AddListener(EventConst.StopBattleTime,StopTime);
}
private void UnRegister()
{
EventManager.RemoveListener(EventConst.StartBattleTime,StartTime);
EventManager.RemoveListener(EventConst.RefreshBattleNum,RefreshAliveNum);
EventManager.RemoveListener(EventConst.RefreshBattleName,RefreshHonourValue);
EventManager.RemoveListener(EventConst.RefreshBattleHonourValue,RefreshHonourValue);
EventManager.RemoveListener(EventConst.StopBattleTime,StopTime);
}
private void StartTime(object param)
{
List<object> list = (List<object>)param;
TimeSpan ts = TimeSpan.Parse((string)list[0]);
myTimer = StartCoroutine(UI.DoTimerMinuteSec(ts,mLabels["CountDown"]));
}
private void StopTime(object param)
{
List<object> list = (List<object>)param;
StopCoroutine(myTimer);
int type = (int) list[0];
if(type == 0)
{
}else if(type == 1){
mLabels["CountDown"].text = "00:00";
}
}
private void RefreshAliveNum(object param)
{
Lisr<object> items = (List<object>)param;
string type = (string)items[0];
if(type == "all")
{
mLabels["AppearUnits1"].text = items[1].ToString();
mLabels["AppearUnits1"].text = items[2].ToString();
}
else if(type == "player")
{
mLabels["AppearUnits1"].text = items[1].ToString();
}
else if(type == "enemy")
{
mLabels["AppearUnits1"].text = items[1].ToString();
}
}
private void RefreshName(object param)
{
Lisr<object> items = (List<object>)param;
string type = (string)items[0];
if(type == "all")
{
mLabels["Name1"].text = items[1].ToString();
mLabels["Name2"].text = items[2].ToString();
}
else if(type == "player")
{
mLabels["Name1"].text = items[1].ToString();
}
else if(type == "enemy")
{
mLabels["Name2"].text = items[1].ToString();
}
}
private void RefreshHonourValue(object param)
{
Lisr<object> items = (List<object>)param;
string type = (string)items[0];
if(type == "all")
{
mLabels["HorourValue1"].text = items[1].ToString();
mLabels["HorourValue2"].text = items[2].ToString();
}
else if(type == "player")
{
mLabels["HorourValue1"].text = items[1].ToString();
}
else if(type == "enemy")
{
mLabels["HorourValue2"].text = items[1].ToString();
}
}
BattleInfo的更多相关文章
- [TcaplusDB知识库]TcaplusDB客户端及常用命令
数据库大都支持命令行访问,TcaplusDB也不例外,通过安装TcaplusDB客户端,您可以方便快捷地从命令行管理与访问数据库. TcaplusDB客户端 首先在 TcaplusServiceApi ...
随机推荐
- Java中执行shell笔记
在java中执行shell有好几种方式:第一种(exec)方式一 public static synchronized void runshell2() { File superuser = n ...
- Ranking Relevance小结
Ranking Relevance是搜索排序算法的各个影响因子中相当重要的一个部分.对于Ranking Relevance的计算,过去的技术往往分为两个大的方向:Click Behavior和Text ...
- JS和CSS中引号的使用
font-family属性值如果是英文可以不加引号,如果是中文按照CSS标准则应该加引号,但不加引号也没关系.比如:font-family:Arial,"宋体"," ...
- Linux学习---vi/vim命令
Vim是从 vi 发展出来的一个文本编辑器.代码补完.编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用. 所以本文直接用Vim编辑器 基本上 vi/vim 共分为三种模式,分别是命令模式( ...
- AngularJS创建新指令 - 基本功能
指令(Directives)是所有AngularJS应用最重要的部分.尽管AngularJS已经提供了非常丰富的指令,但还是经常需要创建应用特定的指令. AngularJS原有的指令 ng-init ...
- yum仓库
1.概念: Yum仓库则是为进一步简化RPM管理软件难度而设计的,Yum能够根据用户的要求分析出所需软件包及其相关依赖关系,自动从服务器下载软件包并安装到系统 yum的工作原理:执行yum命令――&g ...
- elasticsearch基础概念
接近实时(NRT) Elasticsearch是一个接近实时的搜索平台.这意味着,从索引一个文档直到这个文档能够被搜索到有一个轻微的延迟(通常是1秒). 集群(clu ...
- 【代码学习】MYSQL数据库的常见操作
---恢复内容开始--- ============================== MYSQL数据库的常见操作 ============================== 一.mysql的连接与 ...
- 关于System.Windows.Forms.DateTimePicker的一个Bug
几天接到客户的反馈,说系统无法查询2017年2月份的账单,原因是没办法选择2017年2月份,没办法选择2月份???,马上开启vs,运行系统,应为市去年的系统,测试数据也是去年的,就查询了2016年2月 ...
- C# 读取Execl和Access数据库
第一次写,请大家指教!!话不多说 直接走代码! /// <summary> /// 打开文件 /// </summary> /// <param name="s ...