示例#1
0
            public void Run()
            {
#if NET_4_6 || NET_STANDARD_2_0
                runFlag.Wait();
                runFlag.Reset();
#else
                runFlag.WaitOne();
#endif

                while (!terminate)
                {
                    try
                    {
                        List <Agent> agents = simulator.GetAgents();
                        if (task == 0)
                        {
                            for (int i = start; i < end; i++)
                            {
                                agents[i].CalculateNeighbours();
                                agents[i].CalculateVelocity(context);
                            }
                        }
                        else if (task == 1)
                        {
                            for (int i = start; i < end; i++)
                            {
                                agents[i].BufferSwitch();
                            }
                        }
                        else if (task == 2)
                        {
                            simulator.BuildQuadtree();
                        }
                        else
                        {
                            Debug.LogError("Invalid Task Number: " + task);
                            throw new System.Exception("Invalid Task Number: " + task);
                        }
                    }
                    catch (System.Exception e)
                    {
                        Debug.LogError(e);
                    }
                    waitFlag.Set();
#if NET_4_6 || NET_STANDARD_2_0
                    runFlag.Wait();
                    runFlag.Reset();
#else
                    runFlag.WaitOne();
#endif
                }
            }
示例#2
0
            public void Run()
            {
                runFlag.WaitOne();

                while (!terminate)
                {
                    try {
                        List <Agent> agents = simulator.GetAgents();
                        if (task == 0)
                        {
                            for (int i = start; i < end; i++)
                            {
                                agents[i].CalculateNeighbours();
                                agents[i].CalculateVelocity(context);
                            }
                        }
                        else if (task == 1)
                        {
                            for (int i = start; i < end; i++)
                            {
                                agents[i].Update();
                                agents[i].BufferSwitch();
                            }
                        }
                        else if (task == 2)
                        {
                            simulator.BuildQuadtree();

                            /*} else if (task == 2) {
                             *  for (int i=start;i<end;i++) {
                             *      agents[i].BufferSwitch ();
                             *  }*/
                        }
                        else
                        {
                            EB.Debug.LogError("Invalid Task Number: {0}", task);
                            throw new System.Exception("Invalid Task Number: " + task);
                        }
                    } catch (System.Exception e) {
                        Debug.LogError(e);
                    }
                    waitFlag.Set();
                    runFlag.WaitOne();
                }
            }