예제 #1
0
    // Called from GameManager x amount of times
    public void CreateNpc()
    {
        // Instantiate & set name
        GameObject npc = GameObject.Instantiate(npcPrefab, this.transform.position, Quaternion.identity);

        npc.name = npcNames[Random.Range(0, npcNames.Count)];

        // Set dialogue
        List <string> chosenDialogue = new List <string>();
        Dictionary <int, List <string> > chosenDialogueResponses = new Dictionary <int, List <string> >();

        switch (Random.Range(0, dialogueCount))
        {
        case 0:
            chosenDialogue          = dialogue0;
            chosenDialogueResponses = dialogueResponses0;
            break;

        case 1:
            chosenDialogue          = dialogue1;
            chosenDialogueResponses = dialogueResponses1;
            break;

        default:
            break;
        }

        // Initialize
        NpcClass npcClass = npc.GetComponent <NpcClass> ();

        npcClass.Initialize(npc.name, npcSprites[Random.Range(0, npcSprites.Count)], chosenDialogue, chosenDialogueResponses);

        this.gameManager.AddActiveNpc(npcClass);
    }
예제 #2
0
        public NpcClassSkillMap GetClassSkillMap(NpcClass cl)
        {
            NpcClassSkillMap result;

            if (classSkills.TryGetValue(cl, out result))
            {
                return(result);
            }
            return(null);
        }
    // Get possible responses and update response text objects
    private IEnumerator UpdateResponseText(NpcClass npc)
    {
        List <string> responses = npc.GetDialogueResponses(this.currentLineIndex);

        for (int i = 0; i < responses.Count; i++)
        {
            this.responseTexts[i].text = responses[i];
        }

        yield return(null);
    }
예제 #4
0
        public int MatchingBackingFieldAndPropertyReturnType(object initialValue, object value)
        {
            //Arrange.
            NpcClass npc = new NpcClass(initialValue);
            PropertyChangedHandler handler = new PropertyChangedHandler(npc);

            //Act.
            npc.Data = value;

            //Assert.
            return(handler.EventCount);
        }
    // Controls the flow of the conversation
    public IEnumerator Converse(NpcClass npc)
    {
        Debug.Log("line index: " + this.currentLineIndex);

        // Npc Speaks
        yield return(this.StartCoroutine(this.SayLine(npc)));

        // Update responses
        yield return(this.StartCoroutine(this.UpdateResponseText(npc)));

        // Wait for player input & immediately reset bool for the next question
        yield return(new WaitUntil(() => this.isWaitingForResponse == false));

        this.isWaitingForResponse = true;

        // Pick a random corerct answer
        int correctAnswer = Random.Range(0, npc.GetDialogueResponses(this.currentLineIndex).Count);

        // Update player phunk meter if chosen answer matches correct answer
        if (this.currentResponseIndex == correctAnswer)
        {
            this.gameManager.IncreasePlayerPhunk(GameManager.answerPoints);
            Debug.Log("Correct Answer");
        }

        // Increase counter
        this.currentLineIndex++;

        // Call converse if there are more dialogue lines
        if (this.currentLineIndex < npc.GetDialogueCount())
        {
            this.StartCoroutine(this.Converse(npc));
        }
        else
        {
            this.EnableDialogueUI(false);
        }

        yield return(null);
    }
예제 #6
0
        public static Workshop GetWorkshopForRaceAndClass(Race race, NpcClass npcClass)
        {
            switch (race)
            {
            case Race.Humans: {
                switch (npcClass)
                {
                case NpcClass.rdd: {
                    return(Workshop.DarthTribe);
                }

                case NpcClass.healer: {
                    return(Workshop.Equilibrium);
                }

                case NpcClass.sdd: {
                    return(Workshop.BigBang);
                }

                case NpcClass.tank: {
                    return(Workshop.RedEye);
                }
                }
            }
            break;

            case Race.Borguzands: {
                switch (npcClass)
                {
                case NpcClass.rdd: {
                    return(Workshop.Phelpars);
                }

                case NpcClass.healer: {
                    return(Workshop.Zoards);
                }

                case NpcClass.sdd: {
                    return(Workshop.Rakhgals);
                }

                case NpcClass.tank: {
                    return(Workshop.Lerjees);
                }
                }
            }
            break;

            case Race.Criptizoids: {
                switch (npcClass)
                {
                case NpcClass.rdd: {
                    return(Workshop.Yshuar);
                }

                case NpcClass.healer: {
                    return(Workshop.Arlen);
                }

                case NpcClass.sdd: {
                    return(Workshop.Dyneira);
                }

                case NpcClass.tank: {
                    return(Workshop.KrolRo);
                }
                }
            }
            break;
            }
            return(Workshop.Arlen);
        }
 // Get NPC Line and update UI dialogue text
 private IEnumerator SayLine(NpcClass npc)
 {
     this.dialogueText.text = npc.GetDialogue(currentLineIndex);
     yield return(null);
 }
예제 #8
0
 public void AddActiveNpc(NpcClass npc)
 {
     this.activeNpcs.Add(npc);
 }