public void AddCollistionData(NetData other)
 {
     if (!collisonDatas.Contains(other))
     {
         collisonDatas.Add(other);
     }
 }
Exemple #2
0
 /// <summary>
 /// 向子节点添加对象
 /// </summary>
 /// <param name="obj">添加的对象</param>
 public void Add(NetData obj)
 {
     for (int i = 0; i < 4; i++)
     {
         trees[i].Add(obj);
     }
 }
Exemple #3
0
 public static void Move(NetData obj)
 {
     Tree4[] trees = obj.trees.ToArray();
     foreach (var item in trees)
     {
         item.SubMove(obj);
     }
 }
Exemple #4
0
 public static void SetActive(NetData obj)
 {
     foreach (var item in obj.trees)
     {
         item.collisonInfo.active = true;
         activeTreeList.Add(item);
     }
 }
Exemple #5
0
        public static GameObject Instantiate <T>(NetData data) where T : NetData, new()
        {
            GameObject obj = GameObject.Instantiate(GetPrefab(data), data.transform.Position.ToVector3(), data.transform.Rotation.ToUnityRotation());

            obj.GetComponent <NetObjectView <T> >().data = data;
            data.view = obj.GetComponent <NetObjectView <T> >();
            return(obj);
        }
Exemple #6
0
 public static void Remove(NetData obj)
 {
     Tree4[] trees = obj.trees.ToArray();
     foreach (var item in trees)
     {
         item.DisLink(obj);
     }
 }
Exemple #7
0
        /// <summary>
        /// 添加对象
        /// </summary>
        /// <param name="obj">游戏对象</param>
        public void Add(NetData obj)
        {
            shaps.Add(obj);

            if (!tree.Add(obj))
            {
                UnityEngine.Debug.LogWarning("四叉树添加物体失败" + obj.name);
            }
        }
Exemple #8
0
 public void SubMove(NetData obj)
 {
     if (!IsIn(obj.Shap))
     {
         DisLink(obj);
     }
     brother.Add(obj);
     //root.Add(obj);
 }
Exemple #9
0
 /// <summary>
 /// 向邻居节点添加对象
 /// </summary>
 /// <param name="obj">移动的对象</param>
 public void Add(NetData obj)
 {
     for (int i = 0; i < 4; i++)
     {
         if (brothers[i] != null)
         {
             brothers[i].Add(obj);
         }
     }
 }
        public GameObject GetPrefab(NetData data)
        {
            var prefab = Resources.Load(data.PrefabPath()) as GameObject;

            if (prefab == null)
            {
                Debug.LogError("{" + data.PrefabPath() + "}is Null");
            }
            return(prefab);
        }
Exemple #11
0
 public bool IsIn(NetData obj)
 {
     if (((border.center.x - obj.transform.Position.x).Abs() <= (border.size + obj.Width / 2))
         &&
         ((border.center.y - obj.transform.Position.y).Abs() <= (border.size + obj.Height / 2))
         )
     {
         return(true);
     }
     return(false);
 }
Exemple #12
0
 public static bool BoxCheck(NetData objA, NetData objB)
 {
     if (FixedNumber.Abs((objA.transform.Position.x - objB.transform.Position.x)) < (objA.Width + objB.Width) / 2
         &&
         FixedNumber.Abs((objA.transform.Position.y - objB.transform.Position.y)) < (objA.Height + objB.Height) / 2
         )
     {
         return(true);
     }
     return(false);
 }
Exemple #13
0
 private void DisLink(NetData obj)
 {
     if (objs.Contains(obj))
     {
         objs.Remove(obj);
     }
     if (obj.trees.Contains(this))
     {
         obj.trees.Remove(this);
     }
 }
        public bool CheckCollision(NetData a)
        {
            foreach (var item in collisonDatas)
            {
                if (!item.isTrigger)
                {
                    return(true);
                }
            }

            return(false);
        }
        public GameObject Instantiate(NetData data)
        {
            GameObject obj = GameObject.Instantiate(GetPrefab(data), data.transform.Position.ToVector3(), data.transform.Rotation.ToUnityRotation());

            obj.transform.parent     = (client.unityClient as MonoBehaviour).gameObject.transform;
            obj.transform.localScale = data.transform.Scale.ToVector3(1);
            var view = obj.GetComponent <View>();

            view.netData = data;
            data.view    = view;
            return(obj);
        }
Exemple #16
0
        /// <summary>
        /// 向子节点添加对象
        /// </summary>
        /// <param name="obj">添加的对象</param>
        public bool Add(NetData obj)
        {
            bool flag = false;

            for (int i = 0; i < 4; i++)
            {
                if (trees[i].Add(obj))
                {
                    flag = true;
                }
            }
            return(flag);
        }
Exemple #17
0
 public void SetActive(NetData obj)
 {
     foreach (var item in obj.trees)
     {
         item.collisonInfo.active = true;
         if (!activeTreeList.Contains(item))
         {
             activeTreeList.Add(item);
         }
         else
         {
             // Debug.LogError("多余的激活树");
         }
     }
 }
Exemple #18
0
 public void Add(NetData obj)
 {
     if (!IsIn(obj))
     {
         return;
     }
     if (objs.Contains(obj))
     {
         return;
     }
     if (child == null)
     {
         Link(obj);
         if (objs.Count > SplitSize && depth <= MaxDepth)
         {
             Split();
         }
     }
     else
     {
         child.Add(obj);
     }
 }
Exemple #19
0
 public bool Add(NetData obj)
 {
     if (!IsIn(obj.Shap))
     {
         return(false);
     }
     if (objs.Contains(obj))
     {
         return(true);
     }
     if (child == null)
     {
         Link(obj);
         if (objs.Count > SplitSize && depth <= MaxDepth)
         {
             Split();
         }
         return(true);
     }
     else
     {
         return(child.Add(obj));
     }
 }
Exemple #20
0
 /// <summary>
 /// 添加对象
 /// </summary>
 /// <param name="obj">游戏对象</param>
 public void Add(NetData obj)
 {
     shaps.Add(obj);
     tree.Add(obj);
 }
Exemple #21
0
 /// <summary>
 /// 移除对象
 /// </summary>
 /// <param name="obj">游戏对象</param>
 public void Remove(NetData obj)
 {
     shaps.Remove(obj);
     Tree4.Remove(obj);
 }
Exemple #22
0
 public void Init(NetData data)
 {
     this.data = data;
 }
Exemple #23
0
 //GJK算法原理
 //两个物体进行明可夫斯基差操作 得到的新图形形状包含原点则这两个图形的是相交的
 /// <summary>
 /// 立即检测两个物体是否发生细节碰撞
 /// 先包围盒检测(粗略) 后GJK碰撞检测(细节)
 /// </summary>
 /// <param name="a">检测对象a</param>
 /// <param name="b">检测对象b</param>
 /// <returns>是否碰撞</returns>
 public static bool Check(NetData a, NetData b)
 {
     return(Tree4.BoxCheck(a, b) && GJKCheck(a.Shap, b.Shap));//;// xB&&yB;
 }
Exemple #24
0
 public virtual void OnPhysicsCheckExit(NetData other)
 {
     // UnityEngine.Debug.Log("Exit触发");
 }
Exemple #25
0
 public virtual void OnPhysicsCheckEnter(NetData other)
 {
 }
Exemple #26
0
 public virtual void OnPhysicsCheckStay(NetData other)
 {
     // UnityEngine.Debug.Log("Stay触发");
 }
 public void InitNetData(NetData data)
 {
     this.netData = data;
     Init();
 }
Exemple #28
0
 public static GameObject GetPrefab(NetData data)
 {
     return(Resources.Load(data.PrefabPath()) as GameObject);
 }
Exemple #29
0
 private void Link(NetData obj)
 {
     objs.Add(obj);
     obj.trees.Add(this);
 }