Exemple #1
0
        private void Start()
        {
            // playerObject = GameObject.FindWithTag("Player").transform;

            allSphereBots = new List <MicroBot>();
            renderedBots  = new List <MicroBot>();

            if (TryGetComponent(out Renderer _r))
            {
                var newRoot = new MicroBot(null, transform, _r.material.color);
                allSphereBots = newRoot.GetBFS();
                renderedBots  = newRoot.GetRenderedBots();
            }
            else
            {
                var newRoot = new MicroBot(null, transform);
                allSphereBots = newRoot.GetBFS();
                renderedBots  = newRoot.GetRenderedBots();
            }

            Debug.Log($"Rendered bots count = {renderedBots.Count}");
            originalRadius = Vector3.Distance(transform.position,
                                              renderedBots[renderedBots.Count - 1].botTransform.position);
            directions = new Vector3[renderedBots.Count];
            for (int i = 0; i < renderedBots.Count; i++)
            {
                directions[i] = transform.position - renderedBots[i].botTransform.position;
            }
        }
        public static List <MicroBot> GetRenderedBots(this MicroBot root)
        {
            root.FillTreeFromRoot();
            List <MicroBot> renderedBots = root.GetBFS();

            Debug.Log($"Getting the rendered bots -- {renderedBots.Count}");
            for (int i = renderedBots.Count - 1; i >= 0; i--)
            {
                if (renderedBots[i].botTransform.GetComponent <Renderer>().enabled == false)
                {
                    renderedBots.RemoveAt(i++);
                }
            }
            Debug.Log($"Updated count -- {renderedBots.Count}");
            return(renderedBots);
        }