Ejemplo n.º 1
0
 public void NewRound()
 {
     UpdateRPG();
     UpdateTest();
     // set new creature
     if (currentCreature == null || creaturePatternDone)
     {
         currentCreature         = AssetManager.Inst.Creatures.Next(currentCreature);
         currentCreaturePhase    = 0;
         currentCreatureDialogue = 0;
         CreatureNameText.text   = currentCreature.Name;
         CreatureResponseBox.SetActive(false);
         CreatureResponseText.text = "";
         CreatureDebug.text        = currentCreature.name;
         currentCreature.IntroSound.Play();
         currentCreatureObj = Instantiate(currentCreature.Prefab, CreaturePosition, Quaternion.identity);
         currentCreatureObj.transform.localScale = CreatureScaleInit;
         Tween.ScaleTo(currentCreatureObj, CreatureScaleFinal, 0.5f, Interpolate.EaseType.EaseOutQuad);
         var sprite = currentCreatureObj.GetComponentInChildren <SpriteRenderer>();
         sprite.color = sprite.color.withAlpha(0);
         Tween.ColorTo(sprite.gameObject, sprite.color.withAlpha(1), 0.4f, Interpolate.EaseType.EaseOutSine);
     }
     // set new question
     questionOrder.Shuffle();
     currentQuestion    = AssetManager.Inst.Questions.Next(currentQuestion);
     QuestionText.text  = currentQuestion.Question.LineWrap(QuestionLineLength);
     Answer1Text.text   = currentQuestion.GetAnswer(questionOrder[0]).Text.LineWrap(AnswerLineLength);
     Answer2Text.text   = currentQuestion.GetAnswer(questionOrder[1]).Text.LineWrap(AnswerLineLength);
     Answer3Text.text   = currentQuestion.GetAnswer(questionOrder[2]).Text.LineWrap(AnswerLineLength);
     Answer4Text.text   = currentQuestion.GetAnswer(questionOrder[3]).Text.LineWrap(AnswerLineLength);
     NumberText.text    = "Question " + (questionsAnswered + 1) + "/" + QuestionsBeforeWin;
     QuestionDebug.text = currentQuestion.name;
 }
Ejemplo n.º 2
0
    public void SelectAction(int choice)
    {
        // figure out choices
        var creatureAction = CreatureAction.Talk;
        var questionAnswer = 1;

        switch (choice)
        {
        case 1:
            creatureAction = CreatureAction.Attack;
            questionAnswer = questionOrder[0];
            break;

        case 2:
            creatureAction = CreatureAction.Magic;
            questionAnswer = questionOrder[1];
            break;

        case 3:
            creatureAction = CreatureAction.Defend;
            questionAnswer = questionOrder[2];
            break;

        case 4:
            creatureAction = CreatureAction.Talk;
            questionAnswer = questionOrder[3];
            break;
        }
        // do creature action
        var phase = currentCreature.Pattern[currentCreaturePhase];

        previousCreatureReaction = 0;
        if (creatureAction == phase.GoodAction)
        {
            CreatureResponseText.text = phase.GoodReaction.LineWrap(ResponseLineLength);
            HealthRPG++;
            GoldRPG += phase.GoldOnGood;
            currentCreaturePhase++;
            previousCreatureReaction = 1;
        }
        else if (creatureAction == phase.BadAction)
        {
            CreatureResponseText.text = phase.BadReaction.LineWrap(ResponseLineLength);
            HealthRPG--;
            currentCreaturePhase++;
            previousCreatureReaction = -1;
        }
        else if (phase.UseBad2 && creatureAction == phase.BadAction2)
        {
            CreatureResponseText.text = phase.BadReaction2.LineWrap(ResponseLineLength);
            HealthRPG--;
            currentCreaturePhase++;
        }
        else if (creatureAction == CreatureAction.Talk)
        {
            HealthRPG += currentCreature.Dialogues.Count > currentCreatureDialogue
                ? currentCreature.Dialogues[currentCreatureDialogue].HealthChange
                : 0
            ;
            GoldRPG += currentCreature.Dialogues.Count > currentCreatureDialogue
                ? currentCreature.Dialogues[currentCreatureDialogue].GoldChange
                : 0
            ;
            CreatureResponseText.text = currentCreature.Dialogues[currentCreatureDialogue].Text.LineWrap(ResponseLineLength);
            currentCreatureDialogue   = Mathf.Min(currentCreatureDialogue + 1, currentCreature.Dialogues.Count - 1);
        }
        else
        {
            CreatureResponseText.text = phase.NeutralReaction.LineWrap(ResponseLineLength);
            currentCreaturePhase++;
        }
        HealthRPG = Mathf.Clamp(HealthRPG, 0, Hearts.Length);
        GoldRPG   = Mathf.Max(GoldRPG, 0);
        // do question answers
        previousTestAnswerScore = currentQuestion.GetAnswer(questionAnswer).Score;
        ScoreTest += previousTestAnswerScore;
        // endgame?
        questionsAnswered++;
        // animation
        AnimationManager.Inst.MakeChoice(choice - 1);
    }