public static new VirtualButton ButtonPromptToVirtualButton(ButtonPrompt prompt) { if (controlsIDToButton.TryGetValue(prompt, out VirtualButton btn)) { return(btn); } return(orig_ButtonPromptToVirtualButton(prompt)); }
void Awake() { controls = new InputMaster(); player = FindObjectOfType <PlayerController>(); if (prompt == null) { prompt = GetComponentInChildren <ButtonPrompt>(); } }
private void CheckCurrentSelection() { // select current interaction object going through the list if (CurrentObject != null && !IsCharCloserThan(CurrentObject, 1.5f)) { DeselectCurrentObject(CurrentObject); } float closestDistToCenter = Mathf.Infinity; IInteractableObject closestInteraction = null; foreach (var interactionPair in interactionObjects) { IInteractableObject iObject = interactionPair.Key; ButtonPrompt promtObject = interactionPair.Value; //if (!iObject.isVisible()) // continue; //if (!promtObject.IsVisible) // continue; bool showText = LightStatesMachine.Instance.IsLightOn() && !iObject.IsInteracting; if (iObject is DoorInteraction) { showText = true; } UpdatePromtButton(showText, iObject, promtObject); Vector3 viewPos = Camera.main.WorldToViewportPoint(iObject.transform.position); float distance = Vector2.Distance(viewPos, Vector2.one * 0.5f); bool isRealClose = IsCharCloserThan(iObject, 1.5f); if (distance < closestDistToCenter && isRealClose) { closestDistToCenter = distance; closestInteraction = iObject; } } if (closestInteraction == null) { return; } // switching to the new interactable object if (CurrentObject != closestInteraction) { if (CurrentObject != null) { DeselectCurrentObject(CurrentObject); } SelectCurrentObject(closestInteraction); } }
private void UpdatePromtButton(bool showText, IInteractableObject iObject, ButtonPrompt promtObject) { if (IsInteracting) { showText = false; } string textToOutput = iObject.IsSelected ? iObject.ActionsToDisplay : iObject.TextToDisplay; promtObject.SetText(showText ? textToOutput : ""); promtObject.setInteractableUI(iObject.IsSelected && !IsInteracting); }
// Use this for initialization void Start() { _invulnerable = false; _vitalityAdjustment = 0; _animator = GetComponent<Animator>(); _promptBehavior = ButtonPrompt.GetComponent<ButtonPrompt>(); _startingVitality = CurrentVitality; _hawkSpwner = FindObjectOfType<HawkSpwner>(); MatingZone.onGain += OnGain; foreach(var enemy in _hawkSpwner.enemies) { enemy.GetComponent<HawkBehavior>().PlayerHit += OnPlayerHit; } }
public static void AddHUDButtons(GameObject buttonBP, float baseX, float baseY) { int index = 0; foreach (KeyValuePair <string, string> bData in buttonConfig) { GameObject buttonGO = NGUITools.AddChild(paHUD, buttonBP); buttonGO.name = "PA_Button_" + bData.Key; ButtonPrompt button = buttonGO.transform.GetComponent <ButtonPrompt>(); string label = buttonLabels[bData.Key]; button.UpdatePromptLabel(label); button.m_KeyboardButtonLabel.text = bData.Value; if (bData.Key == "CONFORM") { conformButton = button; } else if (bData.Key == "SNAP") { snapButton = button; } if (bData.Value == "SHIFT") { button.m_KeyboardButtonSprite.transform.localScale = new Vector3(2.6f, 1f, 1f); } if (bData.Value == "LEFT ALT") { button.m_KeyboardButtonSprite.transform.localScale = new Vector3(3.0f, 1f, 1f); } float posX = baseX + ((index % 2) * 110f); float posY = baseY - (Mathf.Floor(index / 2) * 80); buttonGO.transform.localPosition = new Vector3(posX, posY, 0); buttonList.Add(button); index++; } }
private void OnInteractionEnter(IInteractableObject interactionObject) { if (interactionObjects.ContainsKey(interactionObject)) { return; } GameObject promtPrefab = UIManager.Instance.m_buttonPromtPrefab; GameObject promtGO = Instantiate(promtPrefab) as GameObject; ButtonPrompt buttonPrompt = promtGO.GetComponent <ButtonPrompt>(); buttonPrompt.SetText(""); buttonPrompt.SetConnectedTransform(interactionObject.transform); // setting the object under Canvas //promtGO.transform.SetParent(UIManager.s_canvas.transform); //promtGO.transform.localScale = Vector3.one; interactionObjects.Add(interactionObject, buttonPrompt); interactionObject.onInteractionDestroyed += OnInteractionDestroyed; interactionObject.onInteractionDisabled += OnInteractionDisabled; }
private void UpdatePromtButton(bool showText, IInteractableObject iObject, ButtonPrompt promtObject) { if(IsInteracting) showText = false; string textToOutput = iObject.IsSelected ? iObject.ActionsToDisplay : iObject.TextToDisplay; promtObject.SetText (showText ? textToOutput : ""); promtObject.setInteractableUI(iObject.IsSelected && !IsInteracting); }
public static extern VirtualButton orig_ButtonPromptToVirtualButton(ButtonPrompt prompt);
void Start() { prompt = GetComponent <ButtonPrompt>(); prompt.OnCorrect.AddListener(WinState); }