public void RequestMove() { if (!gameObject.activeSelf || !enabled) { return; } if (playerInside) { if (barrelAnimator != null) { barrelAnimator.SetTrigger(moveBarrelTrigger); if (playSound && soundSourcePlayer != null) { soundSourcePlayer.Play(); } if (unityEventOnMoved && unityEvent != null) { unityEvent.Invoke(); } } else { Debug.LogError("No Animator given!", this); } } }
public override void OnInteraction(PlayerContext context) { string glassUniqueId = "glass_empty"; Item emptyGlassId = new Item(glassUniqueId, glassUniqueId, glassUniqueId, emptyGlass); InventoryController inventory = context.inventory; if (null != context.inventory.ContainsItem("glass_blue")) { ChangeSprite(blueSplash); value = RiddleColor.Blue; if (playSound) { if (soundSourcePlayer != null) { soundSourcePlayer.Play(); } } } else if (null != context.inventory.ContainsItem("glass_red")) { ChangeSprite(redSplash); value = RiddleColor.Red; if (playSound) { if (soundSourcePlayer != null) { soundSourcePlayer.Play(); } } } else if (null != context.inventory.ContainsItem("glass_green")) { ChangeSprite(greenSplash); value = RiddleColor.Green; if (playSound) { if (soundSourcePlayer != null) { soundSourcePlayer.Play(); } } } colorRiddleManager.UpdateState(key, value); }
public override void OnInteraction(PlayerContext context) { if (playSound) { if (soundSourcePlayer != null) { soundSourcePlayer.Play(); } } Item glass = GetGlassFromInventory(context); if (glass != null) { string uniqueId; string title; string description = "Jetzt ist in dem Glass etwas drin..."; switch (color) { case RiddleColor.Red: uniqueId = "glass_red"; title = "Eine rote Flüssigkeit"; break; case RiddleColor.Blue: uniqueId = "glass_blue"; title = "Eine blaue Substanz"; break; case RiddleColor.Green: uniqueId = "glass_green"; title = "Ein grünes Etwas"; break; default: uniqueId = "glass_empty"; title = "Glass"; break; } Item newGlass = new Item(uniqueId, title, description, sprite); context.inventory.RemoveItem(glass.UniqeId); context.inventory.AddItem(newGlass); } else { if (null != ifNoGlassGiven) { ifNoGlassGiven.Invoke(); } else { Debug.LogError("No Alternate Event given", gameObject); } } }
public override void OnInteraction(PlayerContext context) { if (playSound) { if (soundSourcePlayer != null) { soundSourcePlayer.Play(); } } Destroy(gameObject); }
public override void OnInteraction(PlayerContext context) { if (numpadController != null) { numpadController.ButtonPressed(numpadButtonType); if (playSound && soundSourcePlayer != null) { soundSourcePlayer.Play(); } } else { Debug.LogError("No NumpadController given!", this); } }
void Update() { if (openTimer.GetStarted()) { if (openTimer.Get() > waitAfterInsertion) { // If key was inserted and it is longer than waitAfterInsertion, the Open animation will be triggered and this Object will be destroyed (Cleaning!!!) openChestAnimator.SetTrigger(chestOpenAnimationTrigger); if (chestOpenSound != null) { chestOpenSound.Play(); } Destroy(gameObject); } } }
public override void OnInteraction(PlayerContext context) { if (!useStandardText) { dialogMessage.text = messageText; } if (soundSourcePlayer != null && playSound) { soundSourcePlayer.Play(); } else { Debug.LogError("No soundSourcePlayer given!"); } dialogMessage.Show(); }
public override void OnInteraction(PlayerContext context) { Item item = new Item(uniqueId, title, description, icon, consumable); if (context.inventory.AddItem(item)) { Debug.Log("Putting " + title + " into the inventory."); if (playSound) { if (soundSourcePlayer != null) { soundSourcePlayer.Play(); } } if (addUnityEvent) { if (unityEventAfterCollection != null) { unityEventAfterCollection.Invoke(); } } if (autoDestroyThis) { Destroy(gameObject); } if (destroyOtherObject) { if (otherObjectToDestroy != null) { Destroy(otherObjectToDestroy); } else { Debug.LogError("No otherObjectToDestroy given!", this); } } } }
public override void OnInteraction(PlayerContext context) { // -> Key inserted // Make animated Key visible animatedKey.SetActive(true); if (keyRotateSound != null) { keyRotateSound.Play(); } // Start Unlock animation and save start Time animatedKeyAnimator.SetTrigger(keyRotationAnimationTrigger); openTimer.Start(); // Disable Interactable if (interactable != null) { interactable.enabled = false; } }
public void Show() { if (currentShownState) { Debug.LogError("Already Shown!", this); return; } if (autoAssignGlobalProperties) { GetProperties(); } if (dialogProperties == null || !dialogProperties.Validate()) { Debug.LogError("No or broken DialogProperties attached!", this); return; } currentShownState = true; dialogProperties.player.LockPlayer(); if (currentlyShownObjects.IsNullOrEmpty()) { currentlyShownObjects = new List <SelfDestruct>(); } else { Hide(); } if (currentlyShownMessages == null) { currentlyShownMessages = new List <DialogMessage>(); } currentlyShownMessages.Add(this); GameObject textObject = Instantiate(dialogProperties.textPrefab, gameObject.transform); RectTransform textTransform = textObject.GetComponent <RectTransform>(); TMP_Text tmProText = textObject.GetComponentInChildren <TMP_Text>(); SelfDestruct textDestruct = textObject.AddComponent <SelfDestruct>(); if (textObject == null) { Debug.LogError("Cannot create text GameObject!", this); return; } if (textTransform == null) { Debug.LogError("No RectTransform on Prefab!", this); return; } if (tmProText == null) { Debug.LogError("No TMP_Text on Prefab!", this); return; } if (textDestruct == null) { Debug.LogError("Cannot create SelfDestruct on text!", this); return; } tmProText.text = text; textTransform.SetPositionX(dialogProperties.textPosition.x); textTransform.SetPositionY(dialogProperties.textPosition.y); currentlyShownObjects.Add(textDestruct); int currentNumber = 0; foreach (DialogOption dialogOption in options) { float yPosition = dialogProperties.optionsOrigin.y - ((dialogProperties.optionsOffset * (options.Count - 1)) / 2) + (dialogProperties.optionsOffset * (float)(currentNumber++)); GameObject optionObject = Instantiate(dialogProperties.buttonPrefab, gameObject.transform); RectTransform optionTransform = optionObject.GetComponent <RectTransform>(); TMP_Text optionText = optionObject.GetComponentInChildren <TMP_Text>(); DialogButton dialogButton = optionObject.GetComponentInChildren <DialogButton>(); SelfDestruct optionDestruct = optionObject.AddComponent <SelfDestruct>(); if (optionObject == null) { Debug.LogError("Cannot create Options GameObject!", this); } else if (optionTransform == null) { Debug.LogError("No RectTransform on Prefab!", this); } else if (optionText == null) { Debug.LogError("No TMP_Text on Prefab!", this); } else if (dialogButton == null) { Debug.LogError("No DialogButton on Prefab!", this); } else if (optionDestruct == null) { Debug.LogError("Cannot add SelfDestruct to Option!", this); } else { dialogButton.parentMessage = this; dialogButton.dialogOption = dialogOption; optionText.text = dialogOption.optionName; optionTransform.SetPositionX(dialogProperties.optionsOrigin.x); optionTransform.SetPositionY(yPosition); currentlyShownObjects.Add(optionDestruct); } } if (playSoundOnShow && soundSourcePlayer != null) { soundSourcePlayer.Play(); } if (triggerUnityEventOnShow && unityEvent != null) { unityEvent.Invoke(); } }