void RefreshView()
    {
        foreach (Transform child in displayBoard.transform)
        {
            if (child.CompareTag("choiceButton"))
            {
                Destroy(child.gameObject);
            }
        }

        while (_mainStory.canContinue)
        {
            string text = _mainStory.Continue();
            dialogText.text = text;
            List <string> tags = _mainStory.currentTags;
            if (tags.Contains("GiveQuest"))
            {
                npc.isQuestGiver = true;
            }
            if (tags.Contains("GiveDemonKarma"))
            {
                CharacterSheet.charSheet.ChangeDemonKarma(1);
            }
            if (tags.Contains("GiveSpiritKarma"))
            {
                CharacterSheet.charSheet.ChangeSpiritKarma(1);
            }
        }

        if (_mainStory.currentChoices.Count > 0)
        {
            for (int i = 0; i < _mainStory.currentChoices.Count; ++i)
            {
                Choice choice = _mainStory.currentChoices[i];
                Button button = Instantiate(choiceButtonPrefab, displayBoard.transform) as Button;
                button.GetComponentInChildren <TextMeshProUGUI>().text = choice.text;
                button.onClick.AddListener(delegate
                {
                    OnClickChoiceButton(choice);
                });
            }
        }
        else
        {
            Button button = Instantiate(choiceButtonPrefab, displayBoard.transform) as Button;
            button.GetComponentInChildren <TextMeshProUGUI>().text = "Click to dismiss";
            button.onClick.AddListener(delegate
            {
                npc.CloseDialog();
            });
        }
    }
Beispiel #2
0
    public void DisplayDialog()
    {
        if (!npc.dialogBox.activeSelf)
        {
            Quest.QuestProgress statusTest = questToGive.questProgress;

            Time.timeScale = 0f;

            GameManager.gm.data.overviewMap.SetActive(false);

            switch (statusTest)
            {
            case Quest.QuestProgress.AVAILABLE:
                npc.dialogText.text = questToGive.questDesc;
                GiveQuest();
                break;

            case Quest.QuestProgress.CURRENT:
            case Quest.QuestProgress.ACCEPTED:
                npc.dialogText.text = questToGive.questDesc;
                break;

            case Quest.QuestProgress.COMPLETED:
                npc.dialogText.text = questToGive.questCompleteText;
                if (questType == Quest.QuestType.FIND_ITEM)
                {
                    FindItem quest = (FindItem)questToGive;
                    quest.RemoveItem();
                }
                if (questType == Quest.QuestType.KILL)
                {
                    KillQuest quest = (KillQuest)questToGive;
                }
                if (questType == Quest.QuestType.LOCATION)
                {
                    LocateQuest quest = (LocateQuest)questToGive;
                }
                if (questType == Quest.QuestType.AWAKEN)
                {
                    AwakenQuest quest = (AwakenQuest)questToGive;
                }
                QuestManager.questManager.SetQuestStatus(questToGive.questID, Quest.QuestProgress.DONE);
                break;

            case Quest.QuestProgress.DONE:
                npc.dialogText.text = questToGive.questDoneText;
                questToGive.GiveRewards();
                if (questToGive.nextQuest == -1)
                {
                    this.gameObject.GetComponent <NonPlayerCharacter>().questToken.SetActive(false);
                    npc.isQuestGiver = false;
                    break;
                }
                questToGive = QuestManager.questManager.GetQuestById(questToGive.nextQuest);
                QuestManager.questManager.SetQuestStatus(questToGive.questID, Quest.QuestProgress.AVAILABLE);
                QuestManager.questManager.AcceptQuest(questToGive);
                questType = questToGive.questType;
                break;

            default:
                break;
            }

            Button button = Instantiate(npc.buttonPrefab, npc.displayBoard.transform) as Button;
            button.GetComponentInChildren <TextMeshProUGUI>().text = "Click to dismiss";
            button.onClick.AddListener(delegate
            {
                npc.CloseDialog();
            });

            npc.dialogBox.SetActive(true);
        }
        else
        {
            Time.timeScale = 1f;
            npc.dialogBox.SetActive(false);
            GameManager.gm.data.overviewMap.SetActive(true);
        }

        NPCManager.npcManager.UpdateNPCList(npc.ID, questToGive, npc.talkNotifier.activeSelf, npc.questToken.activeSelf);
    }
Beispiel #3
0
    void Update()
    {
        // ============== MOVEMENT ======================
        float horizontal = Input.GetAxis("Horizontal");
        float vertical   = Input.GetAxis("Vertical");

        if (System.Enum.IsDefined(typeof(OverlandEnemyTrap.Levels), _scene.name) || _scene.name.Equals("DemonRealm"))
        {
            vertical = 0f;
        }

        Vector2 move = new Vector2(horizontal, vertical);

        if (!Mathf.Approximately(move.x, 0.0f) || !Mathf.Approximately(move.y, 0.0f))
        {
            lookDirection.Set(move.x, move.y);
            lookDirection.Normalize();
        }

        currentInput = move;


        // ============== ANIMATION =======================

        animator.SetFloat("Look X", lookDirection.x);
        animator.SetFloat("Look Y", lookDirection.y);
        animator.SetFloat("Speed", move.magnitude);

        // ============== ATTACKS ======================

        if (Input.GetKeyDown(KeyCode.C))
        {
            LaunchProjectile();
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            SwordAttack();
        }

        // ======== EXAMINE ==========
        if (Input.GetKeyDown(KeyCode.X))
        {
            RaycastHit2D hit = Physics2D.Raycast(rigidbody2d.position + Vector2.up * 0.2f, lookDirection, 1.5f, 1 << LayerMask.NameToLayer("NPC"));
            if (hit.collider != null)
            {
                TreasureChest      chest     = hit.collider.GetComponent <TreasureChest>();
                NonPlayerCharacter character = hit.collider.GetComponent <NonPlayerCharacter>();
                if (character != null)
                {
                    if (!character.dialogBox.activeSelf)
                    {
                        character.DisplayDialog();
                    }
                    else
                    {
                        character.CloseDialog();
                    }
                }
                else if (chest != null && chest.status == TreasureChest.ChestState.CLOSED)
                {
                    Time.timeScale = 0f;
                    chest.DisplayDialog();
                    chest.status = TreasureChest.ChestState.OPENED;
                    ChestManager.chestManager.UpdateChest(chest.chestID, chest.status);
                }
            }
        }


        if (Input.GetKeyDown(KeyCode.Return))
        {
            RaycastHit2D hit = Physics2D.Raycast(rigidbody2d.position + Vector2.up * 0.2f, lookDirection, 1.5f, 1 << LayerMask.NameToLayer("NPC"));
            if (hit.collider != null)
            {
                TreasureChest chest = hit.collider.GetComponent <TreasureChest>();
                if (chest != null)
                {
                    if (chest.status == TreasureChest.ChestState.OPENED)
                    {
                        Time.timeScale = 1f;
                        chest.dialogBox.SetActive(false);
                        chest.GetTreasure();
                        chest.status = TreasureChest.ChestState.USED;
                        ChestManager.chestManager.UpdateChest(chest.chestID, chest.status);
                    }
                }
            }
        }
    }