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. cuda数组的拷贝

    原文链接 简单描述一下自己要做的事情:(1)CPU三维的vector--->(2)CPU三维数组--->(3)转换到GPU中的三维数组--->(4)转换到CPU中的三维数组,而其中问 ...

  2. 【JS-Java-EL】JavaScript和Java(EL表达式)引发的 Uncaught SyntaxError: Unexpected token ILLEGAL

    2018.10.14 BUG原因: 在较早期的代码中,容易出现 JS 拼接 HTML 代码字符串的情况.如 // 页面 test.jsp 内部的 JS 代码 // ${} JSP中EL语法,内部为Ja ...

  3. 第一个C#程序Hello World

    一.编写第一个C#程序——Hello World1. 启动Microsoft Visual Studio 2010.2. 点击“文件”菜单,选择“新建”项,在弹出的子菜单中选择“项目”命令.3. 弹出 ...

  4. babel 不能统编译Iterator、Generator、Set、Maps、Proxy、Reflect、Symbol、Promise的问题

    Babel默认只转换新的JavaScript句法(syntax),而不转换新的API,比如Iterator.Generator.Set.Maps.Proxy.Reflect.Symbol.Promis ...

  5. CSS3一些特殊属性

    (一)-webkit-tap-highlight-color         这个属性只用于iOS (iPhone和iPad).当你点击一个链接或者通过Javascript定义的可点击元素的时候,它就 ...

  6. Java之 jstl 自定义标签的方法

    1.写一个Java类 我的路径是写再tag包中的一个 HelloTag类 package tag; import java.io.IOException; import javax.servlet.j ...

  7. 常见Linux的发行版有哪些?并描述不同发行版之间的联系与区别。

    一.按系列罗列linux的发行版,并描述不同发行版之间的联系和区别 Linux发行版=Linux内核+商业软件 linux的发行版: RedHat.Fedora.suse.红旗.debian.Ubun ...

  8. Redhat 6.4 linux系统不重启识别热添加的硬盘方法

    1.1    选择虚拟机添加一块硬盘 1.2    查看系统当前磁盘信息 [root@zhongyi-test ~]# ls -l /dev/sd* brw-rw----. 1 root disk 8 ...

  9. 理解volatile与synchronized

    用 volatile 修饰的变量可以保证线程的"可见性",也就是,任何线程修改了这个 volatile 修饰的值都会通知其他线程来主缓存中重新读取值. 下面通过例子加以说明: pu ...

  10. 【LeetCode #179】Largest Number 解题报告

    原题链接:Largest Number 题目描述: Given a list of non negative integers, arrange them such that they form th ...