//------------------------------------------------- #region Get Method's Region public bool Exists(GraphicElements _e) { // check if the passed-by graphic element is an sandbox or not. if (_e is SandBoxBase _s) { // check if the passed-by sandbox is // an error sandbox or not. if (_s.IsErrorSandBox()) { // check if this element manager is owned by // some graphic element or not. if (HasOwner) { // NOTICE: // only the Element Manager of the GameClient // should have the error sandbox, // so if you are looking for an error sandbox // in here, then you are in a wrong place! return(false); } if (this.LowErrorSandBox != null) { if (LowErrorSandBox.Equals(_s)) { return(true); } } if (TopMostErrorSandBox != null) { if (TopMostErrorSandBox.Equals(_s)) { return(true); } } //return LowErrorSandBox.Equals(_s) || TopMostErrorSandBox.Equals(_s); return(false); } else { // if the passed-by value is not an error sandbox, // but just an ordinary sandbox, then it doesn't matter // if this manager is owned by only an ordinary sandbox or element, // you still can get the list of the sandboxes in this manager // and search for the passed by element. // for example, this manager is owned by a HallSandBox // (or not even a sandbox), and it has a sandbox on it, // so long as the passed-by value is not an error sandbox, // it's okay to try for searching for it. return(GetList(_s.SandBoxPriority).Exists(_s)); } } // it means the passed-by graphic element is just an ordinary // element, so you can get the list using it's priority. return(GetList(_e.Priority).Exists(_e)); }
/// <summary> /// enable the last sand box of this manager. /// use this method when a sandbox has been closed. /// for example if a LowErrorSandBox is closed, /// but please consider this, if a TopMostSandBox is closed, /// it means the game should be closed too, so there is no need to call this method. /// </summary> public void EnableLastSandBox() { if (LowErrorSandBox != null) { if (!LowErrorSandBox.Enabled) { LowErrorSandBox.Enable(); return; } } if (TopMostSandBoxes.Length > 1) { for (int i = TopMostSandBoxes.Length - 1; i >= 0; i--) { if (TopMostSandBoxes[i] != null) { if (!TopMostSandBoxes[i].Enabled) { TopMostSandBoxes[i].Enable(); return; } else { continue; } } else { continue; } } } if (LowSandBoxes.Length > 0) { for (int i = LowSandBoxes.Length - 1; i >= 0; i--) { if (LowSandBoxes[i] != null) { if (!LowSandBoxes[i].Enabled) { LowSandBoxes[i].Enable(); return; } else { continue; } } else { continue; } } } }
public bool ContainsChild(GraphicElements _e) { // check if the passed-by graphic element is an sandbox or not. if (_e is SandBoxBase _s) { // check if the passed-by sandbox is // an error sandbox or not. if (_s.IsErrorSandBox()) { // check if this element manager is owned by // some graphic element or not. if (HasOwner) { // NOTICE: // only the Element Manager of the GameClient // should have the error sandbox, // so if you are looking for an error sandbox // in here, then you are in a wrong place! return(false); } // check if the sand box you are looking for is // one of the low error sand boxes or their child or not. return(LowErrorSandBox.ContainsChild(_s) || TopMostErrorSandBox.ContainsChild(_s)); } else { // if the passed-by value is not an error sandbox, // but just an ordinary sandbox, then it doesn't matter // if this manager is owned by only an ordinary sandbox or element, // you still can get the list of the sandboxes in this manager // and search for the passed by element. // for example, this manager is owned by a HallSandBox // (or not even a sandbox), and it has a sandbox on it, // so long as the passed-by value is not an error sandbox, // it's okay to try for searching for it. // check if the low sandboxes list is null or not. if (this.LowSandBoxes != null) { // check if the sandbox you are looking for is // one the low sandboxes or their child or not. if (this.LowSandBoxes.ContainsChild(_s)) { // it means the sandbox is one the low sandboxes // or their child. return(true); } } // check if the top most sandboxes list is null or not. if (this.TopMostSandBoxes != null) { // check if the sandbox you are looking for is // one the top most sandboxes or their child or not. if (this.TopMostSandBoxes.ContainsChild(_s)) { // it means the sandbox is one the top most sandboxes // or their child. return(true); } } // huh? we are sure that the passed-by value was a sandbox, // but it is not in our lists, so it means you should // return false. return(false); } } // using a loop for searching in the elements. for (int i = 0; i < Elements.Length; i++) { // check if the current elment list is null or not. if (this.Elements[i] != null) { // check if the current element list contains this element // or not. if (this.Elements[i].ContainsChild(_e)) { // it means the current element list contans the element, // so you should return true. return(true); } } } // it means the passed-by graphic element is just an ordinary // element, so you can get the list using it's priority. return(false); }