Esempio n. 1
0
 IEnumerator WaitForDissolve(BrokenTreePart current)
 {
     if (current.lDis != null)
     {
         yield return(new WaitWhile(() => current.lDis.isDissolving));
     }
     current.SetAliveState(false);
     yield return(null);
 }
Esempio n. 2
0
    public BrokenTreePart GetTreePartByID(int id)
    {
        BrokenTreePart found = null;

        foreach (BrokenTreePart bTP in parts)
        {
            if (bTP.GetPartID == id)
            {
                found = bTP;
                break;
            }
        }
        return(found);
    }
Esempio n. 3
0
    public void DestroyPart(BrokenTreePart current)
    {
        BrokenTreePart before = current.childToDestroyFirst;

        if (before != null && before.Alive)
        {
            DestroyPart(before);
        }
        if (current.lDis != null)
        {
            current.lDis.startDissovle();
        }
        StartCoroutine(WaitForDissolve(current));
    }
Esempio n. 4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        Collider[] hits = Physics.OverlapSphere(centerOfSphere.position, radius, checkLayers);
        if (hits.Length != 0)
        {
            foreach (Collider c in hits)
            {
                if (lastTreeCollisions.Select(items => items.c).Contains(c))
                {
                    break;
                }
                if (c.gameObject.layer == LayerMask.NameToLayer("PoI"))
                {
                    PoI parent = GlobalMethods.FindParentWithTag(c.gameObject, "PoI")?.GetComponent <PoI>();
                    if (parent is FallenBigTree fallen)
                    {
                        BrokenTreePart brokenPart = c.gameObject.GetComponent <BrokenTreePart>();
                        if (brokenPart.Alive)
                        {
                            fallen.DestroyPart(brokenPart);
                            ColliderInfo cInfo = new ColliderInfo();
                            cInfo.Setup(c, TypeOfParent.P_POI, parent);
                            lastTreeCollisions.Add(cInfo);
                        }
                    }
                }
                else if (c.gameObject.layer == LayerMask.NameToLayer("Interactable"))
                {
                    Interactable parent = GlobalMethods.FindParentWithTag(c.gameObject, "TreeLogic")?.GetComponent <Interactable>();

                    if (parent is Trees tree)
                    {
                        if (c.name.EndsWith("0") && !tree.lDis.isDissolving)
                        {
                            tree.Controller.handleTreeDestroy(tree);
                            ColliderInfo cInfo = new ColliderInfo();
                            cInfo.Setup(c, TypeOfParent.P_INT, parent);
                            lastTreeCollisions.Add(cInfo);
                        }
                    }
                }
            }
            Collider[] tempCopy = lastTreeCollisions.Select(item => item.c).ToArray();
            for (int i = 0; i < tempCopy.Length; i++)
            {
                Collider c     = tempCopy[i];
                Collider found = hits.FirstOrDefault(pC => pC.name.Equals(c.name));
                if (found == null)
                {
                    lastTreeCollisions.RemoveAt(i);
                }
            }

            /*
             * foreach(Collider c in tempCopy)
             * {
             *  Collider found = hits.FirstOrDefault(pC => pC.name.Equals(c.name));
             *  if(found == null)
             *  {
             *      lastTreeCollisions.Remove(c);
             *  }
             * }
             */
        }
        else
        {
            lastTreeCollisions.Clear();
        }
    }