void Awake() { m_Instance = this; // create factories m_Factories = new IPromoFactory[] { new PromoFactory <BrushSizePromo>(PromoType.BrushSize, "BrushSize"), new PromoFactory <ShareSketchPromo>(PromoType.ShareSketch, "ShareSketch"), new PromoFactory <FloatingPanelPromo>(PromoType.FloatingPanel, "FloatingPanel"), new PromoFactory <SelectionPromo>(PromoType.Selection, "Selection"), new PromoFactory <DuplicatePromo>(PromoType.Duplicate, "Duplicate"), new PromoFactory <InteractIntroPanelPromo>(PromoType.InteractIntroPanel, "InteractIntroPanel"), new PromoFactory <SaveIconPromo>(PromoType.SaveIcon, "SaveIcon"), new PromoFactory <DeselectionPromo>(PromoType.Deselection, "Deselection"), new PromoFactory <AdvancedPanelsPromo>(PromoType.AdvancedPanels, "AdvancedPanels"), }.ToDictionary(f => f.InstanceType); m_RequestedPromos = new HashSet <BasePromo>(); GameObject obj = (GameObject)GameObject.Instantiate(m_HintLinePrefab); m_HintLine = obj.GetComponent <HintArrowLineScript>(); obj.SetActive(false); m_ButtonHighlightMesh = (GameObject)Instantiate(m_ButtonHighlightPrefab); m_ButtonHighlightMeshBasePos = m_ButtonHighlightMesh.transform.localPosition; m_ButtonHighlightMeshBaseScale = m_ButtonHighlightMesh.transform.localScale; m_ButtonHighlightMesh.SetActive(false); if (App.UserConfig.Testing.ResetPromos) { foreach (var factory in m_Factories.Values) { PlayerPrefs.DeleteKey(factory.PrefsKey); } } }
public void UpdateIntroTutorial() { switch (m_IntroState) { case IntroTutorialState.ActivateBrush: ActivateControllerTutorial(InputManager.ControllerName.Brush, true); ActivateControllerTutorial(InputManager.ControllerName.Wand, false); IntroState = IntroTutorialState.WaitForBrushStrokeStart; break; case IntroTutorialState.WaitForBrushStrokeStart: if (PointerManager.m_Instance.IsMainPointerCreatingStroke()) { IntroState = IntroTutorialState.WaitForBrushStrokeEnd; } break; case IntroTutorialState.WaitForBrushStrokeEnd: if (PointerManager.m_Instance.IsMainPointerCreatingStroke()) { // Lazy init of initial painting position. if (!m_IntroPaintWasPainting) { m_IntroPaintLastPos = InputManager.Brush.Transform.position; m_IntroPaintMovementAmount = 0.0f; m_IntroPaintWasPainting = true; } else { // Increase our painting distance with the movement diff. Vector3 brushPos = InputManager.Brush.Transform.position; float fPrevAmount = m_IntroPaintMovementAmount; m_IntroPaintMovementAmount += Vector3.Distance(brushPos, m_IntroPaintLastPos); m_IntroPaintLastPos = brushPos; // If we went far enough, shine a bit. if (fPrevAmount < m_IntroPaintRegisterDistance && m_IntroPaintMovementAmount >= m_IntroPaintRegisterDistance) { AudioManager.m_Instance.TriggerOneShot(m_IntroBeginSound, InputManager.m_Instance.GetControllerPosition(InputManager.ControllerName.Brush), 1.0f); DisableControllerTutorial(InputManager.ControllerName.Brush); } } } else if (!PointerManager.m_Instance.IsMainPointerCreatingStroke()) { // If we're not painting, move on if we've painted far enough. m_IntroPaintWasPainting = false; if (m_IntroPaintMovementAmount >= m_IntroPaintRegisterDistance) { IntroState = IntroTutorialState.SwipeToUnlockPanels; } } break; case IntroTutorialState.SwipeToUnlockPanels: ActivateControllerTutorial(InputManager.ControllerName.Wand, true); m_IntroSwipeTotal = 0.0f; IntroState = IntroTutorialState.WaitForSwipe; break; case IntroTutorialState.WaitForSwipe: m_IntroSwipeTotal += InputManager.m_Instance.GetAdjustedWandScrollAmount(); if (Mathf.Abs(m_IntroSwipeTotal) > m_IntroSwipeAdvanceAmount) { DisableControllerTutorial(InputManager.ControllerName.Wand); IntroState = IntroTutorialState.ActivatePanels; } break; case IntroTutorialState.ActivatePanels: SketchControlsScript.m_Instance.RequestPanelsVisibility(true); m_IntroStateCountdown = m_IntroPointHintDelay; IntroState = IntroTutorialState.DelayForPointToPanelHint; break; case IntroTutorialState.DelayForPointToPanelHint: // If we're waiting to tell the user how to interact with the UI and they do it already, // skip that step. if (SketchControlsScript.m_Instance.IsUserInteractingWithUI()) { IntroState = IntroTutorialState.Done; // The player can now be considered to have 'played the game'. PlayerPrefs.SetInt(App.kPlayerPrefHasPlayedBefore, 1); PromoManager.m_Instance.RequestPromo(PromoType.BrushSize); break; } m_IntroStateCountdown -= Time.deltaTime; if (m_IntroStateCountdown <= 0.0f) { GameObject obj = (GameObject)Instantiate(m_PointHintPrefab); m_IntroPointHintArrowLine = obj.GetComponent <HintArrowLineScript>(); InputManager.m_Instance.TriggerHapticsPulse(InputManager.ControllerName.Brush, 4, 0.15f, 0.1f); EnablePointAtPanelHint(true); IntroState = IntroTutorialState.WaitForPanelInteract; } break; case IntroTutorialState.WaitForPanelInteract: // Keep hint arrow line connected to the pointer and nearest panel center. AlignPointLineToPanels(); if (SketchControlsScript.m_Instance.IsUserInteractingWithUI()) { m_IntroPointHintArrowLine.Reset(); Destroy(m_IntroPointHintArrowLine); m_IntroPointHintArrowLine = null; EnablePointAtPanelHint(false); IntroState = IntroTutorialState.Done; // The player can now be considered to have 'played the game'. PlayerPrefs.SetInt(App.kPlayerPrefHasPlayedBefore, 1); PromoManager.m_Instance.RequestPromo(PromoType.BrushSize); } break; // Special case for viewing only modes. Like Tilt Brush Gallery RIP. case IntroTutorialState.InitializeForNoCreation: SketchControlsScript.m_Instance.RequestPanelsVisibility(true); IntroState = IntroTutorialState.Done; break; } }