public void SpawnBot() { try { if (botData == null && BotConfiguator.singleton.possibleBots.Count > 0) { botData = BotConfiguator.singleton.possibleBots[Random.Range(0, BotConfiguator.singleton.possibleBots.Count)]; } if (botData) { var newBot = BotConfiguator.GenerateBotFromData(botData, playerBot, false, transform); var healthScript = newBot.GetComponent <Health>(); var botScript = newBot.GetComponent <Bot>(); if (WinCondition.singleton) { WinCondition.singleton.botCount++; healthScript.OnDeath.AddListener(WinCondition.singleton.DeathOf); if (playerBot) { WinCondition.singleton.playerBot = botScript; } } var camScript = Camera.main.GetComponent <MultiPlayerCam>(); if (camScript) { camScript.keepInFrame.Add(newBot.transform); healthScript.OnDeath.AddListener(camScript.TakeBotOutOfTargets); } OnSpawn.Invoke(botScript); } } catch (System.Exception e) { Debug.LogWarning("exception on bot creation: " + e); } }
private void Awake() { if (singleton == null) { singleton = this; } else { Debug.LogWarning("Too many Bot Configurators", gameObject); Destroy(gameObject); } //GetAllBots(); }