public override void Tap() { Debug.Log ("ProgressBarWhenTapped Tap!"); base.Tap(); if (isTapped) { UnTap(); return; } isTapped = true; double maxRatio = -1; WorkInProgress workInProgress = null; GamePlayer player = GamePlayerManager.Instance.LoggedInPlayer; InProgress = GamePlayerLogic.Instance.GetCurrentWorkItemsForProductionItem(player, BuildableItem); foreach(WorkInProgress wip in InProgress) { double ratio = GamePlayerLogic.Instance.GetPercentageCompleteForWorkItem(wip); if (ratio > maxRatio) { workInProgress = wip; maxRatio = ratio; } } guiItemBox = GUIItemFactory<GUIBox>.Instance.Pool.New(); guiItemBox.SetRectangle(transform.position.x - 2f, transform.position.y - 0.1f, 0.3f, 0.3f, true, ScaleMode.StretchToFill); guiItemBox.Element = ProgressBarElement; guiItemBox.Style = LightweightResourceManager<GUIStyle>.Instance.Get(ResourceEnum.GUISTYLE_BASIC_STYLE); guiItemBox.Visible = true; GUIStateManager.Instance.AddChild(guiItemBox); if (workInProgress != null) { progressBar = GUIItemFactory<WorkItemProgressBar>.Instance.Pool.New(); progressBar.Content.image = ResourceManager<Texture2D>.Instance.Load(ResourceEnum.TEXTURE_BAR_OUTER); progressBar.BarInner = ResourceManager<Texture2D>.Instance.Load(ResourceEnum.TEXTURE_BAR_INNER); progressBar.SetRectangle(0.05f, 0.05f, 0.2f, 0.05f, false, ScaleMode.StretchToFill); progressBar.Element = GUIElementEnum.ProgressBar; progressBar.Visible = true; progressBar.WorkInProgress = workInProgress; guiItemBox.AddChild(progressBar); } }
/// <summary> /// Loads the assets for the tutorial manager /// </summary> private void LoadAssets() { IsFinished = false; louieTextures = new List<Texture2D>(); louieTextures.Add(ResourceManager<Texture2D>.Instance.Load(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_0)); louieTextures.Add(ResourceManager<Texture2D>.Instance.Load(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_1)); louieTextures.Add(ResourceManager<Texture2D>.Instance.Load(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_2)); louieTextures.Add(ResourceManager<Texture2D>.Instance.Load(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_3)); louieTextures.Add(ResourceManager<Texture2D>.Instance.Load(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_4)); louieTextures.Add(ResourceManager<Texture2D>.Instance.Load(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_5)); louieTextures.Add(ResourceManager<Texture2D>.Instance.Load(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_6)); louieSound = ResourceManager<AudioClip>.Instance.Load(ResourceEnum.AUDIOCLIP_UNCLELOUIE); louieDialogueWindow = GUIItemFactory<GUIImage>.Instance.Pool.New(); louieDialogueWindow.Content.image = ResourceManager<Texture2D>.Instance.Load(ResourceEnum.TEXTURE_WIN_TUTORIAL_DIALOGUE); louieDialogueWindow.SetRectangle(0.32f, 0.15f, 0.67f, 0.4f, false, ScaleMode.StretchToFill); louieDialogueWindow.Element = GUIElementEnum.TutorialDialogueWindow; GUIStateManager.Instance.AddChild(louieDialogueWindow); louieDialogueBox = GUIItemFactory<GUIBox>.Instance.Pool.New(); louieDialogueBox.SetRectangle(0.05f, 0.05f, 0.58f, 0.3f, false, ScaleMode.ScaleToFit); louieDialogueBox.Element = GUIElementEnum.TutorialDialogueBox; louieDialogueBox.Style = LightweightResourceManager<GUIStyle>.Instance.Get(ResourceEnum.GUISTYLE_NO_BACKGROUND); louieDialogueWindow.AddChild(louieDialogueBox); moreTextButton = GUIItemFactory<GUIButton>.Instance.Pool.New(); moreTextButton.Content.image = ResourceManager<Texture2D>.Instance.Load(ResourceEnum.TEXTURE_ICON_MORE_TEXT); moreTextButton.SetRectangle(0.59f, 0.24f, 0.075f, 0.075f, false, ScaleMode.ScaleToFit); moreTextButton.Element = GUIElementEnum.TutorialMoreText; moreTextButton.Style = LightweightResourceManager<GUIStyle>.Instance.Get(ResourceEnum.GUISTYLE_NO_BACKGROUND); moreTextButton.OnClick = (gi) => { SetStage(currentStageIndex + 1); }; louieDialogueWindow.AddChild(moreTextButton); louieImage = GUIItemFactory<GUIImage>.Instance.Pool.New(); louieImage.Element = GUIElementEnum.TutorialLouie; GUIStateManager.Instance.AddChild(louieImage); }
/// <summary> /// Finishes the tutorial /// </summary> public void FinishTutorial() { IsFinished = true; // @TO DO Make sure we destroy all objects and clean everything up! ResourceManager<AudioClip>.Instance.UnLoad(ResourceEnum.AUDIOCLIP_UNCLELOUIE); ResourceManager<Texture2D>.Instance.UnLoad(ResourceEnum.TEXTURE_ICON_MORE_TEXT); ResourceManager<Texture2D>.Instance.UnLoad(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_0); ResourceManager<Texture2D>.Instance.UnLoad(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_1); ResourceManager<Texture2D>.Instance.UnLoad(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_2); ResourceManager<Texture2D>.Instance.UnLoad(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_3); ResourceManager<Texture2D>.Instance.UnLoad(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_4); ResourceManager<Texture2D>.Instance.UnLoad(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_5); ResourceManager<Texture2D>.Instance.UnLoad(ResourceEnum.TEXTURE_TUTORIAL_LOUIE_6); GUIStateManager.Instance.RemoveChild(GUIElementEnum.TutorialLouie); GUIStateManager.Instance.RemoveChild(GUIElementEnum.TutorialDialogueWindow); louieDialogueWindow.Destroy(); louieDialogueBox.Destroy(); louieImage.Destroy(); moreTextButton.Destroy(); louieDialogueBox = null; louieImage = null; moreTextButton = null; stages.Clear (); stages = null; currentStage = null; sayings = null; louieTextures.Clear (); louieTextures = null; }
public override void UnTap() { Debug.Log ("ProgressBarWhenTapped UnTap!"); base.UnTap(); if (!isTapped) { return; } if (progressBar != null) { guiItemBox.RemoveChild(GUIElementEnum.ProgressBar); progressBar.Destroy(); progressBar = null; ResourceManager<Texture2D>.Instance.UnLoad(ResourceEnum.TEXTURE_BAR_OUTER); ResourceManager<Texture2D>.Instance.UnLoad(ResourceEnum.TEXTURE_BAR_INNER); } guiItemBox.Destroy(); guiItemBox = null; GUIStateManager.Instance.RemoveChild(ProgressBarElement); isTapped = false; Debug.Log(DateTime.Now + ": UnTapped"); }