Ejemplo n.º 1
0
    private IEnumerator DelayHelper(DelayedFunc f, float p_delay)
    {
        //Debug.Log("Delay start");
        yield return(new WaitForSeconds(p_delay));

        f();
    }
Ejemplo n.º 2
0
 protected override void OnCollision(EntityId targetEntityId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal)
 {
     // Hit something, reset last event time.
     if(state == BoidState.Launched)
     {
         if(postFire == null)
             postFire = new DelayedFunc(OnStoppedMoving, 4000);
         else
             postFire.Reset();
     }
 }
Ejemplo n.º 3
0
        void OnStoppedMoving()
        {
            if(Launcher.Instance != null)
            {
                postFire = null;

                ReceiveUpdates = false;
                state = BoidState.Dead;

                Launcher.Instance.PostFire();
            }
        }
Ejemplo n.º 4
0
 protected override void OnCollision(EntityId targetEntityId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal)
 {
     // Hit something, reset last event time.
     if (state == BoidState.Launched)
     {
         if (postFire == null)
         {
             postFire = new DelayedFunc(OnStoppedMoving, 4000);
         }
         else
         {
             postFire.Reset();
         }
     }
 }
        public async Task RunWithoutParamTest()
        {
            var called = false;
            var sw     = new Stopwatch();

            Func <string> fun = new Func <string>(() =>
            {
                called = true;
                sw.Stop();
                return("Received!");
            });

            var delayedFunc = new DelayedFunc <string>(fun);

            sw.Start();
            var result = await delayedFunc.RunWithDelayAsync(2000);

            Assert.IsTrue(called);
            Assert.AreEqual("Received!", result);
            Assert.IsTrue(sw.Elapsed.TotalMilliseconds > 2000);
        }
Ejemplo n.º 6
0
 private IEnumerator DelayHelper(DelayedFunc f, float p_delay)
 {
     //Debug.Log("Delay start");
     yield return new WaitForSeconds(p_delay);
     f();
 }
Ejemplo n.º 7
0
 public void Delay(DelayedFunc f, float p_delay)
 {
     StartCoroutine(DelayHelper(f, p_delay));
 }
Ejemplo n.º 8
0
 public TestEntity()
 {
     delayedFunc = new DelayedFunc(MyDelayedFunc, 1337);
 }
Ejemplo n.º 9
0
 public TestEntity()
 {
     delayedFunc = new DelayedFunc(MyDelayedFunc, 1337);
 }
Ejemplo n.º 10
0
 public void Delay(DelayedFunc f, float p_delay)
 {
     StartCoroutine(DelayHelper(f, p_delay));
 }
Ejemplo n.º 11
0
    IEnumerator DelayFunc_(DelayedFunc func, float time)
    {
        yield return(new WaitForSeconds(time));

        func.Invoke();
    }
Ejemplo n.º 12
0
 public void DelayFunc(DelayedFunc func, float time)
 {
     StartCoroutine(DelayFunc_(func, time));
 }