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 ...
随机推荐
- 【Android】error opening trace file: No such file or directory (2)
1.问题描述: 运行报错: 12-25 13:35:32.286: E/Trace(1202): error opening trace file: No such file or directory ...
- HNOI2017前被虐记及感悟
本文所记录的时间以HNOI2017第一天考试时间为DAY1,前一天为DAY0,以此类推. 本文记载了博主从HNOI2017开始前一周进行全真模拟考试的被虐过程和结果.文章内可能包含博主的不良情绪,如果 ...
- Ackerman 函数 (双递归函数)
public static int ackerman(int n,int m){ if(n==1&&m==0){return 2;} else if(n==0&&m ...
- 第六章 Hibernate关联映射
第六章 hibernate关联映射一.本章知识点分为2部分:1.关联关系:单向多对一关联关系,双向一对多关联关系(含一对多关联关系),多对多关联关系2.延迟加载:类级别加载策略,一对多加载策略,多对一 ...
- 读书笔记 effective c++ Item 53 关注编译器发出的警告
许多程序员常常忽略编译器发出的警告.毕竟,如果问题很严重,它才将会变成一个error,不是么?相对来说,这个想法可能在其它语言是无害的,但是在C++中,我敢打赌编译器的实现者对于对接下来会发生什么比你 ...
- Angularjs快速入门(二)
说说上一节的例子,$scope 我们没有创建这个对象,直接绑定就能获取里面的对象,这种风格遵循了一种叫迪米特法则的设计模式. 然后angular还有一种很强大的功能叫“指令”. 就是你可以吧模板编写成 ...
- EverythingAboutJava
1 GC gabage collection 垃圾回收Java GC系列(1):Java垃圾回收简介 http://mp.weixin.qq.com/s?src=3×tamp=149 ...
- Java Web实现IOC控制反转之依赖注入
控制反转(Inversion of Control,英文缩写为IoC)是一个重要的面向对象编程的法则来削减计算机程序的耦合问题,也是轻量级的Spring框架的核心. 控制反转一般分为两种类型,依赖注入 ...
- 解决xmapp中Apache端口号占用问题
[原]解决 "安装xmapp后Apache不能正常启动" 问题 小伙伴们安装xmapp后发现Apache不能正常开启,下面给出了不同情况的解决办法,可以分为以下几种情况分析问题: ...
- JavaScript知识点整理 (二)
1)函数概述 1.函数是一块 JS 代码,被定义一次,但可以执行和调用多次. JS 中的函数也是对象,所以 JS 函数可以像其它对象那样操作和传递,所以也常叫 JS 中的函数为函数对象. 2.函数也是 ...