Ejemplo n.º 1
0
    public static List <TriangleMeshNode> GetAllNodesInRadius(Vector3 origin, float radius)
    {
        //float radiusSquared = radius * radius;

        TriangleMeshNode root = AStarPathfindingUtils.GetNearestNodeOnNavMesh(origin);

        List <TriangleMeshNode> validNodes = new List <TriangleMeshNode>();

        EB.Collections.Queue <TriangleMeshNode> toCheck = new EB.Collections.Queue <TriangleMeshNode>();
        HashSet <TriangleMeshNode> visited = new HashSet <TriangleMeshNode>();

        toCheck.Enqueue(root);
        while (toCheck.Count > 0)
        {
            TriangleMeshNode curNode = toCheck.Dequeue();

            if (SphereXZTriangleIntersect(origin, radius, (Vector3)curNode.GetVertex(0), (Vector3)curNode.GetVertex(1), (Vector3)curNode.GetVertex(2)))
            {
                validNodes.Add(curNode);
                for (int i = 0; i < curNode.connections.Length; i++)
                {
                    TriangleMeshNode connection = curNode.connections[i] as TriangleMeshNode;
                    if (!visited.Contains(connection))
                    {
                        toCheck.Enqueue(connection);
                    }
                }
            }

            visited.Add(curNode);
        }

        return(validNodes);
    }
Ejemplo n.º 2
0
    public static Dictionary <int, GameObject> FindIndexedComponents(Transform root)
    {
        Dictionary <int, GameObject> allComponents = new Dictionary <int, GameObject>();

        EB.Collections.Queue <Transform> queue = new EB.Collections.Queue <Transform>(16);
        queue.Enqueue(root);
        while (queue.Count > 0)
        {
            Transform            it      = queue.Dequeue();
            IndexedZoneComponent indexer = it.GetComponent <IndexedZoneComponent>();

            if (indexer != null)
            {
                allComponents.Add(indexer.Index, indexer.gameObject);
            }

            int childCount = it.childCount;
            for (int i = 0; i < childCount; ++i)
            {
                queue.Enqueue(it.GetChild(i));
            }
        }

        return(allComponents);
    }
Ejemplo n.º 3
0
    // recursively fine the transform include inRoot and the whole hierarchy under the inRoot, this also include the object that is deactivate
    public static Transform SearchHierarchyForBone(Transform inRoot, string inName, bool ignoreDisabled = false)
    {
        if (inRoot == null || inName.Length <= 0)
        {
            return(null);
        }
        // check if the current bone is the bone we're looking for, if so return it
        if (inRoot.name.Equals(inName))
        {
            return(inRoot);
        }

        EB.Collections.Queue <Transform> queue = new EB.Collections.Queue <Transform>(16);
        Transform result = null;

        queue.Enqueue(inRoot);
        while (queue.Count > 0)
        {
            Transform it = queue.Dequeue();
            result = it.Find(inName);
            if (result && (!ignoreDisabled || result.gameObject.activeInHierarchy))
            {
                return(result);
            }

            int childCount = it.childCount;
            for (int i = 0; i < childCount; ++i)
            {
                queue.Enqueue(it.GetChild(i));
            }
        }
        return(null);
    }
Ejemplo n.º 4
0
 /// <summary>
 /// 添加进入将要更新的缓存数据队列
 /// </summary>
 /// <param name="dataID">数据的唯一id</param>
 /// <param name="value">数据对象</param>
 private void StashUpdateLookupsCall(string dataID, object value)
 {
     updateLookupsCallsStack.Enqueue(new UpdateLookupsCall()
     {
         DataID = dataID, Value = value
     });
 }
Ejemplo n.º 5
0
        public void Destroy(T obj)
        {
            GameUtils.FastRemove <T>(_active, obj);
            _inactive.Enqueue(obj);

            obj.OnPoolDeactivate();
        }
Ejemplo n.º 6
0
        public void Destroy(object obj)
        {
            GameUtils.FastRemove <object>(_active, obj);
            _inactive.Enqueue(obj);

            (obj as IPoolable).OnPoolDeactivate();
        }
Ejemplo n.º 7
0
    private void LoadTexture(string textureName, System.Action <bool, Texture2D> cb)
    {
#if TEXTUREPOOL_SPEW
        EB.Debug.Log("Trying to load texture " + textureName);
#endif
        if (string.IsNullOrEmpty(textureName))
        {
            EB.Debug.LogWarning("Attempt to load empty texture.");
            return;
        }

        var info = GetTextureInfo(textureName);
        if (info != null)
        {
            info.refCount++;             // inc the refcount
            info.time = Time.realtimeSinceStartup;

            if (info.texture != null)
            {
                if (cb != null)
                {
                    cb(info.successfullyLoaded, info.texture);
                }
            }
            else
            {
                info.callbacks.Add(cb);
                _loads.Enqueue(textureName);
            }
            return;
        }

        // create new info
        info             = new TextureInfo();
        info.textureName = textureName;
        info.refCount    = 1;
        info.time        = Time.realtimeSinceStartup;
        info.callbacks.Add(cb);
        _all.Add(info);
        _loads.Enqueue(textureName);
    }
Ejemplo n.º 8
0
 /// <summary>
 /// ui入栈
 /// </summary>
 /// <param name="stackable"></param>
 /// <param name="queued"></param>
 /// <param name="manualDepth"></param>
 public void EnStack(IStackableUI stackable, bool queued = false)
 {
     if (!queued || CanDisplayNextOnQueue())
     {
         StartCoroutine(EnStackCoroutine(stackable));
     }
     else
     {
         stackable.Show(false);
         _toEnstackWhenPossible.Enqueue(stackable);
     }
 }
Ejemplo n.º 9
0
    /// <summary>
    /// 让指定的ui队列中移除
    /// </summary>
    /// <param name="ui"></param>
    public void Dequeue(IStackableUI ui)
    {
        EB.Collections.Queue <IStackableUI> tmpQueue = new EB.Collections.Queue <IStackableUI>();

        while (_toEnstackWhenPossible.Count > 0)
        {
            IStackableUI q = _toEnstackWhenPossible.Dequeue();
            if (q == ui)
            {
                break;
            }

            tmpQueue.Enqueue(q);
        }

        while (_toEnstackWhenPossible.Count > 0)
        {
            tmpQueue.Enqueue(_toEnstackWhenPossible.Dequeue());
        }

        _toEnstackWhenPossible = tmpQueue;
    }
Ejemplo n.º 10
0
    private IDebuggable[] GetAllSystemsFromPath(string systemPath, IDebuggable parent = null)
    {
        if (systemPath == null)
        {
            return(new IDebuggable[0]);
        }

        string[] names = systemPath.Split('/');
        if (names.Length == 0)
        {
            return(new IDebuggable[0]);
        }

        EB.Collections.Queue <IDebuggable> currents = new EB.Collections.Queue <IDebuggable>();
        foreach (IDebuggable sys in GetAllSystemsFromName(names[0]))
        {
            if (_gameSystems[sys].parent == parent && _gameSystems[sys].systemName == names[0])
            {
                currents.Enqueue(sys);
            }
        }

        for (int i = 1; i < names.Length; i++)
        {
            while (currents.Count > 0 && _gameSystems[currents.Peek()].systemName == names[i - 1])
            {
                foreach (IDebuggable sub in _gameSystems[currents.Dequeue()].subSystems)
                {
                    if (_gameSystems[sub].systemName == names[i])
                    {
                        currents.Enqueue(sub);
                    }
                }
            }
        }

        return(currents.ToArray());
    }
Ejemplo n.º 11
0
    public virtual void Show(UIDialogeOption option)
    {
        if (IsOpen())
        {
            mQueue.Enqueue(option);
            return;
        }

        if (mQueue.Count > 0)
        {
            mQueue.Enqueue(option);
            return;
        }

        mClearQueue = true;
        Option      = option;
        Open();

        if (header != null)
        {
            header.SetActive(option.title != null);
            if (header.activeSelf)
            {
                UILabel titleLabel = header.GetComponentInChildren <UILabel>();
                titleLabel.text = option.title;
            }
        }

        if (body != null)
        {
            body.SetActive(option.body != null);
            if (body.activeSelf)
            {
                UILabel   bodyLabel = body.GetComponentInChildren <UILabel>();
                string [] strs      = option.body.Split('\n');
                if (strs.Length > 5)
                {
                    bodyLabel.text = strs[0];
                }
                else
                {
                    bodyLabel.text = option.body;
                }
            }
        }

        if (input != null)
        {
            input.SetActive(option.input != null);
            if (input.activeSelf)
            {
                UIInput inputComponent = input.GetComponentInChildren <UIInput>();
                inputComponent.value = option.input;
            }
        }

        if (acceptButton != null)
        {
            acceptObject.SetActive((option.buttons & eUIDialogueButtons.Accept) == eUIDialogueButtons.Accept);
            acceptButton.onClick.Clear();
            if (acceptObject.activeSelf)
            {
                acceptButton.onClick.Add(new EventDelegate(OnAcceptButtonClick));
            }
        }

        if (declineButton != null)
        {
            declineObject.SetActive((option.buttons & eUIDialogueButtons.Decline) == eUIDialogueButtons.Decline);
            declineButton.onClick.Clear();
            if (declineObject.activeSelf)
            {
                declineButton.onClick.Add(new EventDelegate(OnDeclineButtonClick));
            }
        }

        if (cancelButton != null)
        {
            cancelObject.SetActive((option.buttons & eUIDialogueButtons.Cancel) == eUIDialogueButtons.Cancel);
            cancelButton.onClick.Clear();
            if (cancelObject.activeSelf)
            {
                cancelButton.onClick.Add(new EventDelegate(OnCancelButtonClick));
            }
        }
    }