Exemplo n.º 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);
    }
Exemplo n.º 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);
    }
Exemplo n.º 3
0
    private void AttachAllRopesToNewObject(GameObject p_newObject)
    {
        if (p_newObject != null && p_newObject.GetComponent <Rigidbody2D>() != null && this.GetComponent <Rigidbody2D>() != null)
        {
            if (Application.isPlaying)
            {
                RopesAttached v_attachedComponent = GetComponent <RopesAttached>();
                if (v_attachedComponent != null)
                {
                    foreach (Rope2D v_rope in v_attachedComponent.PluggedRopes)
                    {
                        if (v_rope.GetRigidBody2DFromObject(v_rope.ObjectA) == this.GetComponent <Rigidbody2D>())
                        {
                            v_rope.ObjectA = p_newObject;
                        }
                        if (v_rope.GetRigidBody2DFromObject(v_rope.ObjectB) == this.GetComponent <Rigidbody2D>())
                        {
                            v_rope.ObjectB = p_newObject;
                        }
                    }
                }
            }
            else
            {
                Rope2D[] v_arrayOfRopes = KiltUtils.FindAllComponentsOfType <Rope2D>(true);
                foreach (Rope2D v_rope in v_arrayOfRopes)
                {
                    bool v_changed = false;
                    if (v_rope.GetRigidBody2DFromObject(v_rope.ObjectA) == this.GetComponent <Rigidbody2D>())
                    {
                        v_changed      = true;
                        v_rope.ObjectA = p_newObject;
                    }
                    if (v_rope.GetRigidBody2DFromObject(v_rope.ObjectB) == this.GetComponent <Rigidbody2D>())
                    {
                        v_changed      = true;
                        v_rope.ObjectB = p_newObject;
                    }

                    if (v_changed)
                    {
                        ApplyModificationsInEditMode(v_rope);
                    }
                }
            }
        }
    }