public void jormun() { double[] myVals = new double[] { -100.0, -100.0, -100.0, -100.0, -100.0, -100.0, -100.0, -100.0, -100.0, -100.0 }; int[] bestFollowUps = new int[10]; Random r = new Random(); for (int i = 0; i < curStory.decisions[myDecision].followups.Length; i++) { double detVal = 0.1; detVal += r.NextDouble() * 0.3; for (int j = 0; j < curStory.decisions[myDecision].followups[i].conditions.Length; j++) { if (curStory.decisions[myDecision].followups[i].conditions[j] > 0) { if (myChar.skills[j] == 0) { detVal = -200.0; } else if (myChar.skills[j] == 100) { detVal = 200.0; } else { detVal += (myChar.skills[j] - curStory.decisions[myDecision].followups[i].conditions[j]) / 100.0; } } } detVal *= curStory.decisions[myDecision].followups[i].probability; for (int k = 0; k < 9; k++) { if (detVal > myVals[k]) { for (int l = 9; l > k; l--) { myVals[l] = myVals[l - 1]; bestFollowUps[l] = bestFollowUps[l - 1]; } myVals[k] = detVal; bestFollowUps[k] = curStory.decisions[myDecision].followups[i].ID; } } } if (curStory.ID == 114 || curStory.ID == 1117 || curStory.ID == 1123 || curStory.ID == 1115 || curStory.ID == 1116 || curStory.ID == 1108) { for (int k = 0; k < 3; k++) { if (bestFollowUps[0] == 14 && myChar.ID != 1) { bestFollowUps[0] = bestFollowUps[1]; while (bestFollowUps[0] != 14) { for (int i = 1; i < 9; i++) { bestFollowUps[i] = bestFollowUps[i + 1]; } } } else if ((bestFollowUps[0] == 1119 || bestFollowUps[0] == 1124 || bestFollowUps[0] == 1126 || bestFollowUps[0] == 1132 || bestFollowUps[0] == 1110) && myChar.ID != 2) { bestFollowUps[0] = bestFollowUps[1]; while ((bestFollowUps[0] != 1119 || bestFollowUps[0] != 1124 || bestFollowUps[0] != 1126 || bestFollowUps[0] != 1132 || bestFollowUps[0] != 1110)) { for (int i = 1; i < 9; i++) { bestFollowUps[i] = bestFollowUps[i + 1]; } } } } } else if (storyIds.Contains(bestFollowUps[0]) && !(bestFollowUps[0] == 100 || bestFollowUps[0] == 101 || bestFollowUps[0] == 102 || bestFollowUps[0] == 103 || bestFollowUps[0] == 104 || bestFollowUps[0] == 105 || bestFollowUps[0] == 106 || bestFollowUps[0] == 107 || bestFollowUps[0] == 108 || bestFollowUps[0] == 109 || bestFollowUps[0] == 110 || bestFollowUps[0] == 111 || bestFollowUps[0] == 112 || bestFollowUps[0] == 113 || bestFollowUps[0] == 114 || bestFollowUps[0] == 115 || bestFollowUps[0] == 116 || bestFollowUps[0] == 117 || bestFollowUps[0] == 2000)) { curStory = JsonConvert.DeserializeObject <Story>(File.ReadAllText("files/story/405.json")); } if (bestFollowUps[0] == 99999) { drawCharTab(); myTabs.SelectedIndex--; audioPath = "files/sound/125.mp3"; outputDevice.Stop(); changeBackground(Resources.bckgrnd_wood); storyIds.Clear(); mySave.inStory = 0; area = 666; mySave.stories = storyIds.ToArray(); } else { if (File.Exists("files/story/" + bestFollowUps[0] + ".json")) { curStory = JsonConvert.DeserializeObject <Story>(File.ReadAllText("files/story/" + bestFollowUps[0] + ".json")); } else { curStory = JsonConvert.DeserializeObject <Story>(File.ReadAllText("files/story/0.json")); } loadStory(0); } if (curStory.ID == 5) { if (!unlockedChars.Contains(3)) { unlockedChars.Add(3); mySave.myChars = unlockedChars.ToArray(); } unlockAch(1); } //Ragnarok else if (curStory.ID == 0) //Dark Souls { unlockAch(0); } else if (curStory.ID == 100) //Yggdrasil { unlockAch(3); } else if (curStory.ID == 5000) //Jotunheim { unlockAch(4); } else if (curStory.ID == 1010) //Freeze to death { unlockAch(5); } else if (curStory.ID == 2000) { specialStoryCounter++; if (specialStoryCounter == 50) { unlockAch(2); specialStoryCounter = 0; } } //Surtr is waiting else if (curStory.ID == 116) //drank from well { unlockAch(6); } else if (curStory.ID == 1105 || curStory.ID == 1101 || curStory.ID == 1103) //Killed Garm { unlockAch(7); } else if (curStory.ID == 3017) { if (!unlockedChars.Contains(5)) { unlockedChars.Add(5); } mySave.myChars = unlockedChars.ToArray(); } } //does everything
private void Yggdrasil_Load(object sender, EventArgs e) //initializes often used variables and generates GUI elements { #region Init int btnEdge = 60; int btnGap = 20; changeBackground(Resources.bckgrnd_wood); lr = 247; lg = 241; lb = 227; light = Color.FromArgb(lr, lg, lb); dr = 214; //214,138,105 dg = 138; db = 105; decisionColor = Color.FromArgb(dr, dg, db); outline = decisionColor; Size btnSize = new Size(btnEdge, btnEdge); exitBtn.Size = btnSize; exitBtn.BringToFront(); exitBtn.Location = new Point(Width - btnGap - btnEdge, btnGap); muteBtn.Size = btnSize; muteBtn.BringToFront(); muteBtn.Location = new Point(Width - btnGap * 2 - btnEdge * 2, btnGap); achBtn.Size = btnSize; achBtn.Location = new Point(Width - btnGap * 3 - btnEdge * 3, btnGap); achBtn.BringToFront(); #endregion #region Save File mySave = new SaveFile(); if (File.Exists("save.sf")) { mySave = loadGame <SaveFile>(); } else { mySave.myChars = new int[] { 0, 1, 2, 4 }; mySave.inStory = 0; mySave.verification = getSHA1(mySave.inStory.ToString() + 42 + unlockedChars.ToString()); mySave.achievements = new int[0]; } if (mySave.verification != getSHA1(mySave.inStory.ToString() + 42 + unlockedChars.ToString())) { mySave.myChars = new int[] { 0, 1, 2 }; mySave.inStory = 0; mySave.verification = getSHA1(mySave.inStory.ToString() + 42 + unlockedChars.ToString()); mySave.achievements = new int[0]; } myChar = JsonConvert.DeserializeObject <Character>(File.ReadAllText("files/char/" + mySave.selectedChar + ".json")); #endregion #region Tabs myTabs.Size = new Size(Width + 8, Height + 26); myTabs.Location = new Point(-4, -22); #region StoryTab sceneLbl.MaximumSize = new Size(Width * 60 / 100, 0); sceneLbl.Location = new Point((Width / 2) - sceneLbl.Width / 2, Height * 15 / 100); sceneLbl.Parent = myTabs.TabPages[1]; situationLbl.MaximumSize = new Size(Width * 60 / 100, 0); situationLbl.Location = new Point((Width / 2) - situationLbl.Width / 2, Height * 20 / 100 + sceneLbl.Height); if (Width < 1500) { sceneLbl.Font = situationLbl.Font = main = new Font("Book Antiqua", 13.5f); } saveBtn.Size = new Size(btnEdge, btnEdge); saveBtn.Location = new Point(Width - btnGap * 3 - btnEdge * 3, btnGap); #endregion unlockedChars.AddRange(mySave.myChars); achievements.AddRange(mySave.achievements); drawCharTab(); #endregion #region Audio /* -- Audio -- */ audioPath = "files/sound/125.mp3"; if (outputDevice == null) { outputDevice = new WaveOutEvent(); outputDevice.PlaybackStopped += OnPlaybackStopped; outputDevice.Volume = volume / 100f; } if (audioFile == null) { audioFile = new AudioFileReader(audioPath); outputDevice.Init(audioFile); } outputDevice.Play(); /* -- Audio End -- */ #endregion #region Open Action if (mySave.inStory == 1) { storyIds.AddRange(mySave.stories); curStory = JsonConvert.DeserializeObject <Story>(File.ReadAllText("files/story/" + storyIds[storyIds.Count - 1] + ".json")); myTabs.SelectedIndex = 1; loadStory(1); fadeInTimer.Enabled = true; } #endregion }
private void startBtn_Click(object sender, EventArgs e) //starts story with selected character { myTabs.SelectedIndex++; curStory = JsonConvert.DeserializeObject <Story>(File.ReadAllText("files/story/" + myChar.startstory + ".json")); loadStory(); }