Пример #1
0
    //Update is called once per frame
    void Update()
    {
        if (update)
        {
            update = false;
            //UpdateChunk();
            //RenderMesh(thisMeshData);
            //UpdateChunk();
            EZThread.ExecuteInBackground(UpdateChunk, RenderMesh);
        }

        if (generateData)
        {
            generateData = false;
            GenerateChunkData();
            //EZThread.ExecuteInBackground(GenerateChunkData);
        }

        if (renderMesh)
        {
            renderMesh = false;
            //UpdateChunk();
            RenderMesh(thisMeshData);
            //EZThread.ExecuteInBackground(UpdateChunk, RenderMesh);
        }
    }
Пример #2
0
 void FixedUpdate()
 {
     if (isRunning)
     {
         currentNetworkFrame++;
         EZThread.ExecuteInBackground(DoFixedUpdate, UpdateUnitFrameInfo);
     }
 }
Пример #3
0
    public override void TurnUpdate()
    {
        if (this.PlayersUnits.Count != 0 && !base.updateboard && !base.OnMovement && !computing)
        {
            computing   = true;
            currentmove = null;
            EZThread.ExecuteInBackground(moveMaker.MakeMove, ComputeTheMove);
            Debug.Log("[AI] thinking.. computing:" + computing + " updateboard:" + base.updateboard);
        }

        if (!computing && base.updateboard)
        {
            Debug.Log("[AI] performing move! computing:" + computing + " updateboard:" + base.updateboard);
            UpdateBoard(currentmove);
        }
    }
Пример #4
0
        private bool StartConnectToServer(string _ip, int _port, bool _takon)
        {
            try
            {
                if (s_datatype == SocketDataType.Json && ReceiveMessageEvent == null)
                {
                    Debug.Log("没有注册receiveServerEvent事件");
                }

                if (s_datatype == SocketDataType.Json && ReceiveBitEvent == null)
                {
                    Debug.Log("没有注册receiveServerEventbit事件");
                }
                ip   = _ip;
                port = _port;

                //tcpClient = new TcpClient(ip, port);
                tcpClient = new TcpClient();
                //  tcpc.ExclusiveAddressUse = false;

                try
                {
                    tcpClient.Connect(ip, port);
                }
                catch
                {
                    return(false);
                }

                IsOnline = true;
                isok     = true;

                timeout = DateTime.Now;
                if (!isReceives)
                {
                    isReceives = true;



                    /*开始执行线程开始*/
                    // myThreadScheduler = Loom.CreateThreadPoolScheduler();

                    //--------------- Ending Single threaded routine 单线程程序结束--------------------
                    // threadA = Loom.StartSingleThread(ReceivesThread, null, System.Threading.ThreadPriority.Normal, true);
                    //--------------- Ending Single threaded routine 单线程程序结束--------------------

                    //--------------- Continues Single threaded routine 在单线程的程序--------------------
                    // threadB = Loom.StartSingleThread(CheckToken_UpdateListDataThread, System.Threading.ThreadPriority.Normal, true);
                    //--------------- Continues Single threaded routine  在单线程的程序--------------------
                    /*开始执行线程结束*/
                    /*改用新的EZThreading插件的方法开始*/
                    EZThread.ExecuteInBackground(() => ReceivesThread());

                    EZThread.ExecuteInBackground(() => CheckToken_UpdateListDataThread());


                    /*改用新的EZTheading插件的方法结束*/
                }
                int ss = 0;

                if (!_takon)
                {
                    return(true);
                }

                while (tokan == null)
                {
                    System.Threading.Thread.Sleep(1000);
                    // Loom.WaitForNextFrame(10);
                    //Loom.WaitForSeconds(1);
                    ss++;
                    if (ss > 10)
                    {
                        return(false);
                    }
                }

                if (ConnectOkEvent != null)
                {
                    ConnectOkEvent();
                }

                return(true);
            }
            catch (Exception e)
            {
                IsOnline = false;
                if (ErrorMessageEvent != null)
                {
                    ErrorMessageEvent(1, e.Message);
                }
                return(false);
            }
        }