private void Start()
        {
            this.Sequence()
            .Delay(1.0f)
            .Event(() => Log.I("Sequence1 延时了 1s"))
            .Begin()
            .DisposeWhenFinished()                     // Default is DisposeWhenGameObjDestroyed
            .OnDisposed(() => { Log.I("Sequence1 destroyed"); });

            var sequenceNode2 = SequenceNode.Allocate(DelayAction.Allocate(1.5f));

            sequenceNode2.Append(EventAction.Allocate(() => Log.I("Sequence2 延时 1.5s")));
            sequenceNode2.Append(DelayAction.Allocate(0.5f));
            sequenceNode2.Append(EventAction.Allocate(() => Log.I("Sequence2 延时 2.0s")));

            this.ExecuteNode(sequenceNode2);

            /* 这种方式需要自己手动进行销毁
             * sequenceNode2.Dispose();
             * sequenceNode2 = null;
             */

            // 或者 OnDestroy 触发时进行销毁
            sequenceNode2.AddTo(this);
        }
Exemple #2
0
        private IEnumerator Start()
        {
//			this.Sequence().Delay();

            var delayNode = new DelayNode(1.0f);

            delayNode.OnBeganCallback = () => Log.I("first began");
            delayNode.OnEndedCallback = () => Log.I("first ended");

            var delayNode2 = new DelayNode(1.0f);

            delayNode2.OnBeganCallback = () => Log.I("second began");
            delayNode2.OnEndedCallback = () => Log.I("second ended");

            yield return(SequenceNode.Allocate(delayNode, delayNode2).Execute());

            yield return(QWait.ForSeconds(1.0f));

            Log.I("from seconds");

            mHostIp = NetworkUtil.GetAddressIP();

            mSocketServer = FlexiSocket.Create(1366, Protocols.BodyLengthPrefix, false);
            mSocketServer.ClientConnected += delegate(ISocketClientToken client)
            {
                Log.I("OnClientConnected ID:{0} Count:{1}", client.ID, mSocketServer.Clients.Count);
            };
            mSocketServer.SentToClient += delegate(bool success, ISocketClientToken client)
            {
                if (success)
                {
                }
            };

            mSocketServer.ReceivedFromClient += delegate(ISocketClientToken client, byte[] message)
            {
                SocketMsg msg = SerializeHelper.FromProtoBuff <SocketMsg>(message);
                mMessage = msg.msgId + ":" + msg.ToEventID;
                if (!string.IsNullOrEmpty(msg.Msg))
                {
                    mMessage += ":" + msg.Msg;
                }
                Log.I("OnReceivedFromClient:{0}", mMessage);
                mMsgQueue.Enqueue(msg);
            };

            mSocketServer.ClientDisconnected += delegate(ISocketClientToken client) {};
            mSocketServer.StartListen(10);

            yield return(0);
        }