Ejemplo n.º 1
0
        private void refreshBots(List <Bot> bots)
        {
            CleanKilledBots(bots);
            foreach (var bot in bots)
            {
                BotController currentBotController = null;
                _bots.TryGetValue(bot.Id, out currentBotController);
                if (currentBotController == null)
                {
                    var currentBotGO = Instantiate(botPrefab);
                    currentBotController = currentBotGO.GetComponent <BotController>();

                    var currentNameTagGO = Instantiate(nameTagPrefab);
                    currentNameTagGO.transform.SetParent(currentBotController.head);
                    var nameTagController = currentNameTagGO.GetComponent <NameTagController>();
                    nameTagController.BotGameObject        = currentBotGO;
                    currentBotController.NameTagController = nameTagController;

                    var currentHealthTagGO = Instantiate(healthTagPrefab);
                    var healthController   = currentHealthTagGO.GetComponent <HealthTagController>();
                    currentHealthTagGO.transform.SetParent(currentBotController.head);
                    healthController.BotGameObject        = currentBotGO;
                    currentBotController.HealthController = healthController;

                    var currentStaminaTagGO = Instantiate(staminaTagPrefab);
                    var staminaController   = currentStaminaTagGO.GetComponent <StaminaTagController>();
                    currentStaminaTagGO.transform.SetParent(currentBotController.head);
                    staminaController.BotGameObject        = currentBotGO;
                    currentBotController.StaminaController = staminaController;

                    _bots.Add(bot.Id, currentBotController);
                }
                currentBotController.UpdateBot(bot);
            }
        }
Ejemplo n.º 2
0
        public Transform getCreatureById(string botId)
        {
            Transform     toRet      = null;
            BotController controller = null;

            _bots.TryGetValue(botId, out controller);
            if (controller != null)
            {
                toRet = controller.transform;
            }
            return(toRet);
        }