public void UpdateHelp() { // initialize if (helpContainer.activeSelf && helpTimerCoroutine != null) { StopCoroutine(helpTimerCoroutine); } foreach (Transform child in helpContainer.transform) { Destroy(child.gameObject); } // create items to show and place them Vector3 position = new Vector3(-0.5f * helpSpacing * (interactionConditionList.Count - 1), 0, 0); foreach (KeyValuePair <string, string> entry in interactionConditionList) { InteractionConditionTemplate go = Instantiate(template, helpContainer.transform); go.transform.localPosition = position; go.gameObject.SetActive(true); if (ToolDictionary.instance.tools.ContainsKey(entry.Key)) { go.mainIcon.sprite = ToolDictionary.instance.tools[entry.Key].icon; } else if (ResourceDictionary.instance.resources.ContainsKey(entry.Key)) { go.mainIcon.sprite = ResourceDictionary.instance.resources[entry.Key].icon; } else { Debug.Log("no tool icon for this entry : " + entry.Key); } if (entry.Value == "ok") { go.validationIcon.sprite = valid; go.specialText.gameObject.SetActive(false); go.validationIcon.gameObject.SetActive(true); } else if (entry.Value == "nok") { go.validationIcon.sprite = invalid; go.specialText.gameObject.SetActive(false); go.validationIcon.gameObject.SetActive(true); } else { go.specialText.text = entry.Value; go.specialText.gameObject.SetActive(true); go.validationIcon.gameObject.SetActive(false); } position.x += helpSpacing; } // start showing and start a timer for hiding helpTimerCoroutine = HelpTimer(helpDuration); StartCoroutine(helpTimerCoroutine); }
public void ThrowHelp(string icon, string help) { // initialize if (helpContainer.activeSelf && helpTimerCoroutine != null) { StopCoroutine(helpTimerCoroutine); } foreach (Transform child in helpContainer.transform) { Destroy(child.gameObject); } InteractionConditionTemplate go = Instantiate(template, helpContainer.transform); go.transform.localPosition = Vector3.zero; go.gameObject.SetActive(true); if (ToolDictionary.instance.tools.ContainsKey(icon)) { go.mainIcon.sprite = ToolDictionary.instance.tools[icon].icon; } else if (ResourceDictionary.instance.resources.ContainsKey(icon)) { go.mainIcon.sprite = ResourceDictionary.instance.resources[icon].icon; } else { Debug.Log("no tool icon for this entry : " + icon); } if (help == "ok") { go.validationIcon.sprite = valid; go.specialText.gameObject.SetActive(false); go.validationIcon.gameObject.SetActive(true); } else if (help == "nok") { go.validationIcon.sprite = invalid; go.specialText.gameObject.SetActive(false); go.validationIcon.gameObject.SetActive(true); } else { go.specialText.text = help; go.specialText.gameObject.SetActive(true); go.validationIcon.gameObject.SetActive(false); } // start showing and start a timer for hiding helpTimerCoroutine = HelpTimer(helpDuration); StartCoroutine(helpTimerCoroutine); }