/*--------------------------------------------------------------------------------------------*/ public void Start() { if (vFailed) { return; } vMenuState = new MenuState(InputProvider, NavigationProvider.GetRoot(), CustomizationProvider.GetInteractionSettings()); var menuObj = new GameObject("Menu"); menuObj.transform.SetParent(gameObject.transform, false); vUiMenu = menuObj.AddComponent <UiMenu>(); vUiMenu.Build(vMenuState, CustomizationProvider, CustomizationProvider); var cursorObj = new GameObject("Cursor"); cursorObj.transform.SetParent(gameObject.transform, false); vUiCursor = cursorObj.AddComponent <UiCursor>(); vUiCursor.Build(vMenuState.Arc, vMenuState.Cursor, CustomizationProvider, OptionalCameraReference); ((HovercastState)State).SetReferences(vMenuState, menuObj.transform, cursorObj.transform); }
public override void Unload() { if (Main.dedServ) { return; } _bossCursorUserInterface = null; _uiCursor = null; }
public override void Load() { if (Main.dedServ) { return; } _uiCursor = new UiCursor(); _uiCursor.Activate(); _bossCursorUserInterface = new UserInterface(); _bossCursorUserInterface.SetState(_uiCursor); }
/*--------------------------------------------------------------------------------------------*/ public void Update() { if (vState == null || Input.IsFailure) { return; } vState.UpdateBeforeInput(); Input.UpdateInput(); vState.UpdateAfterInput(); ReadOnlyCollection <CursorType> activeTypes = vState.ActiveCursorTypes; ICursorSettings visualSett = DefaultVisualSettings.GetSettings(); Transform cameraTx = CenterCamera.gameObject.transform; CursorTypeUtil.Exclude(vPrevActiveCursorTypes, activeTypes, vHideCursorTypes); CursorTypeUtil.Exclude(activeTypes, vPrevActiveCursorTypes, vShowCursorTypes); foreach (CursorType type in vHideCursorTypes) { vCursorMap[type].gameObject.SetActive(false); } foreach (CursorType type in vShowCursorTypes) { if (vCursorMap.ContainsKey(type)) { vCursorMap[type].gameObject.SetActive(true); continue; } ICursorState cursor = vState.GetCursorState(type); var cursorObj = new GameObject("Cursor-" + type); cursorObj.transform.SetParent(gameObject.transform, false); UiCursor uiCursor = cursorObj.AddComponent <UiCursor>(); uiCursor.Build(cursor, visualSett, cameraTx); vCursorMap.Add(type, uiCursor); vState.SetCursorTransform(type, cursorObj.transform); } vPrevActiveCursorTypes.Clear(); vPrevActiveCursorTypes.AddRange(activeTypes); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void Awake() { if (NavDelegateProvider == null) { throw new Exception("HovercastSetup.NavDelegateProvider must be set."); } if (SettingsProvider == null) { throw new Exception("HovercastSetup.SettingsProvider must be set."); } if (InputProvider == null) { throw new Exception("HovercastSetup.InputProvider must be set."); } if (OptionalCameraReference == null) { OptionalCameraReference = gameObject.transform; } vNavProv = new NavProvider(); vNavProv.Init(NavDelegateProvider.GetNavDelegate()); vMenuState = new MenuState(InputProvider, vNavProv, SettingsProvider.GetInteractionSettings()); //// var menuObj = new GameObject("Menu"); menuObj.transform.SetParent(gameObject.transform, false); vUiMenu = menuObj.AddComponent <UiMenu>(); vUiMenu.Build(vMenuState, SettingsProvider); var cursorObj = new GameObject("Cursor"); cursorObj.transform.SetParent(gameObject.transform, false); vUiCursor = cursorObj.AddComponent <UiCursor>(); vUiCursor.Build(vMenuState.Arc, vMenuState.Cursor, SettingsProvider, OptionalCameraReference); }
/*--------------------------------------------------------------------------------------------*/ public void Update() { if (vState == null || Input.IsFailure) { return; } vState.UpdateBeforeInput(); Input.UpdateInput(); vState.UpdateAfterInput(); CursorType[] activeTypes = vState.ActiveCursorTypes; IEnumerable <CursorType> hideTypes = vPrevActiveCursorTypes.Except(activeTypes); IEnumerable <CursorType> showTypes = activeTypes.Except(vPrevActiveCursorTypes); ICursorSettings visualSett = DefaultVisualSettings.GetSettings(); foreach (CursorType type in hideTypes) { vCursorMap[type].gameObject.SetActive(false); } foreach (CursorType type in showTypes) { if (vCursorMap.ContainsKey(type)) { vCursorMap[type].gameObject.SetActive(true); continue; } ICursorState cursor = vState.GetCursorState(type); var cursorObj = new GameObject("Cursor-" + type); cursorObj.transform.SetParent(gameObject.transform, false); UiCursor uiCursor = cursorObj.AddComponent <UiCursor>(); uiCursor.Build(cursor, visualSett, CameraTransform); vCursorMap.Add(type, uiCursor); vState.SetCursorTransform(type, cursorObj.transform); } vPrevActiveCursorTypes = activeTypes; }