public static CallTimeObj AddTime(DelayCall call, float delayTime, MonoBehaviour mn = null, bool isUnique = false) { if (!inited) { inited = true; UpdateManager.AddCoroutine(null, 0, OnUpdate); } if (isUnique) { for (int i = 0; i < calltimes.size; i++) { CallTimeObj call2 = calltimes[i]; if (call2.mn == mn && call2.call == call) { return(call2); } } } var callobj = new CallTimeObj(); callobj.call = call; callobj.isMN = (mn != null); callobj.mn = mn; callobj.time = Time.realtimeSinceStartup + delayTime; calltimes.Add(callobj); return(callobj); }
public void IssueDelayCall() { if (DelayCall != null) { DelayCall.Invoke(); } }
/// <summary> /// 添加延迟执行按照帧数 call, delayframes, mn and isUnique. /// </summary> /// <param name='call'> /// 方法. /// </param> /// <param name='delayframes'> /// 延迟帧数. /// </param> /// <param name='mn'> /// 承载回掉函数的实例是否存在的判断. /// </param> /// <param name='isUnique'> /// 是否是唯一的方法. /// </param> public static CallObj Add(DelayCall call, int delayframes, MonoBehaviour mn = null, bool isUnique = false) { if (!inited) { inited = true; UpdateManager.AddCoroutine(null, 0, OnUpdate); } if (isUnique) { for (int i = 0; i < calls.size; i++) { CallObj call2 = calls[i]; if (call2.mn == mn && call2.call == call) { return(call2); } } } var callobj = new CallObj(); callobj.call = call; callobj.isMN = (mn != null); callobj.mn = mn; callobj.frame = counter + delayframes; calls.Add(callobj); return(callobj); //calls.Add(Time.frameCount+delayframes,call); //calls[Time.frameCount+delayframes]+=call; }
// Player Chararcter public void Refresh() { // deactivate collider int playerLayer = LayerMask.NameToLayer("Player"); int obstacleLayer = LayerMask.NameToLayer("Obstacle"); ignoreCollision = true; Physics.IgnoreLayerCollision(playerLayer, obstacleLayer); Color c = material.GetColor("_Color"); c.a = 0.1f; c.b = 0.5f; material.SetColor("_Color", c); c.a = 1; c.b = 0; float delayTime = 2 / forwardSpeed; // after one second set collider DelayCall.Call(this, () => { Debug.Log("Set collision active"); ignoreCollision = false; Physics.IgnoreLayerCollision(playerLayer, obstacleLayer, false); material.SetColor("_Color", c); }, delayTime); outOfControl = false; }
void Update() { if (delayCall.Count > 0) { for (int i = delayCall.Count - 1; i >= 0; i--) { //if(delayCall[i].enable) //{ if (Time.time > delayCall[i].time) { DelayCall d = delayCall[i]; delayCall.RemoveAt(i); d.action(); //if (d.data == null) // d.luaCallback.call(); //else // d.luaCallback.call(d.data); //d.luaCallback = null; } //} //else //{ // delayCall.RemoveAt(i); //} } } }
public void Shake() { triggered = true; shake = new Shake(); shake.Init(this.transform, .7f, 10, 1f, 10f); delayCall = new DelayCall(); delayCall.Init(.7f, Expolde); }
private void MakePlayerFaster() { if (player.forwardSpeed < maxPlayerSpeed) { player.forwardSpeed += speedIncreaseSteps; DelayCall.Call(this, MakePlayerFaster, 5); } }
public void AddDelayCall(float time, Action action) { DelayCall d = new DelayCall() { time = time + Time.time, action = action }; delayCall.Add(d); }
//public void AddDelayCall(float time, LuaFunction timeCallback) //{ // DelayCall d = new DelayCall() { time = time + Time.time, luaCallback = timeCallback, data = null }; // delayCall.Add(d); //} //public void AddKeyDelayCall(float time, LuaFunction timeCallback,string key) //{ // DelayCall d = new DelayCall() { time = time + Time.time, luaCallback = timeCallback, data = null , key = key }; // delayCall.Add(d); //} //public void RemoveDelayCall(string key) //{ // for (int i = delayCall.Count - 1; i >= 0; i--) // { // if (key == delayCall[i].key) // { // delayCall.RemoveAt(i); // } // } //} public void AddCallFromAsync(Action action) { //Debug.Log("AddCallFromAsync ************** "); DelayCall d = new DelayCall() { time = 0, action = action }; delayCall.Add(d); }
public void IssueDelayCall(bool clear) { if (DelayCall != null) { DelayCall.Invoke(); if (clear) { DelayCall = null; } } }
public void OnHitPiece(BoardDirection direction, float time) { if (clock != null) { clock.OnHitClock(direction); if (clock.triggered) { delayCall = new DelayCall(); delayCall.Init(time, OnClock); } } }
public override void Dead() { base.Dead(); isDead = true; DestoryGroup(false); StopShake(); SetState(PieceState.Normal); ClearChildren(); if (delayCall != null) { delayCall.Stop(); delayCall = null; } }
public void Push(DelayCall delayCall) { mDelayCalls.Enqueue(delayCall); }
private void Awake() { DelayCall.Call(this, MakePlayerFaster, 5); }