https://github.com/pointcache/Unity3d-Timers

Unity3d-Timers

Timer class with various behaviors

About: Have a system allowing to easily create and extend complex timer behaviors.

Usage:

//Start simple repeater
Timer.Repeater(5f, () => Debug.Log("Repeater test"));
//Start countdown and call Draw in 2.5 seconds
Timer.Countdown(2.5f, Draw);

Concept: A manager class pools and constructs new timers, timer store up to 4 handlers, and arbitrarely raise events in concrete implementation.

private class CountdownBehavior : TimerBehaviorBase, ITimerBehavior
{
float exitTime;
public void Initialize()
{
exitTime = f1;
} public void Update(float deltaTime)
{
TimePassed += deltaTime;
TotalTimeActive += deltaTime; if (TimePassed > exitTime)
{
Completed = true;
c1();
}
}
}

Countdown inherits TimerBehaviorBase and implements ITimerBehavior. On top of that only concrete behavior in implemented that uses data and callbacks provided in constructor:

public static Timer Countdown(float exitTime, Action callback)
{
Timer timer = TimerManager.getTimer();
timer.SetBehavior<CountdownBehavior>();
timer.behaviorBase
.SetFloats(exitTime, 0, 0, 0)
.SetCallbacks(callback, null, null, null);
timer.behavior.Initialize();
return timer;
}

as you can see you can set 4 floats, and 4 callbacks and use them in your implementation of behavior as you like. Examples 

For concrete real example look at Ability class, it implements typical game ability, with cooldown.

Github - Unity3d-Timers的更多相关文章

  1. 定时器(NSTimer)

    iOS中定时器NSTimer的使用 1.初始化 + (NSTimer *)timerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget sel ...

  2. 搜刮一些开源项目的APP

    iOS完整App资源收集 <iOS完整app资源收集>  <GitHub 上有哪些完整的 iOS-App 源码值得参考?> <GitHub 上有哪些完整的 iOS-App ...

  3. [GitHub] - Unity Timer

    https://github.com/akbiggs/UnityTimer#unity-timer Run actions after a delay in Unity3D. This library ...

  4. 山寨Unity3D?搜狐畅游的免费开源游戏引擎Genesis-3D

    在CSDN上看到了<搜狐畅游发布3D游戏引擎Genesis-3D 基于MIT协议开源>(http://www.csdn.net/article/2013-11-21/2817585-cha ...

  5. 从Unity3D编译器升级聊起Mono

    接前篇Unity 5.3.5p8 C#编译器升级,本文侧重了解一些Mono的知识. Unity3D的编译器升级 新升级的Mono C#编译器(对应Mono 4.4) Unity编辑器及播放器所使用的M ...

  6. Unity3D和Egret3D的基情

    Unity3D依靠多平台发布这个核心特点,目前如日中天,屌丝引擎之王绝无来者.Egret白鹭引擎,也着实在微信上刷了一屏又一屏.这二者似乎风马牛不相及,但是这个无处不搞基的年代,让一切皆有可能. U3 ...

  7. Egret3D研究报告(二)从Unity3D导出场景到Egret3D

    Egret3D暂时没有场编的计划,但是我们知道unity3D是一个很好的场编. 有一些游戏即使不是使用Unity3D开发,也使用Unity3D做场编.这里就不点名了,而且并不在少数. 我们就这么干. ...

  8. Unity3D游戏开发初探—4.开发一个“疯狂击箱子”游戏

    一.预备知识—对象的”生“与”死“ (1)如何在游戏脚本程序中创建对象而不是一开始就创建好对象?->使用GameObject的静态方法:CreatePrimitive() 以上一篇的博文中的“指 ...

  9. 便捷的方式在手机上查看Unity3D的Console Log(调试信息)

    Logs Viewer 功能描述 Using this tool you can easily check your editor console logs inside the game itsel ...

  10. Unity3D 搭建优雅的UI框架

    为什么要使用UI框架?直接使用NGUI或UGUI一拖一拉直接搭载出界面不就行了? 我相信很多小白,包括我在刚学习Unity3D UI的时候都这样想过. 我的第一款款Unity2D游戏<山地赛车& ...

随机推荐

  1. 路由传参,path和query的刷新报错js文件丢失

    日常的路由跳转,基本都会用到传参,有两种方式:path + query, name + params 常用的写法: this.$router.push({ path: 'proDetail',quer ...

  2. 深入理解java虚拟机学习笔记(一)JVM内存模型

    上周末搬家后,家里的宽带一直没弄好,跟电信客服反映了N遍了终于约了个师傅明天早上来迁移宽带,可以结束一个多星期没网的痛苦日子了.这段时间也是各种忙,都一个星期没更新博客了,再不写之前那种状态和激情都要 ...

  3. 高封装的property方法

    class Person(): def __init__(self): self.__age = 0 def set_age(self, age): if age < 0 or age > ...

  4. selenium等待页面加载完成

    https://blog.csdn.net/hu_zhenghui/article/details/77429505 38行      这种方法 不准确   还在空白页时候   就会 返回  comp ...

  5. Logrotate实现Catalina.out日志每俩小时切割

    一.Logrotate工具介绍 Logrotate是一个日志文件管理工具,它是Linux默认自带的一个日志切割工具.用来把旧文件轮转.压缩.删除,并且创建新的日志文件.我们可以根据日志文件的大小.天数 ...

  6. linux下Tomcat配置提示权限不够解决办法

    在终端输入命令 sudo chmod -R 777 /opt/Tomcat,那么Tomcat文件夹和它下面的所有子文件夹的属性都变成了777(读/写/执行权限)

  7. IntelliJ IDEA 12详细开发教程(一)思想的转变与新手入门【转】

    转载地址:http://bangqu.com/alicas/blog/433 从事软件开发工作以来,提高自己的开发效率,提高自己编码的规范,提高编码深度层次,这三样一直都是自己努力去追求的事情. 最近 ...

  8. yii2 url 美化参数

    所谓的url参数美化就是将冗长的字符串 进行正则替换 yii2 框架的url参数美化完成需要完成两个阶段 第一个阶段分apache和nginx 两种的配置 apache :1.1 必须开启rewrit ...

  9. 学习python第十四天,模块

    Python 模块(Module),是一个 Python 文件,以 .py 结尾,包含了 Python 对象定义和Python语句. 模块让你能够有逻辑地组织你的 Python 代码段. 把相关的代码 ...

  10. Python学习之函数参数

    上一节,我们学习了Python中是如何定义和调用函数且如何得到返回值的.在调用函数时,有的函数需要参数来启动函数,有的则无需参数.这一节我们来介绍Python中有哪些参数类型. 位置参数 在调用函数时 ...