c# 代码
enum myEnum
{
aa = 0,
bb,
cc,
}
public delegate void MyDelegate(myEnum _myEnum, params object[] _params);
public Dectionary<myEnum , MyDelegate> dicMyDelegate = new Dectionary<myEnum , MyDelegate>();
public void GameDelegate(myEnum _myEnum, MyDelegate _Func)
{
if(dicMyDelegate .ContainsKey(_myEnum))
{
MyDelegate Func;
dicMyDelegate.TryGetValue(_myEnum, out Func);
Func += _Func;
}
else
{
dicMyDelegate.Add(_myEnum, _Func);
}
}
public void GameCallBack(myEnum _myEnum)
{
if(!dicMyDelegate.ContainsKey(_myEnum)) return;
MyDelegate Func;
dicMyDelegate.TryGetValue(_myEnum, out Funk);
if(Func == null) return;
Func(_myEnum);
}
====================================================
cocos 创建者 TypeScript。我不知道....请。我现在在学习。
public delegate void MyDelegate(myEnum _myEnum, params object[] _params);
public Dectionary<myEnum , MyDelegate> dicMyDelegate = new Dectionary<myEnum , MyDelegate>();
很难用类型脚本替换上面的代码。
我整天都在网上搜索。
declare module "Delegate"
{
export function MyDelegate(_myEnum: myEnum , args: any[]) : void;
}
import {MyDelegate} from 'Delegate';