Esempio n. 1
0
        static void Check(Tree4 tree)
        {
            if (!tree.collisonInfo.active)
            {
                return;
            }

            int count = tree.objs.Count;
            var objs  = tree.objs;

            for (int i = 0; i < count; i++)
            {
                for (int j = i + 1; j < count; j++)
                {
                    if (objs[i] != objs[j] && (objs[i].rigibody.useCheck || objs[j].rigibody.useCheck))
                    {
                        if (ShapPhysics.Check(objs[i].Shap, objs[j].Shap))
                        {
                            objs[i].rigibody.AddCollistionData(objs[j]);
                            objs[j].rigibody.AddCollistionData(objs[i]);
                        }
                    }
                }
            }
            //lastCheckTime = InputCenter.Time;
            tree.collisonInfo.active = false;
        }
Esempio n. 2
0
        public List <NetData> CheckShap(ShapBase shap)
        {
            List <NetData> objs     = new List <NetData>();
            var            treeList = GetInTress(shap);

            foreach (var tree in treeList)
            {
                for (int i = 0; i < tree.objs.Count; i++)
                {
                    if (ShapPhysics.Check(shap, tree.objs[i].Shap))
                    {
                        objs.Add(tree.objs[i]);
                    }
                }
            }
            return(objs);
        }
Esempio n. 3
0
        /// <summary>
        /// 碰撞检测
        /// </summary>
        /// <param name="tree">检测的节点</param>
        /// <returns>碰撞的对象</returns>
        public Dictionary <NetData, List <NetData> > Check(Tree4 tree)
        {
            if (!active && InputCenter.Time <= lastCheckTime)
            {
                return(checkList);
            }
            checkList.Clear();
            int count = tree.objs.Count;
            var objs  = tree.objs;

            for (int i = 0; i < count; i++)
            {
                for (int j = i + 1; j < count; j++)
                {
                    if (objs[i] != objs[j] && ShapPhysics.Check(objs[i], objs[j]))
                    {
                        if (checkList.ContainsKey(objs[i]))
                        {
                            checkList[objs[i]].Add(objs[j]);
                        }
                        else
                        {
                            checkList.Add(objs[i], new List <NetData>());
                            checkList[objs[i]].Add(objs[j]);
                        }
                        if (checkList.ContainsKey(objs[j]))
                        {
                            checkList[objs[j]].Add(objs[i]);
                        }
                        else
                        {
                            checkList.Add(objs[j], new List <NetData>());
                            checkList[objs[j]].Add(objs[i]);
                        }
                    }
                }
            }
            lastCheckTime = InputCenter.Time;
            active        = false;
            return(checkList);
        }
Esempio n. 4
0
        public List <NetData> CheckShap(ShapBase shap)
        {
            List <NetData> objs     = new List <NetData>();
            var            treeList = GetInTress(shap);

            foreach (var tree in treeList)
            {
                for (int i = 0; i < tree.objs.Count; i++)
                {
                    if (!tree.objs[i].isTrigger && ShapPhysics.Check(shap, tree.objs[i].Shap))
                    {
                        //当物体处于四叉树交界处 可能会添加多次
                        if (!objs.Contains(tree.objs[i]))
                        {
                            objs.Add(tree.objs[i]);
                        }
                    }
                }
            }
            return(objs);
        }
 protected void ConnectCallback(IAsyncResult ar)
 {
     ServerCon.socket.BeginReceive(ServerCon.readBuff, 0, ServerCon.BuffRemain, SocketFlags.None, ReceiveCallBack, ServerCon);
     inputCenter = new InputCenter();
     inputCenter.Init(this, maxUserCount);
     objectManager = new NetObjectManager(this);
     physics       = new ShapPhysics();
     physics.Init();
     random       = new IDG.Random(20190220);
     gameManagers = new List <IGameManager>();
     coroutine    = new CoroutineManager();
     gameManagers.AddRange(managers);
     gameManagers.Add(new TeamManager());
     gameManagers.Sort((a, b) => { if (a.InitLayer > b.InitLayer)
                                   {
                                       return(1);
                                   }
                                   else
                                   {
                                       return(-1);
                                   } });
 }
Esempio n. 6
0
        public static void Check(Tree4 tree)
        {
            if (!tree.collisonInfo.active)
            {
                return;
            }

            int count = tree.objs.Count;
            var objs  = tree.objs;

            for (int i = 0; i < count; i++)
            {
                for (int j = i + 1; j < count; j++)
                {
                    if (objs[i] != objs[j] && ShapPhysics.Check(objs[i], objs[j]))
                    {
                        objs[i].physics.collisonDatas.Add(objs[j]);
                        objs[j].physics.collisonDatas.Add(objs[i]);
                    }
                }
            }
            //lastCheckTime = InputCenter.Time;
            tree.collisonInfo.active = false;
        }