public BuildHub(List <Setting> settingList, List <ObstacleData> obstaclesData, List <Robot> myRobots, List <Part> humanRobotParts, Part[] storeParts, long credits, MODES mode) : base(settingList) { myRobotsList = new List <Robot>(); if (myRobots != null && myRobots.Count > 0) { myRobotsList.AddRange(myRobots); } this.humanRobotParts = humanRobotParts; currentRobot = (this.myRobotsList.Count > 0 ? this.myRobotsList[0] : null); OBSTACLES_DATA = obstaclesData; STORE_PARTS = storeParts; this.credits = credits; this.mode = mode; goToField = false; trainingMode = false; MESHES = new List <Mesh>(); MESHES.Add(PrimitiveHelper.GetPrimitiveMesh(PrimitiveType.Cube)); MESHES.Add(PrimitiveHelper.GetPrimitiveMesh(PrimitiveType.Sphere)); MESHES.Add(PrimitiveHelper.GetPrimitiveMesh(PrimitiveType.Cylinder)); MESHES.Add(PrimitiveHelper.GetPrimitiveMesh(PrimitiveType.Cube)); foreach (Part part in this.humanRobotParts) { if (!(part is Attachment) && part.GAME_OBJECT != null) { part.toggleGameObject(false); } } foreach (Part part in STORE_PARTS) { if (part.GAME_OBJECT != null) { part.toggleGameObject(false); } } if (currentRobot != null) { createPreviewRobot(); } this.myRobots = new MyRobots(myRobotsList.ToArray(), this.humanRobotParts.ToArray(), this.credits, base.colorScheme); workshop = new Workshop(MESHES, previewRobot, (currentRobot != null ? currentRobot.getName() : ""), this.humanRobotParts, (currentRobot != null ? currentRobot.getParts() : null), this.credits, base.colorScheme, enableCreditsSpentAnimation); store = new Store(MESHES, previewRobot, this.STORE_PARTS, this.humanRobotParts, (currentRobot != null ? currentRobot.getParts() : null), this.credits, workshop.getConfigurationCard(), base.colorScheme, enableCreditsSpentAnimation); obstacleList = new ObstacleList(OBSTACLES_DATA); TABS = new List <GameObject>(); foreach (Transform child in GameObject.Find("BuildHubTabs").transform) { TABS.Add(child.gameObject); } MY_ROBOTS_BACK_BUTTON = GameObject.Find("MyRobotsBackButton"); OBSTACLES_INFO_BUTTON = GameObject.Find("ObstaclesInfoButton"); SETTINGS_BUTTON = GameObject.Find("SettingsButton"); TRAINING_BUTTON = GameObject.Find("TrainingButton"); CREDITS_BUTTON = GameObject.Find("CreditsButton"); CREDITS_WIDGET = GameObject.Find("CreditsWidget"); CREDITS_WIDGET.SetActive(false); base.colorScheme = ImageTools.getColorFromString(base.settingPairs.color_scheme); enableCreditsSpentAnimation = base.settingPairs.credits_spent_animation; SETTINGS_BUTTON.GetComponent <UnityEngine.UI.Image>().color = base.colorScheme; TRAINING_BUTTON.GetComponent <UnityEngine.UI.Image>().color = base.colorScheme; colorScheme = SETTINGS_BUTTON.GetComponent <UnityEngine.UI.Image>().color; BACKGROUND = GameObject.Find("Background"); backgroundGraphicString = settingPairs.build_hub_background_graphic; BACKGROUND.GetComponent <UnityEngine.UI.Image>().sprite = ImageTools.getSpriteFromString(backgroundGraphicString); PLATFORM = GameObject.Find("Platform"); platformGraphicString = settingPairs.build_hub_platform_graphic; PLATFORM.GetComponent <Renderer>().material.mainTexture = new Image(platformGraphicString).getTexture(); enablePreviewRobotAnimation = settingPairs.preview_robot_animation; updateTabs(); if (this.mode == MODES.MY_ROBOTS) { MY_ROBOTS_BACK_BUTTON.SetActive(false); foreach (GameObject tab in TABS) { tab.SetActive(false); } } }
private void updateTabs() { if (!obstacleList.isEnabled() && !base.areSettingsOpen()) { if (!OBSTACLES_INFO_BUTTON.activeInHierarchy && !SETTINGS_BUTTON.activeInHierarchy) { if (mode != MODES.MY_ROBOTS) { MY_ROBOTS_BACK_BUTTON.SetActive(true); foreach (GameObject tab in TABS) { tab.SetActive(true); } } previewRobot.GAME_OBJECT.SetActive(true); OBSTACLES_INFO_BUTTON.SetActive(true); SETTINGS_BUTTON.SetActive(true); TRAINING_BUTTON.SetActive(true); } if (mode == MODES.MY_ROBOTS && (myRobots.getRobotBeingPicked() != null || myRobots.getNewRobot() != null || myRobots.getRobotsToRemove().Count > 0)) { if (myRobots.getRobotsToRemove().Count > 0) { List <Robot> robotsToRemove = myRobots.getRobotsToRemove(); foreach (Robot robot in robotsToRemove) { myRobotsList.Remove(robot); } if (myRobotsList.Count == 0) { myRobots = new MyRobots(myRobotsList.ToArray(), humanRobotParts.ToArray(), credits, base.colorScheme); } myRobots.clearPickedAndNewRobotAndRobotsToRemove(); } else { currentRobot = (myRobots.getRobotBeingPicked() != null ? myRobots.getRobotBeingPicked() : myRobots.getNewRobot()); if (myRobots.getNewRobot() != null) { myRobotsList.Add(currentRobot); } if (previewRobot == null) { createPreviewRobot(); } myRobots.clearPickedAndNewRobotAndRobotsToRemove(); workshop.destroyAllGeneratedObjects(); store.destroyAllGeneratedObjects(); GameObject.Find("BuildHubCanvas").transform.Find("Workshop").gameObject.SetActive(true); GameObject.Find("BuildHubCanvas").transform.Find("Store").gameObject.SetActive(true); workshop = new Workshop(MESHES, previewRobot, currentRobot.getName(), this.humanRobotParts, currentRobot.getParts(), this.credits, base.colorScheme, enableCreditsSpentAnimation); store = new Store(MESHES, previewRobot, this.STORE_PARTS, this.humanRobotParts, currentRobot.getParts(), this.credits, workshop.getConfigurationCard(), base.colorScheme, enableCreditsSpentAnimation); mode = MODES.WORKSHOP; MY_ROBOTS_BACK_BUTTON.SetActive(true); foreach (GameObject tab in TABS) { tab.SetActive(true); } } } if (MY_ROBOTS_BACK_BUTTON.GetComponent <ButtonListener>().isClicked()) { MY_ROBOTS_BACK_BUTTON.GetComponent <ButtonListener>().resetClick(); updateCurrentRobotInList(); mode = MODES.MY_ROBOTS; MY_ROBOTS_BACK_BUTTON.SetActive(false); foreach (GameObject tab in TABS) { tab.SetActive(false); } myRobots.destroyAllGeneratedObjects(); GameObject.Find("BuildHubCanvas").transform.Find("MyRobots").gameObject.SetActive(true); myRobots = new MyRobots(myRobotsList.ToArray(), humanRobotParts.ToArray(), credits, base.colorScheme); } foreach (GameObject tab in TABS) { if (tab.GetComponent <UnityEngine.UI.Image>().color == INACTIVE_TAB_COLOR && (tab.transform.Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text.ToLower().Contains(mode.ToString().ToLower()) || tab.GetComponent <ButtonListener>().isClicked())) { tab.GetComponent <UnityEngine.UI.Image>().color = ACTIVE_TAB_COLOR; mode = (MODES)Enum.Parse(typeof(MODES), tab.transform.Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text.ToUpper(), true); tab.GetComponent <ButtonListener>().resetClick(); } else if (!tab.transform.Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text.ToLower().Contains(mode.ToString().ToLower())) { tab.GetComponent <UnityEngine.UI.Image>().color = INACTIVE_TAB_COLOR; } tab.GetComponent <ButtonListener>().resetClick(); } GameObject.Find("BuildHubCanvas").transform.Find("MyRobots").gameObject.SetActive(mode == MODES.MY_ROBOTS); GameObject.Find("BuildHubCanvas").transform.Find("Workshop").gameObject.SetActive(mode == MODES.WORKSHOP); GameObject.Find("BuildHubCanvas").transform.Find("Store").gameObject.SetActive(mode == MODES.STORE); if (OBSTACLES_INFO_BUTTON.GetComponent <ButtonListener>().isClicked()) { OBSTACLES_INFO_BUTTON.GetComponent <ButtonListener>().resetClick(); MY_ROBOTS_BACK_BUTTON.SetActive(false); foreach (GameObject tab in TABS) { tab.SetActive(false); } previewRobot.GAME_OBJECT.SetActive(false); GameObject.Find("BuildHubCanvas").transform.Find("Workshop").gameObject.SetActive(false); GameObject.Find("BuildHubCanvas").transform.Find("Store").gameObject.SetActive(false); OBSTACLES_INFO_BUTTON.SetActive(false); SETTINGS_BUTTON.SetActive(false); TRAINING_BUTTON.SetActive(false); obstacleList.enable(); } if (SETTINGS_BUTTON.GetComponent <ButtonListener>().isClicked()) { SETTINGS_BUTTON.GetComponent <ButtonListener>().resetClick(); MY_ROBOTS_BACK_BUTTON.SetActive(false); foreach (GameObject tab in TABS) { tab.SetActive(false); } previewRobot.GAME_OBJECT.SetActive(false); GameObject.Find("BuildHubCanvas").transform.Find("Workshop").gameObject.SetActive(false); GameObject.Find("BuildHubCanvas").transform.Find("Store").gameObject.SetActive(false); OBSTACLES_INFO_BUTTON.SetActive(false); SETTINGS_BUTTON.SetActive(false); base.openSettings(); } if (TRAINING_BUTTON.GetComponent <ButtonListener>().isClicked()) { TRAINING_BUTTON.GetComponent <ButtonListener>().resetClick(); workshop.setGoToField(true); goToField = true; trainingMode = true; } if (CREDITS_BUTTON.GetComponent <ButtonListener>().isClicked()) { CREDITS_BUTTON.GetComponent <ButtonListener>().resetClick(); CREDITS_WIDGET.SetActive(!CREDITS_WIDGET.activeInHierarchy); } } }