public void Interact() { if (akd.DialoguePlaying()) { akd.CreateDialogue(); // There should be only one line of dialogue, so we can make it true here itemObtained = true; } else { if (possessedAmount > 0) { int amount = possessedAmount >= obtainedAmount ? obtainedAmount : possessedAmount; Grid.inventory.AddItem(itemID, amount); possessedAmount -= amount; if (sharedItem) { // Update the shared interactables foreach (var shared in sharedWith) { shared.possessedAmount -= amount; } } Grid.soundManager.PlaySound(Grid.itemDataBase.FetchItemByID(itemID).PickUpSound); string[] arr = { Application.dataPath, "Text", Grid.optionsManager.lang, "General", "getItem" }; string dialogPath = string.Join("/", arr); akd.getDialogueFiles(dialogPath); // Replace text with item information // In theory, only 1 string for (int i = 0; i < akd.dialogue.Length; i++) { for (int j = 0; j < akd.dialogue[i].Length; j++) { akd.dialogue[i][j] = akd.dialogue[i][j].Replace(AMOUNT, amount.ToString()); akd.dialogue[i][j] = akd.dialogue[i][j].Replace(NAME, Grid.itemDataBase.FetchItemByID(itemID).Name_en); } } interacted.Invoke(); akd.CreateDialogue(); } } }
/* * private IEnumerator NoCharacterControl() * { * // Make the character not be able to be controlled while the knockback is happening. * CanMove = false; * // Wait for 'noControlTime' time before being able to control the character again. * yield return new WaitForSeconds(HitAnimationTime); * // Stop the knockback. * characterEntity.GetComponent<Rigidbody2D>().velocity = Vector2.zero; * // We can now move the character. * CanMove = true; * } * * private IEnumerator HitAnimation() * { * CharacterAnimator.SetBool("IsHit", true); * yield return new WaitForSeconds(HitAnimationTime); * CharacterAnimator.SetBool("IsHit", false); * } */ public void Interact() { // Make the NPC face the player Vector2 playerPos = Grid.setup.player.characterEntity.transform.position; Vector2 NPCPos = characterEntity.transform.position; Vector2 posDiff = playerPos - NPCPos; float hor = Mathf.Abs(posDiff.x) < Mathf.Abs(posDiff.y) ? 0f : (playerPos.x > NPCPos.x ? 1f : -1f); float vert = Mathf.Abs(posDiff.x) > Mathf.Abs(posDiff.y) ? 0f : (playerPos.y > NPCPos.y ? 1f : -1f); CharacterAnimator.SetFloat("FaceX", hor); CharacterAnimator.SetFloat("FaceY", vert); // Record the interaction (since Interact executed also to close the dialogue, only record the first time) if (!akd.DialoguePlaying()) { Grid.recorder.Interacted(DialogueDirectory); Grid.recorder.AddInteraction(DialogueDirectory); } // Create dialog akd.CreateDialogue(); }
public bool Talking() { return(akd.DialoguePlaying()); }