예제 #1
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);
        }
예제 #2
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);
        }