public IEnumerator LoadTray() { // Access FarmTray script // yield return InitializeTray FarmTray script = GetComponent <FarmTray> (); script.node = node2; yield return(script.StartCoroutine("Initialize")); yield return(null); }
public void EnablePlants(bool val) { FarmTray tray = activeObject.transform.GetComponent <FarmTray> (); foreach (FarmSite site in tray.mySites) { if (!site.isEmpty) { site.Selectable = val; site.selectionReciever = this; } } }
private void EnableEmptySites(bool val) { FarmTray tray = activeObject.transform.GetComponent <FarmTray> (); foreach (FarmSite site in tray.mySites) { if (site.isEmpty) { site.Selectable = val; site.selectionReciever = this; } else { site.Selectable = (!val); } } emptySitesEnabled = val; }
public IEnumerator Initialize() { ActionButtonManager.actionButtonManager.ModuleStart(); FarmActuatorManager actManager = GameObject.FindGameObjectWithTag("FarmActuatorManager").GetComponent <FarmActuatorManager>(); overrideScrollContent = transform.FindChild("ManualOverridePanel").FindChild("MOScrollRect").FindChild("MOScrollContent"); foreach (FarmActuator act in actManager.actuatorList) { CreateOverrideModule(act); } if (activeFarmObject.isTrayObject) { activeTrayObject = activeFarmObject.gameObject.GetComponent <FarmTray>(); WWW www = new WWW(activeFarmObject.myURL); yield return(www); JSONNode node = JSON.Parse(www.text); if (node["current_recipe_run"].Value != "null") { currentRecipe = node["current_recipe_run"].Value; www = new WWW(currentRecipe); yield return(www); JSONNode recipeNode = JSON.Parse(www.text); www = new WWW(recipeNode["recipe"].Value); yield return(www); recipeNode = JSON.Parse(www.text); currentRecipeDisplay.text = recipeNode["name"].Value; } else { currentRecipeDisplay.text = "None"; } changeRecipeButton.interactable = true; } else { currentRecipeDisplay.text = "Selection is not a tray"; } yield return(null); }
public IEnumerator Initialize() { ActionButtonManager.actionButtonManager.ModuleStart (); FarmActuatorManager actManager = GameObject.FindGameObjectWithTag("FarmActuatorManager").GetComponent<FarmActuatorManager>(); overrideScrollContent = transform.FindChild ("ManualOverridePanel").FindChild ("MOScrollRect").FindChild ("MOScrollContent"); foreach (FarmActuator act in actManager.actuatorList) { CreateOverrideModule(act); } if (activeFarmObject.isTrayObject) { activeTrayObject = activeFarmObject.gameObject.GetComponent<FarmTray>(); WWW www = new WWW(activeFarmObject.myURL); yield return www; JSONNode node = JSON.Parse (www.text); if(node["current_recipe_run"].Value != "null") { currentRecipe = node["current_recipe_run"].Value; www = new WWW(currentRecipe); yield return www; JSONNode recipeNode = JSON.Parse (www.text); www = new WWW(recipeNode["recipe"].Value); yield return www; recipeNode = JSON.Parse (www.text); currentRecipeDisplay.text = recipeNode["name"].Value; } else { currentRecipeDisplay.text = "None"; } changeRecipeButton.interactable = true; } else { currentRecipeDisplay.text = "Selection is not a tray"; } yield return null; }
//OLD private void Setup() { float x, y, z; float length, width, height; string name = "Unnamed"; Vector3 scale, position; // Set object variables x = node ["x"].AsFloat; z = node ["y"].AsFloat; y = node ["z"].AsFloat; length = node ["length"].AsFloat; width = node ["width"].AsFloat; height = node ["height"].AsFloat; if (node["name"] != null) { name = node ["name"]; } // Set object position, scale, parent, name // Set Name gameObject.name = name; // Set Scale scale = new Vector3(length, height, width); transform.localScale = scale; // Set Parent gameObject (transform) transform.SetParent(parentTransform); // Set Position Vector3 plScale = transform.parent.lossyScale; position = new Vector3(x / plScale.x, y / plScale.y, z / plScale.z); if (isUnityPrimitive) { Vector3 primitiveOffset = new Vector3(transform.localScale.x * 0.5f - 0.5f, transform.localScale.y * 0.5f - 0.5f, transform.localScale.z * 0.5f - 0.5f); position += primitiveOffset; } transform.localPosition = position; InitializeResources(); if (isTray(myURL)) { isTrayObject = true; FarmTray script = GetComponent <FarmTray>(); script.node = node; script.PopulateTray(); } // Check for children, and create as necessary if (node["children"] == null) { return; } JSONArray children = node["children"].AsArray; foreach (JSONNode child in children) { GameObject toCreate = genericFarmObject; // Check type for tray vs generic if (isTray(child)) { toCreate = trayFarmObject; } // Instantiate correct object GameObject childObject = Instantiate(toCreate) as GameObject; // Set parent childObject.transform.GetComponent <FarmObject>().parentTransform = transform; childrenTransforms.Add(childObject.transform); // Call setup childObject.GetComponent <FarmObject>().Build(child); } }