Esempio n. 1
0
        public void TestWaitFrames()
        {
            var gobj = new GameObject();
            var test = gobj.AddComponent<TestCoroutine>();

            test.StartCoroutine(test.FrameWaiter());
            Assert.IsFalse(test.HasWaitedForFrames);
            //one extra Run is required as it's assumed that this would be the same frame that the coroutine would be started in.
            test.RunCoroutines();
            Assert.IsFalse(test.HasWaitedForFrames);
            
            //now these are real frames.
            test.RunCoroutines();
            Assert.IsFalse(test.HasWaitedForFrames);
            test.RunCoroutines();
            Assert.IsFalse(test.HasWaitedForFrames);
            test.RunCoroutines();
            Assert.IsTrue(test.HasWaitedForFrames);
        }
Esempio n. 2
0
        public void CoroutineTest()
        {
            var gobj = new GameObject();
            var test = gobj.AddComponent<TestCoroutine>();

            test.StartCoroutine(test.DoThing());
            //one extra Run is required as it's assumed that this would be the same frame that the coroutine would be started in.
            test.RunCoroutines();
            Assert.AreEqual(test.OuterCount, 1);
            Assert.AreEqual(test.InnerCount, 0);
            test.RunCoroutines();
            Assert.AreEqual(test.OuterCount, 1);
            Assert.AreEqual(test.InnerCount, 1);
            test.RunCoroutines();
            Assert.AreEqual(test.OuterCount, 1);
            Assert.AreEqual(test.InnerCount, 2);
            test.RunCoroutines();
            Assert.AreEqual(test.OuterCount, 2);
            Assert.AreEqual(test.InnerCount, 2);

            test.StartCoroutine(test.MoreEnumerator());
            test.RunCoroutines();
            Assert.AreEqual(test.MoreEnumCount, 0);
            test.RunCoroutines();
            Assert.AreEqual(test.MoreEnumCount, 1);
            test.RunCoroutines();
            Assert.AreEqual(test.MoreEnumCount, 2);
            test.RunCoroutines();
            Assert.AreEqual(test.MoreEnumCount, 3);
            test.RunCoroutines();
            Assert.AreEqual(test.MoreEnumCount, 4);
            test.RunCoroutines();
            Assert.AreEqual(test.MoreEnumCount, 5);
            test.RunCoroutines();
            Assert.AreEqual(test.MoreEnumCount, 5);
        }
Esempio n. 3
0
        /// <summary>
        /// Create a static game object that can receive rpc's in the scene. 
        /// The client should have a similar object in the scene matching the room with the same id
        /// </summary>
        /// <param name="sceneObject"></param>
        /// <param name="gobj"></param>
        public void NetworkedRoomObject(NetworkedSceneObject sceneObject, GameObject gobj)
        {
            if (gobj.Room != this && gobj.Room != null)
            {
                Debug.LogError("cannot move the object to the room. it must have no room or be in this one.");
                return;
            }

            var sceneView = gobj.AddComponent<NetworkedSceneObjectView>();

            gobj.Room = this;

            sceneView.room = this;
            sceneView.NetworkID = sceneObject.NetworkID;

            roomObjects[sceneObject.NetworkID] = sceneView;

            //sceneObject.OnFinishedCreation();
        }