Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
 public void IssueDelayCall()
 {
     if (DelayCall != null)
     {
         DelayCall.Invoke();
     }
 }
Exemplo n.º 3
0
    /// <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;
    }
Exemplo n.º 4
0
        // 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;
        }
Exemplo n.º 5
0
    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);
                //}
            }
        }
    }
Exemplo n.º 6
0
 public void Shake()
 {
     triggered = true;
     shake     = new Shake();
     shake.Init(this.transform, .7f, 10, 1f, 10f);
     delayCall = new DelayCall();
     delayCall.Init(.7f, Expolde);
 }
Exemplo n.º 7
0
 private void MakePlayerFaster()
 {
     if (player.forwardSpeed < maxPlayerSpeed)
     {
         player.forwardSpeed += speedIncreaseSteps;
         DelayCall.Call(this, MakePlayerFaster, 5);
     }
 }
Exemplo n.º 8
0
    public void AddDelayCall(float time, Action action)
    {
        DelayCall d = new DelayCall()
        {
            time = time + Time.time, action = action
        };

        delayCall.Add(d);
    }
Exemplo n.º 9
0
    //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);
    }
Exemplo n.º 10
0
 public void IssueDelayCall(bool clear)
 {
     if (DelayCall != null)
     {
         DelayCall.Invoke();
         if (clear)
         {
             DelayCall = null;
         }
     }
 }
Exemplo n.º 11
0
 public void OnHitPiece(BoardDirection direction, float time)
 {
     if (clock != null)
     {
         clock.OnHitClock(direction);
         if (clock.triggered)
         {
             delayCall = new DelayCall();
             delayCall.Init(time, OnClock);
         }
     }
 }
Exemplo n.º 12
0
 public override void Dead()
 {
     base.Dead();
     isDead = true;
     DestoryGroup(false);
     StopShake();
     SetState(PieceState.Normal);
     ClearChildren();
     if (delayCall != null)
     {
         delayCall.Stop();
         delayCall = null;
     }
 }
Exemplo n.º 13
0
 public void Push(DelayCall delayCall)
 {
     mDelayCalls.Enqueue(delayCall);
 }
Exemplo n.º 14
0
 private void Awake()
 {
     DelayCall.Call(this, MakePlayerFaster, 5);
 }