private void StartAnimation() { GameObject loadedObject = Resources.Load(currentCutscene) as GameObject; GameObject go = GameObjectUtils.AddChildGUI(gameObject, loadedObject); go.GetComponent <CutsceneController>().Play(); }
// Either refreshes current page, or shows a new page given page number private void ShowPage(int inventoryPage) { // Destroy children beforehand foreach (Transform slot in decoInventorySlotList) { foreach (Transform child in slot) // Auto detect all/none children { Destroy(child.gameObject); } } int startingIndex = inventoryPage * inventoryPageSize; int endingIndex = startingIndex + inventoryPageSize; for (int i = startingIndex; i < endingIndex; i++) { if (AllDecoInvItems.Count == i) // Reached the end of list { break; } else { GameObject inventoryToken = GameObjectUtils.AddChildGUI(decoInventorySlotList[i % inventoryPageSize].gameObject, decoInventoryTokenPrefab); inventoryToken.GetComponent <InventoryTokenController>().Init(AllDecoInvItems[i]); } } }
//When the scene starts Initialize all the badges once private void InitBadges() { List <ImmutableDataBadge> badges = BadgeManager.Instance.AllBadges; var query = from badge in badges group badge by badge.Type into badgeGroup select new { Key = badgeGroup.Key, Elements = from badge2 in badgeGroup orderby badge2.UnlockCondition ascending select badge2 }; foreach (var group in query) { foreach (var badge in group.Elements) { GameObject badgeGO = GameObjectUtils.AddChildGUI(badgeGrid.gameObject, badgePrefab); badgeGO.name = badge.ID; badgeGO.GetComponent <BadgeController>().Init(badge); } } }
public void SpawnComboFloaty(Vector3 position, int combo) { string comboText = string.Format(Localization.Localize("NINJA_COMBO"), combo); GameObject floatyObject = GameObjectUtils.AddChildGUI(FloatyParent, FloatyComboPrefab); floatyObject.GetComponent <FloatyController>().InitAndActivate(position, customText: comboText); }
// Actual implementation of the result of two gestures public void GesturePassAction() { isGestureRecognized = true; //Disable hint when swipe gesture is registered. GetComponent <HintController>().DisableHint(false); LgInhalerAnimationEventHandler.BreatheInEndEvent += BreatheInEndEventHandler; AudioManager.Instance.PlayClip("inhalerInhale"); petAnimator.SetTrigger("BreatheIn"); // Spawn Hold breath floaty GameObject breathFloaty = GameObjectUtils.AddChildGUI(floatyParent, floatyBreatheInPrefab); breathFloaty.GetComponent <UGUIFloaty>().StartFloatyLocal(Localization.Localize("INHALER_FLOATY_HOLD_BREATH"), 3f, new Vector3(0, 100)); if (finish != null) { finish(this, EventArgs.Empty); } InhalerBodyMoveAnimation.Play(); // Custom override to show the last step InhalerGameUIManager.Instance.NextStepUI(8); GetComponent <HintController>().DisableHint(false); }
protected override void ProcessStep(int step) { switch (step) { case 0: // spawn each trigger trigger1Object = NinjaGameManager.Instance.SpawnTriggersTutorial(1); trigger2Object = NinjaGameManager.Instance.SpawnTriggersTutorial(2); trigger3Object = NinjaGameManager.Instance.SpawnTriggersTutorial(3); trigger4Object = NinjaGameManager.Instance.SpawnTriggersTutorial(4); trigger5Object = NinjaGameManager.Instance.SpawnTriggersTutorial(5); trigger6Object = NinjaGameManager.Instance.SpawnTriggersTutorial(6); //listen to when trigger gets cut trigger1Object.GetComponent <NinjaTrigger>().NinjaTriggerCut += NinjaTriggerFirstCutEventHandler; trigger2Object.GetComponent <NinjaTrigger>().NinjaTriggerCut += NinjaTriggerFirstCutEventHandler; trigger3Object.GetComponent <NinjaTrigger>().NinjaTriggerCut += NinjaTriggerFirstCutEventHandler; trigger4Object.GetComponent <NinjaTrigger>().NinjaTriggerCut += NinjaTriggerFirstCutEventHandler; trigger5Object.GetComponent <NinjaTrigger>().NinjaTriggerCut += NinjaTriggerFirstCutEventHandler; trigger6Object.GetComponent <NinjaTrigger>().NinjaTriggerCut += NinjaTriggerFirstCutEventHandler; //play swipe tutorial GameObject swipeTutPrefab = (GameObject)Resources.Load("NinjaTutorialUI"); swipeTutObject = GameObjectUtils.AddChildGUI(GameObject.Find("Canvas"), swipeTutPrefab); swipeTutAnimator = swipeTutObject.FindInChildren("AnimationParent").GetComponent <Animator>(); swipeTutAnimator.Play("NinjaTutorialUI"); break; default: Debug.LogError("Ninja tutorial has an unhandled step: " + step); break; } }
protected void SpawnFloatyCoin() { Vector3 playerPos = PlayerController.Instance.FloatyLocation.transform.position; GameObject starFloaty = GameObjectUtils.AddChildGUI(RunnerGameManager.Instance.floatyParent.gameObject, RunnerGameManager.Instance.floatyPrefabCoin); //Because Canvas is a Screen Space - Camera there is no need for WorldToScreenSpace starFloaty.GetComponent <UGUIFloaty>().StartFloaty(playerPos, "", 0.5f, new Vector3(0, 10)); }
private void ShowSpeechWithText(Hashtable message) { currentSpeech = GameObjectUtils.AddChildGUI(parentCanvas.gameObject, speechTextPrefab); string textStringAux = message.ContainsKey(SpeechKeys.MessageText) ? (string)message[SpeechKeys.MessageText] : null; currentSpeech.GetComponent <SpeechBubble>().Init(textString: textStringAux); }
/// <summary> /// Any floaties that has to do with the pets go here /// </summary> public void CreateStatsFloaty(int deltaPoints, int deltaHealth, int deltaMood, int deltaStars) { GameObject floaty = GameObjectUtils.AddChildGUI(petCanvas.gameObject, petStatsFloatyPrefab); UGUIFloatyPetStats floatyScript = floaty.GetComponent <UGUIFloatyPetStats>(); floatyScript.Init(deltaPoints, deltaHealth, deltaMood, deltaStars); floatyScript.StartFloatyLocal(null, 1f, new Vector3(0, 100, 0)); }
private void ShowSpeechWithImage(Hashtable message) { currentSpeech = GameObjectUtils.AddChildGUI(parentCanvas.gameObject, speechImagePrefab); string imageSpriteAux = message.ContainsKey(SpeechKeys.ImageTextureName) ? (string)message[SpeechKeys.ImageTextureName] : null; GameObject objectToCall = message.ContainsKey(SpeechKeys.ImageClickTarget) ? (GameObject)message[SpeechKeys.ImageClickTarget] : null; string functionNameToCall = message.ContainsKey(SpeechKeys.ImageClickFunctionName) ? (string)message[SpeechKeys.ImageClickFunctionName] : null; UIModeTypes modeTypeAux = UIModeTypes.None; currentSpeech.GetComponent <SpeechBubble>().Init(imageSprite: imageSpriteAux, _objectToCall: objectToCall, _functionNameToCall: functionNameToCall, _modeType: modeTypeAux); }
//Refresh high score private void RefreshScoreBoard() { GameObject highScoreEntryPrefab = (GameObject)Resources.Load("HighScoreEntry"); Dictionary <string, int> highScoreDict = HighScoreManager.Instance.MinigameHighScore; foreach (KeyValuePair <string, int> score in highScoreDict) { GameObject highScoreEntryGO = GameObjectUtils.AddChildGUI(scoreBoardGrid.gameObject, highScoreEntryPrefab); highScoreEntryGO.GetComponent <HighScoreEntryUIController>().Init(score.Key, score.Value); } }
// Loads the prefab and inits the prefab's PopupController values public IEnumerator ShowPopup(string prefabName, string title, string message, PopupController.Callback specialButtonCallback) { GameObject popupRef = Resources.Load <GameObject>(prefabName); GameObject popup = GameObjectUtils.AddChildGUI(gameObject, popupRef); PopupController controller = popup.GetComponent <PopupController>(); controller.Init(title, message, specialButtonCallback); yield return(0); // Wait a frame for the popup to finish controller.ShowPopup(); }
// in each case we are going to listen to events that tell us to move along protected override void ProcessStep(int nStep) { switch (nStep) { //runs for about 4 sec then starts the game the timer is in the memory game manager case 0: MemoryGameManager.Instance.proceed += MoveAlong; //prompt user to shoot memoryCards = (GameObject)Resources.Load("MemoryTut"); tutBoards = GameObjectUtils.AddChildGUI(GameObject.Find("Canvas"), memoryCards); break; } }
public void ShowRetentionPet(bool isFlipped, Vector3 position) { RemoveRetentionPet(); GameObject goResource = Resources.Load("TutorialRetentionPet") as GameObject; goRetentionPet = GameObjectUtils.AddChildGUI(TutorialManager.Instance.UICanvasParent, goResource); goRetentionPet.transform.localPosition = position; if (isFlipped) { goRetentionPet.transform.localScale = new Vector3(-1f, 1f, 1f); } }
/// <summary> /// Spawns one sprite for the visual curve. /// </summary> IEnumerator SpawnOneSprite(GameObject tweenParent, float delay, StatType statType, Vector3 fromPos, Vector3 toPos, float duration, bool isPlusAnimation, string strSound, Hashtable hashSoundOverrides) { yield return(new WaitForSeconds(delay)); if (!string.IsNullOrEmpty(strSound)) { AudioManager.Instance.PlayClip(strSound, option: hashSoundOverrides); } // Modify some tweening behaviors based on adding or subtracting a stat if (isPlusAnimation) { GameObject go = GameObjectUtils.AddChildGUI(HUDUIManager.Instance.GetStatTweenParents(statType), tweenSpritePrefab); // GameObject go = GameObjectUtils.AddChildGUI(gameObject, tweenSpritePrefab); go.transform.localPosition = GameObjectUtils.GetRandomPointOnCircumference(go.transform.localPosition, 200f); // go.transform.localPosition = fromPos; go.GetComponent <Image>().sprite = SpriteCacheManager.GetHudTweenIcon(statType); // Addition tweening behavior // Vector3[] path = new Vector3[4]; // path[0] = go.transform.localPosition; // Vector3 randomPoint = GameObjectUtils.GetRandomPointOnCircumference(go.transform.localPosition, 200f); // path[1] = randomPoint; // path[2] = path[1]; // path[3] = toPos; // LeanTween.moveLocal(go, path, duration) // .setEase(customEaseCurve) // .setOnComplete(StatTick).setOnCompleteParam(statType) // .setDestroyOnComplete(true); // Just tweening from circumference for now LeanTween.moveLocal(go, toPos, duration) .setEase(customEaseCurve) .setOnComplete(StatTick).setOnCompleteParam(statType) .setDestroyOnComplete(true); } else { // Negative anim, just jump to tick and bar animate StatTick(statType); } }
protected void ShowFingerHint(GameObject goTarget, bool isGUI = false, InterfaceAnchors GUIanchor = InterfaceAnchors.Center, BedroomTutFingerController.FingerState fingerState = BedroomTutFingerController.FingerState.Press, float offsetX = 0.0f, float offsetY = 60.0f, bool flipX = false) { RemoveFingerHint(); // get the proper location of the object we are going to focus on Vector3 focusPos = Vector3.zero; if (!isGUI) { // WorldToScreen returns screen coordinates based on 0,0 being bottom left, so we need to transform those into NGUI center focusPos = CameraManager.Instance.WorldToScreen(CameraManager.Instance.CameraMain, goTarget.transform.position); // Camera.main.WorldToScreenPoint( goTarget.transform.position ); focusPos = CameraManager.Instance.TransformAnchorPosition(focusPos, InterfaceAnchors.BottomLeft, InterfaceAnchors.Center); } GameObject fingerHintResource = (GameObject)Resources.Load("BedroomTutFinger"); goFingerHint = GameObjectUtils.AddChildGUI(TutorialManager.Instance.UICanvasParent, fingerHintResource); focusPos.x = focusPos.x + offsetX; focusPos.y = focusPos.y + offsetY; //offset in Y so the finger hint doesn't overlap the image focusPos.z = 0f; goFingerHint.transform.localPosition = focusPos; if (isGUI) { RectTransform rect = goFingerHint.GetComponent <RectTransform>(); GameObjectUtils.SetAnchor(ref rect, GUIanchor); rect.anchoredPosition = new Vector2(offsetX, offsetY); } if (flipX) { goFingerHint.transform.localScale = new Vector3(-1, 1, 1); } goFingerHint.GetComponent <BedroomTutFingerController>().PlayState(fingerState); }
/// <summary> /// Display the tutorial popup, messages are loaded automatically unless overridden /// </summary> protected void ShowPopup(string popupPrefabKey, Vector3 localPosition, string customMessage = null) { RemovePopup(); // Create the popup GameObject goResource = Resources.Load(popupPrefabKey) as GameObject; goPopup = GameObjectUtils.AddChildGUI(TutorialManager.Instance.UICanvasParent, goResource); goPopup.transform.localPosition = localPosition; // Populate popup text Text popupText = goPopup.GetComponentInChildren <Text>(); if (!string.IsNullOrEmpty(customMessage)) // Check if message needs to be overridden { popupText.text = customMessage; } else // Get text to display from tutorial key + step { popupText.text = Localization.Localize(GetKey() + "_" + CurrentStep); } }
public void SpawnFinger(int zone) { lastPress = 0; tutorialZone = zone; if (finger == null) { finger = GameObjectUtils.AddChildGUI(mainCanvas.gameObject, pointerPrefab).GetComponent <FingerController>(); finger.transform.SetSiblingIndex(2); } else { LeanTween.cancel(finger.gameObject); } if (tutorialZone == 3) { finger.transform.position = GetCorrectTransform().position; //GetButtonTransform((int)assemblyLineController.PeekFirstItem().ItemType).transform.position; } else { finger.transform.position = GetButtonTransform(tutorialZone).position; } multipleFinger = finger.RepeatShake(3 - tutorialZone, new Vector3(0, 20)); StartCoroutine(multipleFinger); }
private void CreateStoreItem(GameObject goGrid, GameObject goPrefab, Item item) { GameObject itemUIObject = GameObjectUtils.AddChildGUI(goGrid, goPrefab); itemUIObject.GetComponent <StoreItemController>().Init(item); }
/// <summary> /// <para>Puts a spotlight around the incoming object to /// draw attention to it. /// eAnchor is the incoming anchor of the object/where /// the spotlight should be created. For 3D objects /// the anchor should be center, and for GUI elements /// the anchor should be whatever anchor the element /// is in.</para> /// /// Params: /// goTarget (GameObject): the target that you want the spotlight to spawn on /// /// /// NOTE: If it is 3D object goTarget needs to != null /// </summary> protected void SpotlightObject(GameObject goTarget = null, bool isGUI = false, InterfaceAnchors GUIanchor = InterfaceAnchors.Center, bool hasFingerHint = false, BedroomTutFingerController.FingerState fingerState = BedroomTutFingerController.FingerState.Press, float spotlightOffsetX = 0f, float spotlightOffsetY = 0f, float fingerOffsetX = 0f, float fingerOffsetY = 60f, bool fingerHintFlip = false, float delay = -1f) { RemoveSpotlight(); RemoveFingerHint(); // get the proper location of the object we are going to focus on Vector3 focusPos = Vector3.zero; if (!isGUI) { // WorldToScreen returns screen coordinates based on 0,0 being bottom left, so we need to transform those into NGUI center focusPos = CameraManager.Instance.WorldToScreen(CameraManager.Instance.CameraMain, goTarget.transform.position); focusPos = CameraManager.Instance.TransformAnchorPosition(focusPos, InterfaceAnchors.BottomLeft, InterfaceAnchors.Center); } // Adjust for custom offset focusPos = new Vector3(focusPos.x + spotlightOffsetX, focusPos.y + spotlightOffsetY, focusPos.z); // Create the spotlight GameObject goResource = Resources.Load("TutorialSpotlight") as GameObject; goSpotlight = GameObjectUtils.AddChildGUI(TutorialManager.Instance.UICanvasParent, goResource); // Set the delay if defined if (delay > 0) { goSpotlight.GetComponent <AlphaTweenToggle>().showDelay = delay; } // Move the spotlight into position goSpotlight.transform.localPosition = focusPos; if (isGUI) { RectTransform rect = goSpotlight.GetComponent <RectTransform>(); GameObjectUtils.SetAnchor(ref rect, GUIanchor); rect.anchoredPosition = new Vector2(spotlightOffsetX, spotlightOffsetY); } // Spawn finger hint if (hasFingerHint) { if (isGUI) { ShowFingerHint(goTarget, isGUI: isGUI, GUIanchor: GUIanchor, fingerState: fingerState, offsetX: fingerOffsetX + spotlightOffsetX, offsetY: fingerOffsetY + spotlightOffsetY, flipX: fingerHintFlip); } else { ShowFingerHint(goTarget, isGUI: isGUI, GUIanchor: GUIanchor, fingerState: fingerState, offsetX: fingerOffsetX, offsetY: fingerOffsetY, flipX: fingerHintFlip); } } // Show the backdrop goSpotlight.GetComponent <AlphaTweenToggle>().ShowAfterInit(); }