Beispiel #1
0
    public List <GameObject> GetAllIndirectObjects(bool p_includeOtherPluggedObjects = true)
    {
        /*List<GameObject> v_finalList = new List<GameObject>();
         * foreach(RopeBehaviour2D v_rope in IndirectRopes)
         * {
         *      if(v_rope != null)
         *              v_finalList.MergeList(v_rope.GetPluggedObjectsInRope());
         * }
         *
         * //Remove Or Add Plugged Objects
         * foreach(RopeBehaviour2D v_rope in PluggedRopes)
         * {
         *      if(v_rope != null)
         *      {
         *              if(!p_includeOtherPluggedObjects)
         *              {
         *                      foreach(GameObject v_object in v_rope.GetPluggedObjectsInRope())
         *                              v_finalList.RemoveChecking(v_object);
         *              }
         *              else
         *                      v_finalList.MergeList(v_rope.GetPluggedObjectsInRope());
         *      }
         * }
         * return v_finalList;*/


        List <GameObject> v_indirectPluggedObjects = GetAllOtherAttachedObjectsInPluggedRopes();
        List <GameObject> v_directObjects          = v_indirectPluggedObjects.CloneList();

        v_indirectPluggedObjects.AddChecking(this.gameObject);
        for (int i = 0; i < v_indirectPluggedObjects.Count; i++)
        {
            GameObject v_otherObject = v_indirectPluggedObjects[i];
            if (v_otherObject != null && v_otherObject != this.gameObject)
            {
                RopesAttached v_attachedScript = v_otherObject.GetComponent <RopesAttached>();
                if (v_attachedScript != null)
                {
                    v_indirectPluggedObjects.MergeList(v_attachedScript.GetAllOtherAttachedObjectsInPluggedRopes());
                }
            }
        }
        if (!p_includeOtherPluggedObjects)
        {
            foreach (GameObject v_object in v_directObjects)
            {
                v_indirectPluggedObjects.RemoveChecking(v_object);
            }
        }
        //Aways Remove Self
        v_indirectPluggedObjects.RemoveChecking(this.gameObject);
        return(v_indirectPluggedObjects);
    }
Beispiel #2
0
    //Find ropes pluggued in objects atacched to one PluggedRope
    public List <Rope2D> GetAllIndirectRopes(bool p_includePluggedRopes = true)
    {
        List <Rope2D>     v_indirectRopes          = new List <Rope2D>(PluggedRopes);
        List <GameObject> v_indirectPluggedObjects = GetAllOtherAttachedObjectsInPluggedRopes();

        v_indirectPluggedObjects.AddChecking(this.gameObject);
        for (int i = 0; i < v_indirectPluggedObjects.Count; i++)
        {
            GameObject v_otherObject = v_indirectPluggedObjects[i];
            if (v_otherObject != null && v_otherObject != this.gameObject)
            {
                RopesAttached v_attachedScript = v_otherObject.GetComponent <RopesAttached>();
                if (v_attachedScript != null)
                {
                    v_indirectRopes.MergeList(v_attachedScript.PluggedRopes);
                    v_indirectPluggedObjects.MergeList(v_attachedScript.GetAllOtherAttachedObjectsInPluggedRopes());
                }
            }
        }
        if (!p_includePluggedRopes)
        {
            foreach (Rope2D v_rope in PluggedRopes)
            {
                v_indirectRopes.RemoveChecking(v_rope);
            }
        }
        return(v_indirectRopes);
    }
 protected override void OnRemove(TAOTPair p_pair)
 {
     if (p_pair != null)
     {
         _values.RemoveChecking(p_pair.Value, false);
     }
     if (p_pair != null)
     {
         _keys.RemoveChecking(p_pair.Key, false);
     }
 }
Beispiel #4
0
	protected virtual void ClearAudio(bool p_force = false)
	{
		if(p_force || _needCleanAudio)
		{
			_needCleanAudio = false;
			m_soundEffectsSource.RemoveNulls();
			List<AudioSource> v_clonedList = m_soundEffectsSource.CloneList();
			foreach(AudioSource v_source in v_clonedList)
			{
				if(v_source != null && !v_source.isPlaying)
					m_soundEffectsSource.RemoveChecking(v_source);
			}
		}
	}
Beispiel #5
0
 protected override void OnRemove(KVPair <TKey, TValue> p_pair)
 {
     if (EnableUnityInspectorSupport)
     {
         if (p_pair != null)
         {
             _values.RemoveChecking(p_pair.Value, false);
         }
         if (p_pair != null)
         {
             _keys.RemoveChecking(p_pair.Key, false);
         }
     }
     else
     {
         GetAllKeyValuesFromPairs();
     }
 }
	protected virtual IEnumerator ChangeInput()
	{
		if(!_checking)
		{
			_checking = true;
			EventSystem v_eventSystem = EventSystem.current;
			if(v_eventSystem != null)
			{
				bool v_moveBack = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
				GameObject v_currentSelectedGameObject = v_eventSystem.currentSelectedGameObject;
				Selectable v_currentSelectedComponent = v_currentSelectedGameObject != null? v_currentSelectedGameObject.GetComponent<Selectable>() : null;

				if(!(v_currentSelectedComponent is InputField) || !(((InputField)v_currentSelectedComponent).multiLine))
				{
					List<Selectable> v_currentSelectables = new List<Selectable>();
					for(int i=0; i<Selectable.allSelectables.Count; i++)
					{
						Selectable v_selectableComponent = Selectable.allSelectables[i];
						v_currentSelectables.RemoveChecking(v_selectableComponent);
						if(v_selectableComponent != null && v_selectableComponent.navigation.mode != Navigation.Mode.None  && FocusContainer.IsUnderFocus(v_selectableComponent.gameObject))
						{
							//Sort with SelectionUpDown Index
							int v_indexDown = v_currentSelectables.IndexOf(v_selectableComponent.navigation.selectOnDown);
							int v_indexUp = v_currentSelectables.IndexOf(v_selectableComponent.navigation.selectOnUp);
							bool v_insertingComplete = false;
							int v_indexToInsert = v_indexDown >=0 && v_indexDown < v_currentSelectables.Count? v_indexDown : (v_indexUp >=0 && v_indexUp < v_currentSelectables.Count? v_indexUp + 1 : -1);
							if(v_indexToInsert >=0 && v_indexToInsert < v_currentSelectables.Count+1)
							{
								try
								{
									v_currentSelectables.Insert(v_indexToInsert, v_selectableComponent);
									v_insertingComplete = true;
								}
								catch{}
							}
							if(!v_insertingComplete)
							{
								v_insertingComplete = true;
								v_currentSelectables.Add(v_selectableComponent);
							}
						}
					}

					if(v_currentSelectedComponent != null)
					{
						int v_index = v_currentSelectables.IndexOf(v_currentSelectedComponent);
						v_index = v_moveBack? v_index-1 : v_index+1;
						v_currentSelectedComponent = v_index >= 0 && v_index < v_currentSelectables.Count? v_currentSelectables[v_index] : null;
						v_currentSelectedGameObject = v_currentSelectedComponent != null? v_currentSelectedComponent.gameObject : null;
					}
					if(v_currentSelectedComponent == null)
					{
						v_currentSelectedComponent = v_moveBack? v_currentSelectables.GetLast() : v_currentSelectables.GetFirst();
						v_currentSelectedGameObject = v_currentSelectedComponent != null? v_currentSelectedComponent.gameObject : null;
					}

					v_eventSystem.SetSelectedGameObject(v_currentSelectedGameObject);
					if (v_currentSelectedComponent != null)
					{
						InputField v_inputfield = v_currentSelectedComponent.GetComponent<InputField>();
						if (v_inputfield != null)
							v_inputfield.OnPointerClick(new PointerEventData(v_eventSystem));
						yield return StartCoroutine(CoroutineUtil.WaitForRealSeconds(0.05f));
					}
				}
			}
			_checking = false;
		}
	}
        protected virtual IEnumerator ChangeInput()
        {
            if (!_checking)
            {
                _checking = true;
                EventSystem v_eventSystem = EventSystem.current;
                if (v_eventSystem != null)
                {
                    bool       v_moveBack = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
                    GameObject v_currentSelectedGameObject = v_eventSystem.currentSelectedGameObject;
                    Selectable v_currentSelectedComponent  = v_currentSelectedGameObject != null?v_currentSelectedGameObject.GetComponent <Selectable>() : null;

                    if (!(v_currentSelectedComponent is InputField) || !(((InputField)v_currentSelectedComponent).multiLine))
                    {
                        List <Selectable> v_currentSelectables = new List <Selectable>();
#if UNITY_2019_1_OR_NEWER
                        IList <Selectable> v_allSelectables = Selectable.allSelectablesArray;
#else
                        IList <Selectable> v_allSelectables = Selectable.allSelectables;
#endif
                        for (int i = 0; i < v_allSelectables.Count; i++)
                        {
                            Selectable v_selectableComponent = v_allSelectables[i];
                            v_currentSelectables.RemoveChecking(v_selectableComponent);
                            if (v_selectableComponent != null && v_selectableComponent.enabled && v_selectableComponent.gameObject.activeInHierarchy && v_selectableComponent.gameObject.activeSelf && v_selectableComponent.navigation.mode != Navigation.Mode.None && FocusGroup.IsUnderFocus(v_selectableComponent.gameObject))
                            {
                                //Sort with SelectionUpDown Index
                                int  v_indexDown         = v_currentSelectables.IndexOf(v_selectableComponent.navigation.selectOnDown);
                                int  v_indexUp           = v_currentSelectables.IndexOf(v_selectableComponent.navigation.selectOnUp);
                                bool v_insertingComplete = false;
                                int  v_indexToInsert     = v_indexDown >= 0 && v_indexDown < v_currentSelectables.Count ? v_indexDown : (v_indexUp >= 0 && v_indexUp < v_currentSelectables.Count ? v_indexUp + 1 : -1);
                                if (v_indexToInsert >= 0 && v_indexToInsert < v_currentSelectables.Count + 1)
                                {
                                    try
                                    {
                                        v_currentSelectables.Insert(v_indexToInsert, v_selectableComponent);
                                        v_insertingComplete = true;
                                    }
                                    catch { }
                                }
                                if (!v_insertingComplete)
                                {
                                    v_insertingComplete = true;
                                    v_currentSelectables.Add(v_selectableComponent);
                                }
                            }
                        }

                        if (v_currentSelectedComponent != null)
                        {
                            int v_index = v_currentSelectables.IndexOf(v_currentSelectedComponent);
                            v_index = v_moveBack ? v_index - 1 : v_index + 1;
                            v_currentSelectedComponent  = v_index >= 0 && v_index < v_currentSelectables.Count ? v_currentSelectables[v_index] : null;
                            v_currentSelectedGameObject = v_currentSelectedComponent != null ? v_currentSelectedComponent.gameObject : null;
                        }
                        if (v_currentSelectedComponent == null)
                        {
                            v_currentSelectedComponent  = v_moveBack ? v_currentSelectables.GetLast() : v_currentSelectables.GetFirst();
                            v_currentSelectedGameObject = v_currentSelectedComponent != null ? v_currentSelectedComponent.gameObject : null;
                        }

                        v_eventSystem.SetSelectedGameObject(v_currentSelectedGameObject);
                        if (v_currentSelectedComponent != null)
                        {
                            InputField v_inputfield = v_currentSelectedComponent.GetComponent <InputField>();
                            if (v_inputfield != null)
                            {
                                v_inputfield.OnPointerClick(new PointerEventData(v_eventSystem));
                            }
                            yield return(new WaitForSecondsRealtime(0.05f));
                        }
                    }
                }
                _checking = false;
            }
        }
	//Find ropes pluggued in objects atacched to one PluggedRope
	public List<Rope2D> GetAllIndirectRopes(bool p_includePluggedRopes = true)
	{
		List<Rope2D> v_indirectRopes = new List<Rope2D>(PluggedRopes);
		List<GameObject> v_indirectPluggedObjects = GetAllOtherAttachedObjectsInPluggedRopes();
		v_indirectPluggedObjects.AddChecking(this.gameObject);
		for(int i=0; i<v_indirectPluggedObjects.Count; i++)
		{
			GameObject v_otherObject = v_indirectPluggedObjects[i];
			if(v_otherObject != null && v_otherObject != this.gameObject)
			{
				RopesAttached v_attachedScript = v_otherObject.GetComponent<RopesAttached>();
				if(v_attachedScript != null)
				{
					v_indirectRopes.MergeList(v_attachedScript.PluggedRopes);
					v_indirectPluggedObjects.MergeList(v_attachedScript.GetAllOtherAttachedObjectsInPluggedRopes());
				}
			}
		}
		if(!p_includePluggedRopes)
		{
			foreach(Rope2D v_rope in PluggedRopes)
				v_indirectRopes.RemoveChecking(v_rope);
		}
		return v_indirectRopes;
	}
Beispiel #9
0
 protected virtual void OnDestroy()
 {
     _markedToDestroyInstances.RemoveChecking(this);
 }
Beispiel #10
0
	public static void UnregisterRopeFromScene(Rope2D p_rope)
	{
		List<Rope2D> v_ropeList = new List<Rope2D>(_allRopesInScene);
		v_ropeList.RemoveChecking(p_rope);
		_allRopesInScene = v_ropeList.ToArray();
	}