Ejemplo n.º 1
0
 private void ActiveWindow(ChildIndex index)
 {
     if (!controllers.ContainsKey(index))
     {
         GameObject window = ResourceManager.Instance.LoadWindow(index.ToString());
         controllers.Add(index, window);
         window.transform.parent     = windowPanel.transform;
         window.transform.localScale = Vector3.one;
         window.SetActive(true);
     }
     foreach (ChildIndex key in controllers.Keys)
     {
         if (index == key)
         {
             controllers[key].transform.position = Vector3.zero;
             controllers[key].SetActive(true);
             lastPreviousWindowIndex = currentWindowIndex;
             currentWindowIndex      = index;
         }
         else
         {
             controllers[key].SetActive(false);
         }
     }
 }
Ejemplo n.º 2
0
    private void RemoveChildInternal(ChildIndex index, bool cleanup, bool updateNeighbours)
    {
        AssertNotDeleted();
        if (children == null)
        {
            throw new ArgumentException("The child at that index is already removed!", "index");
        }

        var indexInt = (int)index;

        if (children[indexInt] == null)
        {
            throw new ArgumentException("The child at that index is already removed!", "index");
        }

        childCount--;

        children[indexInt].SetDeleted(updateNeighbours);
        children[indexInt] = null;

        if (childCount != 0)
        {
            return;
        }

        children = null;

        if (cleanup && parent != null)
        {
            // no need to update parent's neighbours!
            parent.RemoveChildInternal(indexInParent, true, false);
        }
    }
Ejemplo n.º 3
0
    void SortDown(T item)
    {
        while (true)
        {
            ChildIndex childIndex      = GetChildIndex(item);
            int        leftChildIndex  = childIndex.left;
            int        rightChildIndex = childIndex.right;
            int        swapIndex       = 0;

            if (leftChildIndex < currentItemCount)
            {
                swapIndex = leftChildIndex;
                if (rightChildIndex < currentItemCount)
                {
                    if (items[leftChildIndex].CompareTo(items[rightChildIndex]) < 0)
                    {
                        swapIndex = rightChildIndex;
                    }
                }
                if (item.CompareTo(items[swapIndex]) < 0)
                {
                    Swap(item, items[swapIndex]);
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }
    }
Ejemplo n.º 4
0
 void resetLoginWindow()
 {
     needResetLogin                    = false;
     currentWindowIndex                = ChildIndex.NONE;
     lastPreviousWindowIndex           = ChildIndex.NONE;
     GuideManager.Instance.currentStep = GuideManager.GUIDE_STEP.NONE;
 }
Ejemplo n.º 5
0
	private void AddTransparentNode(ChildIndex childIndex) {
		if (childIndex != ChildIndex.Invalid) {
			NeighbourSide verticalSide, depthSide, horizontalSide;

			if (_sideTransparentCount == null)
			{
				_sideTransparentCount = new Dictionary<NeighbourSide, int>();
				for (var i = 0; i < 6; ++i)
				{
					var neighbourSide = (NeighbourSide)i;
					_sideTransparentCount[neighbourSide] = 0;
				}
			}

			GetNeighbourSides(childIndex, out verticalSide, out horizontalSide, out depthSide);

			_sideTransparentCount[verticalSide]++;
			_sideTransparentCount[depthSide]++;
			_sideTransparentCount[horizontalSide]++;
		} 

		if (parent != null && _transparentNodeCount == 0) {
			parent.AddTransparentNode(indexInParent);
		}

		_transparentNodeCount++;
	}
Ejemplo n.º 6
0
        public override int GetHashCode()
        {
            var hashCode = -1774268519;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(NodeTypeName);

            hashCode = hashCode * -1521134295 + ChildIndex.GetHashCode();
            return(hashCode);
        }
Ejemplo n.º 7
0
    protected static Bounds GetChildBoundsInternal(Bounds originalBounds, ChildIndex childIndex)
    {
        var childDirection = GetChildDirection(childIndex);

        var childSize = originalBounds.extents;

        var childBounds = new Bounds(originalBounds.center + Vector3.Scale(childSize, childDirection * 0.5f), childSize);

        return(childBounds);
    }
Ejemplo n.º 8
0
        private Bounds CreateParentBounds(ChildIndex wantedIndexInParent)
        {
            var myBounds = GetBounds();

            var parentBoundsCenter = myBounds.center - Vector3.Scale(myBounds.extents, GetChildDirection(wantedIndexInParent));

            return(new Bounds(parentBoundsCenter, Vector3.zero)
            {
                extents = myBounds.extents * 2
            });
        }
Ejemplo n.º 9
0
    protected TNode SetChild(ChildIndex index, TNode child)
    {
        AssertNotDeleted();
#if USE_ALL_NODES
        child.AssertNotDeleted();
        _allNodes.Add(child.nodeCoords.GetHashCode(), child);
#endif

        children[(int)index] = child;
        return(child);
    }
Ejemplo n.º 10
0
 public GameObject getController(ChildIndex index)
 {
     if (controllers.ContainsKey(index))
     {
         return(controllers[index]);
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 11
0
 private void UnActiveWindow(ChildIndex index)
 {
     if (!controllers.ContainsKey(index))
     {
         return;
     }
     foreach (ChildIndex key in controllers.Keys)
     {
         if (index == key)
         {
             controllers[key].SetActive(false);
         }
     }
 }
Ejemplo n.º 12
0
	private void RemoveTransparentNode(ChildIndex childIndex) {
		if (childIndex != ChildIndex.Invalid) {
			NeighbourSide verticalSide, depthSide, horizontalSide;

			GetNeighbourSides(childIndex, out verticalSide, out horizontalSide, out depthSide);

			_sideTransparentCount[verticalSide]--;
			_sideTransparentCount[depthSide]--;
			_sideTransparentCount[horizontalSide]--;
		}

		_transparentNodeCount--;

		if (parent != null && _transparentNodeCount == 0) {
			parent.RemoveTransparentNode(indexInParent);
		}
	}
Ejemplo n.º 13
0
    public TNode GetChild(ChildIndex index)
    {
        AssertNotDeleted();

        var intIndex = (int)index;

        if (intIndex < 0 || intIndex > 7)
        {
            throw new ArgumentOutOfRangeException("index", "Invalid index specified for GetChild.");
        }

        if (children == null)
        {
            return(null);
        }

        return(children[(int)index]);
    }
Ejemplo n.º 14
0
                public override int GetHashCode()
                {
                    int hash = 1;

                    if (ChildIndex != 0)
                    {
                        hash ^= ChildIndex.GetHashCode();
                    }
                    if (Type.Length != 0)
                    {
                        hash ^= Type.GetHashCode();
                    }
                    if (Variable.Length != 0)
                    {
                        hash ^= Variable.GetHashCode();
                    }
                    return(hash);
                }
Ejemplo n.º 15
0
	private void RemoveSolidNode(ChildIndex childIndex, bool wasActuallySolid) {
		NeighbourSide verticalSide, depthSide, horizontalSide;

		if (childIndex != ChildIndex.Invalid) {
			GetNeighbourSides(childIndex, out verticalSide, out horizontalSide, out depthSide);

			_sideSolidCount[verticalSide]--;
			_sideSolidCount[depthSide]--;
			_sideSolidCount[horizontalSide]--;
		} else {
			GetNeighbourSides(indexInParent, out verticalSide, out horizontalSide, out depthSide);
		}

		_solidNodeCount--;

		if (parent != null && _solidNodeCount == 0) {
			parent.RemoveSolidNode(indexInParent, false);
		}

		if (!wasActuallySolid) {
			return;
		}

		VoxelNode actualNode;
		if (childIndex != ChildIndex.Invalid) {
			actualNode = GetChild(childIndex);

			_sideSolidChildren[verticalSide].Remove(actualNode);
			_sideSolidChildren[depthSide].Remove(actualNode);
			_sideSolidChildren[horizontalSide].Remove(actualNode);
		} else {
			actualNode = this;
		}

		var currentParent = parent;
		while (currentParent != null) {
			currentParent._sideSolidChildren[verticalSide].Remove(actualNode);
			currentParent._sideSolidChildren[depthSide].Remove(actualNode);
			currentParent._sideSolidChildren[horizontalSide].Remove(actualNode);

			currentParent = currentParent.parent;
		}
	}
Ejemplo n.º 16
0
    public static Vector3 GetChildDirection(ChildIndex childIndex)
    {
        Vector3 childDirection;

        switch (childIndex)
        {
        case ChildIndex.RightAboveBack:
            childDirection = RightAboveBack;
            break;

        case ChildIndex.LeftAboveBack:
            childDirection = LeftAboveBack;
            break;

        case ChildIndex.RightAboveForward:
            childDirection = RightAboveForward;
            break;

        case ChildIndex.LeftAboveForward:
            childDirection = LeftAboveForward;
            break;

        case ChildIndex.RightBelowBack:
            childDirection = RightBelowBack;
            break;

        case ChildIndex.LeftBelowBack:
            childDirection = LeftBelowBack;
            break;

        case ChildIndex.RightBelowForward:
            childDirection = RightBelowForward;
            break;

        case ChildIndex.LeftBelowForward:
            childDirection = LeftBelowForward;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
        return(childDirection);
    }
Ejemplo n.º 17
0
        private void ReplaceChild(ChildIndex childIndex, Node newChild)
        {
            Assert.AreEqual(newChild.bounds.extents * 2, bounds.extents);
            var childCoords = new Coords(new[] { OctreeChildCoords.FromIndex(childIndex) });
            var childBounds = GetChildBounds(childCoords);

            Assert.AreEqual(newChild.bounds.center, childBounds.center);

            if (children == null)
            {
                children = new Node[8];
            }
            else if (children[(int)childIndex] != null)
            {
                RemoveChild(childIndex);
            }

            childCount++;

            SetChild(childIndex, newChild);
        }
Ejemplo n.º 18
0
    public TNode AddChild(ChildIndex index)
    {
        if (index == ChildIndex.Invalid)
        {
            throw new ArgumentOutOfRangeException("index", "Cannot create a child at an invalid index.");
        }

        AssertNotDeleted();

        if (children == null)
        {
            children = new TNode[8];
        }

        if (GetChild(index) != null)
        {
            throw new ArgumentException("There is already a child at this index", "index");
        }

        childCount++;
        return(SetChild(index, ocTree.ConstructNode(GetChildBounds(index), (TNode)this, index)));
    }
Ejemplo n.º 19
0
    protected OctreeNodeBase(Bounds bounds, TNode parent, ChildIndex indexInParent, TTree ocTree)
    {
        deleted     = false;
        this.bounds = bounds;
        this.parent = parent;
        if (parent == null)
        {
#if USE_ALL_NODES
            // ReSharper disable once UseObjectOrCollectionInitializer
            _allNodes = new Dictionary <int, OctreeNode <T> >();
            _allNodes[nodeCoords.GetHashCode()] = this;
#endif
        }
        else
        {
#if USE_ALL_NODES
            _allNodes = _root._allNodes;
#endif
        }

        this.indexInParent = indexInParent;
        item        = default(TItem);
        this.ocTree = ocTree;
    }
Ejemplo n.º 20
0
 public Node(Bounds bounds, Node parent, ChildIndex indexInParent, SuperVoxelTree ocTree)
     : base(bounds, parent, indexInParent, ocTree)
 {
 }
Ejemplo n.º 21
0
	public VoxelNode(Bounds bounds, VoxelNode parent, ChildIndex indexInParent, VoxelTree ocTree)
		: base(bounds, parent, indexInParent, ocTree) {
		_coords = new Coords(parent._coords, OctreeChildCoords.FromIndex(indexInParent));
	}
Ejemplo n.º 22
0
    private void ActiveWindow(ChildIndex index)
    {
//      if(index == ChildIndex.GGLController)
//      {
//          MainController mc = mainController.GetComponent<MainController>();
//          mc.ShowGGL();
//      }
//      else
//      {
//          MainController mc = mainController.GetComponent<MainController>();
//          mc.ShowtopInfo();
//      }

        foreach (ChildIndex key in controllers.Keys)
        {
            if (index != key)
            {
                //controllers[key].SendMessage("CloseWindow", SendMessageOptions.DontRequireReceiver);
                controllers[key].SetActive(false);
            }
        }


        if (!controllers.ContainsKey(index))
        {
            GameObject window = ResourceManager.Instance.LoadWindow(index.ToString());
            controllers.Add(index, window);
            window.transform.parent        = windowPanel.transform;
            window.transform.localScale    = Vector3.one;
            window.transform.localPosition = Vector3.zero;
        }
//		else
//		{
//			controllers[index].SetActive(false);
//		}


        foreach (ChildIndex key in controllers.Keys)
        {
            if (index == key)
            {
                lastPreviousWindowIndex = currentWindowIndex;
                currentWindowIndex      = index;
                controllers[key].transform.localPosition = Vector3.zero;
                controllers[key].SetActive(true);
                break;
            }
        }
//        for (int i = 0; i < childControllers.Length; i++)
//        {
//            if (i == index)
//            {
//				//ËùÓеĶŒÒÔ0,0,0µãΪ»ù׌£¬²»ÓÃÿžö¶ŒœšÊý×é
////                childControllers[i].transform.localPosition = Vector3.zero;//arrayChildInpos[i];
//				childControllers[i].transform.position = Vector3.zero;
//				childControllers[i].SetActive(true);
//				lastPreviousWindowIndex = currentWindowIndex;
//				currentWindowIndex = i;
//            }
//            else
//            {
////				Debug.Log("set active false:"+i);
//                childControllers[i].SetActive(false);
//            }
//        }
    }
Ejemplo n.º 23
0
 INode INode.GetChild(ChildIndex childIndex)
 {
     return(GetChild(childIndex));
 }
Ejemplo n.º 24
0
	private void AddSolidNode(ChildIndex childIndex, bool actuallySolid) {
		NeighbourSide verticalSide, depthSide, horizontalSide;

		if (childIndex != ChildIndex.Invalid) {
			GetNeighbourSides(childIndex, out verticalSide, out horizontalSide, out depthSide);

			if (_sideSolidCount == null) {
				_sideSolidCount = new Dictionary<NeighbourSide, int>();
				for (var i = 0; i < 6; ++i) {
					var neighbourSide = (NeighbourSide) i;
					_sideSolidCount[neighbourSide] = 0;
				}
			}

			_sideSolidCount[verticalSide]++;
			_sideSolidCount[depthSide]++;
			_sideSolidCount[horizontalSide]++;
		} else {
			GetNeighbourSides(indexInParent, out verticalSide, out horizontalSide, out depthSide);
		}

		if (parent != null && _solidNodeCount == 0) {
			parent.AddSolidNode(indexInParent, false);
		}

		_solidNodeCount++;
		if (!actuallySolid) {
			return;
		}

		VoxelNode actualNode;
		if (childIndex != ChildIndex.Invalid) {
			actualNode = GetChild(childIndex);

			if (_sideSolidChildren == null) {
				_sideSolidChildren = new Dictionary<NeighbourSide, HashSet<VoxelNode>>();
				for (var i = 0; i < 6; ++i) {
					var neighbourSide = (NeighbourSide) i;
					_sideSolidChildren[neighbourSide] = new HashSet<VoxelNode>();
				}
			}

			_sideSolidChildren[verticalSide].Add(actualNode);
			_sideSolidChildren[depthSide].Add(actualNode);
			_sideSolidChildren[horizontalSide].Add(actualNode);
		} else {
			actualNode = this;
		}

		var currentParent = parent;
		while (currentParent != null) {
			if (currentParent._sideSolidChildren == null)
			{
				currentParent._sideSolidChildren = new Dictionary<NeighbourSide, HashSet<VoxelNode>>();
				for (var i = 0; i < 6; ++i)
				{
					var neighbourSide = (NeighbourSide)i;
					currentParent._sideSolidChildren[neighbourSide] = new HashSet<VoxelNode>();
				}
			}

			currentParent._sideSolidChildren[verticalSide].Add(actualNode);
			currentParent._sideSolidChildren[depthSide].Add(actualNode);
			currentParent._sideSolidChildren[horizontalSide].Add(actualNode);

			currentParent = currentParent.parent;
		}
	}
Ejemplo n.º 25
0
 public void RemoveChild(ChildIndex index, bool cleanup = false)
 {
     RemoveChildInternal(index, cleanup, true);
 }
Ejemplo n.º 26
0
    private Bounds GetChildBounds(ChildIndex childIndex)
    {
        AssertNotDeleted();

        return(GetChildBoundsInternal(bounds, childIndex));
    }
Ejemplo n.º 27
0
 public TestOctreeNode(Bounds bounds, TestOctreeNode <T> parent, ChildIndex indexInParent,
                       TestOctree <T> tree) : base(bounds, parent, indexInParent, tree)
 {
 }
Ejemplo n.º 28
0
    protected static void GetNeighbourSides(ChildIndex childIndex,
                                            out NeighbourSide verticalSide,
                                            out NeighbourSide horizontalSide,
                                            out NeighbourSide depthSide)
    {
        switch (childIndex)
        {
        case ChildIndex.Invalid:
            // self
            verticalSide   = NeighbourSide.Invalid;
            horizontalSide = NeighbourSide.Invalid;
            depthSide      = NeighbourSide.Invalid;
            break;

        case ChildIndex.LeftBelowBack:
            verticalSide   = NeighbourSide.Below;
            depthSide      = NeighbourSide.Back;
            horizontalSide = NeighbourSide.Left;
            break;

        case ChildIndex.RightBelowBack:
            verticalSide   = NeighbourSide.Below;
            depthSide      = NeighbourSide.Back;
            horizontalSide = NeighbourSide.Right;
            break;

        case ChildIndex.LeftAboveBack:
            verticalSide   = NeighbourSide.Above;
            depthSide      = NeighbourSide.Back;
            horizontalSide = NeighbourSide.Left;
            break;

        case ChildIndex.RightAboveBack:
            verticalSide   = NeighbourSide.Above;
            depthSide      = NeighbourSide.Back;
            horizontalSide = NeighbourSide.Right;
            break;

        case ChildIndex.LeftBelowForward:
            verticalSide   = NeighbourSide.Below;
            depthSide      = NeighbourSide.Forward;
            horizontalSide = NeighbourSide.Left;
            break;

        case ChildIndex.RightBelowForward:
            verticalSide   = NeighbourSide.Below;
            depthSide      = NeighbourSide.Forward;
            horizontalSide = NeighbourSide.Right;
            break;

        case ChildIndex.LeftAboveForward:
            verticalSide   = NeighbourSide.Above;
            depthSide      = NeighbourSide.Forward;
            horizontalSide = NeighbourSide.Left;
            break;

        case ChildIndex.RightAboveForward:
            verticalSide   = NeighbourSide.Above;
            depthSide      = NeighbourSide.Forward;
            horizontalSide = NeighbourSide.Right;
            break;

        default:
            throw new ArgumentOutOfRangeException("childIndex", childIndex, null);
        }
    }