예제 #1
0
 public void AddCollistionData(NetData other)
 {
     if (!collisonDatas.Contains(other))
     {
         collisonDatas.Add(other);
     }
 }
예제 #2
0
 /// <summary>
 /// 向子节点添加对象
 /// </summary>
 /// <param name="obj">添加的对象</param>
 public void Add(NetData obj)
 {
     for (int i = 0; i < 4; i++)
     {
         trees[i].Add(obj);
     }
 }
예제 #3
0
 public static void Move(NetData obj)
 {
     Tree4[] trees = obj.trees.ToArray();
     foreach (var item in trees)
     {
         item.SubMove(obj);
     }
 }
예제 #4
0
 public static void SetActive(NetData obj)
 {
     foreach (var item in obj.trees)
     {
         item.collisonInfo.active = true;
         activeTreeList.Add(item);
     }
 }
예제 #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);
        }
예제 #6
0
 public static void Remove(NetData obj)
 {
     Tree4[] trees = obj.trees.ToArray();
     foreach (var item in trees)
     {
         item.DisLink(obj);
     }
 }
예제 #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);
            }
        }
예제 #8
0
 public void SubMove(NetData obj)
 {
     if (!IsIn(obj.Shap))
     {
         DisLink(obj);
     }
     brother.Add(obj);
     //root.Add(obj);
 }
예제 #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);
         }
     }
 }
예제 #10
0
        public GameObject GetPrefab(NetData data)
        {
            var prefab = Resources.Load(data.PrefabPath()) as GameObject;

            if (prefab == null)
            {
                Debug.LogError("{" + data.PrefabPath() + "}is Null");
            }
            return(prefab);
        }
예제 #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);
 }
예제 #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);
 }
예제 #13
0
 private void DisLink(NetData obj)
 {
     if (objs.Contains(obj))
     {
         objs.Remove(obj);
     }
     if (obj.trees.Contains(this))
     {
         obj.trees.Remove(this);
     }
 }
예제 #14
0
        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);
        }
예제 #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);
        }
예제 #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("多余的激活树");
         }
     }
 }
예제 #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);
     }
 }
예제 #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));
     }
 }
예제 #20
0
 /// <summary>
 /// 添加对象
 /// </summary>
 /// <param name="obj">游戏对象</param>
 public void Add(NetData obj)
 {
     shaps.Add(obj);
     tree.Add(obj);
 }
예제 #21
0
 /// <summary>
 /// 移除对象
 /// </summary>
 /// <param name="obj">游戏对象</param>
 public void Remove(NetData obj)
 {
     shaps.Remove(obj);
     Tree4.Remove(obj);
 }
예제 #22
0
 public void Init(NetData data)
 {
     this.data = data;
 }
예제 #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;
 }
예제 #24
0
 public virtual void OnPhysicsCheckExit(NetData other)
 {
     // UnityEngine.Debug.Log("Exit触发");
 }
예제 #25
0
 public virtual void OnPhysicsCheckEnter(NetData other)
 {
 }
예제 #26
0
 public virtual void OnPhysicsCheckStay(NetData other)
 {
     // UnityEngine.Debug.Log("Stay触发");
 }
예제 #27
0
 public void InitNetData(NetData data)
 {
     this.netData = data;
     Init();
 }
예제 #28
0
 public static GameObject GetPrefab(NetData data)
 {
     return(Resources.Load(data.PrefabPath()) as GameObject);
 }
예제 #29
0
 private void Link(NetData obj)
 {
     objs.Add(obj);
     obj.trees.Add(this);
 }