コード例 #1
0
    public void AttemptCrisis(Player p, Game g)
    {
        Console.Clear();
        Boolean beat  = false;
        String  words = "";

        if ((Crisis[0] as CrisisCard).Beat)
        {
            Console.WriteLine("You already beat it.");
        }
        else if (!LineStatus())
        {
            beat = CrisisEvent.CrisisResolve(Crisis[0] as CrisisCard, p, g);
            if (beat)
            {
                words = "has been defeated";
            }
            else
            {
                words = "is Still Occuring.";
            }
            Console.WriteLine("The current Crisis Event " + words);
            (Crisis[0] as CrisisCard).Beat = beat;
        }
        else
        {
            Console.WriteLine("There is currently a Villian on the line.");
        }

        Console.WriteLine("Press any key to return...");
    }
コード例 #2
0
ファイル: Crisis.cs プロジェクト: vqbridge/Lean
 /// <summary>
 /// Returns a pre-defined crisis event
 /// </summary>
 /// <param name="crisisEvent">Crisis Event</param>
 /// <returns>Pre-defined crisis event</returns>
 public static Crisis FromCrisis(CrisisEvent crisisEvent)
 {
     return(Events[crisisEvent]);
 }
コード例 #3
0
    void SetPlayersAvaiableAnswers()
    {
        if (ActiveEvent.type != GameEvent.EventType.CRISIS)
        {
            List <Answer> answers = new List <Answer>(ActiveEvent.answers);
            player1.availableAnswers = new List <Answer>();
            while (player1.availableAnswers.Count < 4 && answers.Count > 0)
            {
                int rand = Random.Range(0, answers.Count);
                player1.availableAnswers.Add(answers[rand]);
                answers.RemoveAt(rand);
            }
            answers = new List <Answer>(ActiveEvent.answers);
            player2.availableAnswers = new List <Answer>();
            while (player2.availableAnswers.Count < 4 && answers.Count > 0)
            {
                int rand = Random.Range(0, answers.Count);
                player2.availableAnswers.Add(answers[rand]);
                answers.RemoveAt(rand);
            }
        }
        else
        {
            CrisisEvent activeCrisisEvent = (CrisisEvent)ActiveEvent;

            List <ConditionalAnswer> answers = new List <ConditionalAnswer>(activeCrisisEvent.conditionalAnswers);

            player1.availableAnswers = new List <Answer>();
            player2.availableAnswers = new List <Answer>();
            for (int i = 0; i < 2; i++)
            {
                player1.availableAnswers.Add(answers[i]);
                player2.availableAnswers.Add(answers[i]);
            }

            List <ConditionalAnswer> topAnswersP1 = new List <ConditionalAnswer>();
            List <ConditionalAnswer> topAnswersP2 = new List <ConditionalAnswer>();

            for (int i = 2; i < answers.Count; i++)
            {
                if (answers[i].condition.threshold > player1.influence.GetGroupValueAt((int)answers[i].condition.socialClass) &&
                    World.Instance.groups.GetGroupValueAt((int)answers[i].condition.socialClass) >= 0.6f)
                {
                    topAnswersP1.Add(answers[i]);
                }
                if (answers[i].condition.threshold > player2.influence.GetGroupValueAt((int)answers[i].condition.socialClass) &&
                    World.Instance.groups.GetGroupValueAt((int)answers[i].condition.socialClass) >= 0.6f)
                {
                    topAnswersP2.Add(answers[i]);
                }
            }

            //topAnswersP1.Sort();
            //topAnswersP2.Sort();

            if (topAnswersP1.Count >= 1)
            {
                player1.availableAnswers.Add(topAnswersP1[0]);
            }
            if (topAnswersP1.Count >= 2)
            {
                player1.availableAnswers.Add(topAnswersP1[1]);
            }

            if (topAnswersP2.Count >= 1)
            {
                player2.availableAnswers.Add(topAnswersP2[0]);
            }
            if (topAnswersP1.Count >= 2)
            {
                player2.availableAnswers.Add(topAnswersP2[1]);
            }
        }
    }
コード例 #4
0
    private void GenerateCrisisEvents()
    {
        //MUST CHECK LIST REFERENCES

        List <CrisisEvent.CrisisResolution> crisisResolutions = new List <CrisisEvent.CrisisResolution>();

        CrisisEvent.CrisisResolution tempResolution;

        ConditionalAnswer        conditionalAnswer;
        List <ConditionalAnswer> crisisAnswers = new List <ConditionalAnswer>();
        Dialogue dialogue;

        popChanges.Clear();
        statChanges.Clear();


        int eventIndex = 1;

        print(crisisQuestionsAssets.Length);
        for (int i = 0; i < crisisQuestionsAssets.Length; i++)
        {
            //resolutions
            lines = crisisResolutionsAssets[i].text.Split('\n');

            crisisResolutions.Clear();

            for (int j = 1; j < lines.Length; j++)
            {
                if (string.IsNullOrEmpty(lines[j]))
                {
                    //print("Empty line");
                    break;
                }

                string[] lineContent = lines[j].Split(';');
                tempResolution.resolution = new Dialogue(lineContent[lineContent.Length - 1].Split('$'));

                popChanges.Clear();
                for (int k = 1; k < lineContent.Length - 1; k++)
                {
                    if (lineContent[k] != "0" && lineContent[k] != "-" && lineContent[k] != "-0" && !string.IsNullOrEmpty(lineContent[k]))
                    {
                        popChanges.Add(new StatChange((Utilities.SocialClass)(k - 1), int.Parse(lineContent[k])));
                    }
                }
                tempResolution.index      = int.Parse(lineContent[0]);
                tempResolution.popChanges = new List <StatChange>(popChanges);
                crisisResolutions.Add(tempResolution);
            }

            //possible answers to the question
            lines = crisisQuestionsAssets[i].text.Split('\n');

            dialogue = new Dialogue(lines[1].Split(';')[0].Split('$'));
            Utilities.SocialClass       tempClass;
            ConditionalAnswer.Condition tempCondition;

            crisisAnswers.Clear();

            for (int j = 2; j < lines.Length; j++)
            {
                if (string.IsNullOrEmpty(lines[j]))
                {
                    //print("Empty line");
                    break;
                }

                string[] lineContent = lines[j].Split(';');

                if (lineContent[0] != "-" && lineContent[0] != "" && lineContent[0] != "-0")
                {
                    switch (lineContent[1])
                    {
                    case "Merchant":
                        tempClass = Utilities.SocialClass.MERCHANT;
                        break;

                    case "Guard":
                        tempClass = Utilities.SocialClass.GUARD;
                        break;

                    case "Commoner":
                        tempClass = Utilities.SocialClass.COMMONER;
                        break;

                    case "Noble":
                        tempClass = Utilities.SocialClass.NOBLE;
                        break;

                    case "Alchemist":
                        tempClass = Utilities.SocialClass.ALCHEMIST;
                        break;

                    case "Clergy":
                        tempClass = Utilities.SocialClass.CLERIC;
                        break;

                    default:
                        tempClass = Utilities.SocialClass.NULL;
                        break;
                    }

                    tempCondition.socialClass = tempClass;

                    if (lineContent[2][0] == '-')
                    {
                        tempCondition.threshold = 10000f;
                    }
                    else
                    {
                        tempCondition.threshold = float.Parse(lineContent[2]);
                    }

                    conditionalAnswer = new ConditionalAnswer(j - 1, lineContent[0], null, null, null, tempCondition);
                    crisisAnswers.Add(conditionalAnswer);
                }
            }

            //table
            lines = crisisResultsTableAssets[i].text.Split('\n');

            int[,] crisisResolutionTable = new int[lines[0].Split(';').Length - 1, lines.Length - 2];

            for (int j = 1; j < lines.Length; j++)
            {
                if (string.IsNullOrEmpty(lines[j]))
                {
                    //print("Empty line");
                    continue;
                }

                string[] lineContent = lines[j].Split(';');

                for (int k = 1; k < lineContent.Length; k++)
                {
                    crisisResolutionTable[j - 1, k - 1] = int.Parse(lineContent[k]);
                }
            }

            CrisisEvent gameEvent = new CrisisEvent("CrisisEvent" + eventIndex, GameEvent.EventType.CRISIS, dialogue, new List <ConditionalAnswer>(crisisAnswers), new List <CrisisEvent.CrisisResolution>(crisisResolutions), crisisResolutionTable);
            CreateAsset(typeof(CrisisEvent), gameEvent);
            eventIndex++;
        }
    }