Exemple #1
0
        private List <FirePlace> GetAllConnectedFirePlaces(FirePlace fireplace, FirePlace origin)
        {
            var fireplaces = new List <FirePlace>();

            foreach (FirePlace fp in fireplace.GetConnectedFireplaces())
            {
                if (fp != null && fp != origin)
                {
                    fireplaces.Add(fp);
                    fireplaces.AddRange(GetAllConnectedFirePlaces(fp, fireplace));
                }
            }
            return(fireplaces);
        }
Exemple #2
0
        void OnTriggerStay2D(Collider2D col)
        {
            if (col.gameObject.layer == LayerMask.NameToLayer(Layers.PlSpot))
            {
                FirePlace connectedFireplace = col.GetComponent <FirePlace>();

                if (_fireplace.IsAccessible && connectedFireplace.IsAccessible && Vector2.Distance(col.bounds.center, _thisCol.bounds.center) < 0.3f)
                {
                    _fireplace.Connect(connectedFireplace);
                    connectedFireplace.Connect(_fireplace);
                }
                else if (_fireplace.IsAccessible == false && _fireplace.GetConnectedFireplaces().Contains(connectedFireplace) && Vector2.Distance(col.bounds.center, _thisCol.bounds.center) > 0.3f)
                {
                    _fireplace.Disconnect(connectedFireplace);
                }
            }
        }