protected void OnActivate() { isActive = true; SelectedEnemy = (ENEMY)(Random.Range(0, NumEnemies)); TextEnemy.text = SelectedEnemy.ToString(); Debug.LogFormat("[Adventure Game #{0}] Enemy: {1}", moduleId, SelectedEnemy); StatValues = new int[7]; for (int i = 0; i < NumStats; i++) { StatValues[i] = Random.Range(StatRanges[i * 2], StatRanges[i * 2 + 1] + 1); } Debug.LogFormat("[Adventure Game #{0}] Player stats: {1}", moduleId, logPlayerStats()); Debug.LogFormat("[Adventure Game #{0}] Environment stats: {1}", moduleId, logEnvStats()); serialNum = BombInfo.GetSerialNumber(); bool foundDigit = false; foreach (char c in serialNum) { if (c >= '0' && c <= '9') { if (!foundDigit) { foundDigit = true; firstDigit = c - '0'; } lastDigit = c - '0'; } } numUnlit = BombInfo.GetOffIndicators().Count(); numLit = BombInfo.GetOnIndicators().Count(); doublePort = false; HashSet <string> portList = new HashSet <string>(); foreach (string s in KMBombInfoExtensions.GetPorts(BombInfo)) { if (portList.Contains(s)) { doublePort = true; break; } portList.Add(s); } batteryCount = KMBombInfoExtensions.GetBatteryCount(BombInfo); // Generate weapons InvValues = new List <ITEM>(); CorrectWeapon = new bool[InvWeaponCount]; for (int i = 0; i < InvWeaponCount; i++) { ITEM item; do { item = (ITEM)(Random.Range(0, NumWeapons)); } while (InvValues.Contains(item)); InvValues.Add(item); } RegenerateWeaponScores(); // Generate other items for (int i = 0; i < InvMiscCount; i++) { ITEM item; do { item = (ITEM)(Random.Range(NumWeapons, NumItems)); }while (InvValues.Contains(item)); InvValues.Add(item); } logItemUsage(); UpdateStatDisplay(); UpdateInvDisplay(); }
void GenerateAmounts() { //paper if (Info.IsIndicatorPresent(Indicator.IND) && KMBombInfoExtensions.GetBatteryCount(Info) < 5) { PaperAmount += 19; Debug.LogFormat("[Waste Management #{0}] Added 19 to the paper amount (IND indicator)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Paper amount is now {1}", _moduleId, PaperAmount); } if (Info.IsIndicatorPresent(Indicator.SND)) { PaperAmount += 15; Debug.LogFormat("[Waste Management #{0}] Added 15 to the paper amount (SND indicator)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Paper amount is now {1}", _moduleId, PaperAmount); } if (Info.IsPortPresent(Port.Parallel)) { PaperAmount -= 44; Debug.LogFormat("[Waste Management #{0}] Subtracted 44 from the paper amount (parallel port)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Paper amount is now {1}", _moduleId, PaperAmount); } //don't calculate time dependent rules yet, as we don't know when the submit button is going to be pressed if (Info.GetBatteryCount() == 0 && Info.GetIndicators().Count() < 3) { PaperAmount += 154; Debug.LogFormat("[Waste Management #{0}] Added 154 to the paper amount (zero batteries)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Paper amount is now {1}", _moduleId, PaperAmount); } if (Info.GetSerialNumberLetters().Any("SAVEMYWORLD".Contains) && !(ConsonantOccurances > 2)) { PaperAmount += 200; Debug.LogFormat("[Waste Management #{0}] Added 200 to the paper amount (Save My World)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Paper amount is now {1}", _moduleId, PaperAmount); } //plastic //miss all the check to do with strikes because we don't know how many strikes we have until we submit if (Info.GetPortPlates().Any(x => x.Length == 0) && ModulesName.Count % 2 == 0) { PlasticAmount -= 17; Debug.LogFormat("[Waste Management #{0}] Subtracted 17 from the plastic amount (Empty port plate)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Plastic amount is now {1}", _moduleId, PlasticAmount); } if (Info.IsIndicatorPresent(Indicator.FRQ) && !(Info.GetBatteryCount(Battery.D) > Info.GetBatteryCount(Battery.AA))) { PlasticAmount += 153; Debug.LogFormat("[Waste Management #{0}] Added 153 to the plastic amount (FRQ indicator)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Plastic amount is now {1}", _moduleId, PlasticAmount); } //metal if (Info.IsIndicatorPresent(Indicator.BOB)) { MetalAmount += 199; Debug.LogFormat("[Waste Management #{0}] Added 199 to the metal amount (BOB indicator)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Metal amount is now {1}", _moduleId, MetalAmount); } if (Info.IsIndicatorPresent(Indicator.MSA)) { MetalAmount += 92; Debug.LogFormat("[Waste Management #{0}] Added 92 to the metal amount (MSA indicator)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Metal amount is now {1}", _moduleId, MetalAmount); } if (Info.IsIndicatorPresent(Indicator.CAR) && !(Info.IsPortPresent(Port.RJ45))) { MetalAmount -= 200; Debug.LogFormat("[Waste Management #{0}] Subtracted 200 from the metal amount (CAR indicator)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Metal amount is now {1}", _moduleId, MetalAmount); } if (KMBombInfoExtensions.IsDuplicatePortPresent(Info) && !(Info.IsPortPresent(Port.DVI))) { MetalAmount += 153; Debug.LogFormat("[Waste Management #{0}] Added 153 to the metal amount (duplicate port)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Metal amount is now {1}", _moduleId, MetalAmount); } //again, time stuff needs to be done a point of submission if (Info.IsIndicatorOn(Indicator.BOB) && Info.GetPortCount() >= 6 && ModulesName.Contains("Forget Me Not")) { MetalAmount += 99; Debug.LogFormat("[Waste Management #{0}] Added 99 to the metal amount (lit BOB and at least 6 ports)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Metal amount is now {1}", _moduleId, MetalAmount); } else if (ModulesName.Contains("Forget Me Not")) { MetalAmount -= 84; Debug.LogFormat("[Waste Management #{0}] Subtracted 84 from metal amount (Forget Me Not)", _moduleId); Debug.LogFormat("[Waste Management #{0}] Metal amount is now {1}", _moduleId, MetalAmount); } //print temporary amounts. Perform the actual cleanup at submit time Debug.LogFormat("[Waste Management #{0}] The signed paper amount before time and strike based rules is {1}", _moduleId, PaperAmount); Debug.LogFormat("[Waste Management #{0}] The signed plastic amount before time and strike based rules is {1}", _moduleId, PlasticAmount); Debug.LogFormat("[Waste Management #{0}] The signed metal amount before time and strike based rules is {1}", _moduleId, MetalAmount); Generated = true; }
// Use this for initialization void Start() { _id = idCounter++; speciesId = UnityEngine.Random.Range(0, CroppedMats.Length - 1); Debug.LogFormat("[Fursona #{0}] Selected species: {1}", _id, NAMES[speciesId]); CroppedRenderer.material = CroppedMats[speciesId]; HeadRenderer.material = HeadMats[speciesId]; EyesRenderer.material = EyesMats[speciesId]; FleshRenderer.material = FleshMats[speciesId]; PrimaryRenderer.material = PrimaryMats[speciesId]; SecondaryRenderer.material = SecondaryMats[speciesId]; TertiaryRenderer.material = TertiaryMats[speciesId]; UpdateColors(); PhysicalSlider[] Sliders = new PhysicalSlider[] { A1, A2, A3, B1, B2, B3, C1, C2, C3, D1, D2, D3, E1, E2, E3, F1, F2, F3 }; foreach (PhysicalSlider Slider in Sliders) { Slider.OnUpdate += UpdateColors; } KMBombInfo info = GetComponent <KMBombInfo>(); int ui = KMBombInfoExtensions.GetOffIndicators(info).Count(); int li = KMBombInfoExtensions.GetOnIndicators(info).Count(); int b = KMBombInfoExtensions.GetBatteryCount(info); int bh = KMBombInfoExtensions.GetBatteryHolderCount(info); int p = KMBombInfoExtensions.GetPortCount(info); int ep = KMBombInfoExtensions.GetPortPlates(info).Count(sa => sa.Length == 0); int s3 = int.Parse(KMBombInfoExtensions.GetSerialNumber(info)[2].ToString()); int s6 = int.Parse(KMBombInfoExtensions.GetSerialNumber(info)[5].ToString()); int pp = KMBombInfoExtensions.GetPortPlates(info).Count(); int sl = KMBombInfoExtensions.GetSerialNumberLetters(info).Count(); int sn = KMBombInfoExtensions.GetSerialNumberNumbers(info).Count(); int m = info.GetModuleIDs().Count; int R = -1, G = -1, B = -1, C = -1, M = -1, Y = -1; switch (speciesId) { case 0: R = li; G = ui; B = b; C = bh; M = p; Y = ep; break; case 1: R = s3; G = s6; B = pp; C = sl; M = sn; Y = m; break; case 2: R = ep; G = m; B = p; C = sn; M = bh; Y = sl; break; case 3: R = sl; G = s3; B = bh; C = li; M = sn; Y = s6; break; case 4: R = p; G = ui; B = m; C = pp; M = ep; Y = b; break; case 5: R = s6; G = b; B = sn; C = ep; M = li; Y = pp; break; case 6: R = bh; G = m; B = s3; C = ui; M = sl; Y = p; break; case 7: R = pp; G = p; B = li; C = sl; M = ep; Y = ui; break; case 8: R = sn; G = s3; B = b; C = m; M = s6; Y = bh; break; case 9: R = ui; G = bh; B = ep; C = s6; M = sl; Y = m; break; case 10: R = li; G = b; B = p; C = s3; M = pp; Y = sn; break; default: break; } int maxId = 0; int[] vals = new int[] { R, G, B, C, M, Y }; for (int i = 1; i < 6; i++) { if (vals[i] >= vals[maxId]) { maxId = i; } } TargetEyeColor = maxId; Debug.LogFormat("[Fursona #{0}] Eye color: {1}; Head color: {2}", _id, COLORNAMES[maxId], COLORNAMES[(maxId + 3) % 6]); }
//Logical initialization void Init() { //Randomize order of ordered int[] ordered = { 6, 2, 3, 4, 5, 1 }; for (int i = 5; i > 0; i--) { int j = Random.Range(0, i + 1); int tmp = ordered[i]; ordered[i] = ordered[j]; ordered[j] = tmp; } //Insert a sun int rng = Random.Range(0, 5); ordered[rng] = 0; sun = Instantiate(light); sun.transform.SetParent(buttons[System.Array.IndexOf(ordered, 0)].transform); sun.transform.localPosition = new Vector3(0f, 0f, 0f); float scalar = transform.lossyScale.x; sun.GetComponent <Light>().range *= scalar; planetPatterns = ordered; Debug.LogFormat("[Nomai #{0}] Initialised with planet order: #0: {1} #1: {2} #2: {4} #3: {3} #4: {5} #5(main): {6}", _moduleId, PATTERNS[ordered[0]], PATTERNS[ordered[1]], PATTERNS[ordered[3]], PATTERNS[ordered[2]], PATTERNS[ordered[4]], PATTERNS[ordered[5]]); //Render planets for (int x = 0; x < buttonRenderers.Length; x++) { buttonRenderers[x].material = buttonMats[planetPatterns[x]]; } mainButtonRenderer.material = buttonMats[planetPatterns[5]]; planetActions = new int[6][] { new int[6] { 1, 1, 1, 1, 1, 1 }, new int[6] { 1, 1, 1, 1, 1, 1 }, new int[6] { 1, 1, 1, 1, 1, 1 }, new int[6] { 1, 1, 1, 1, 1, 1 }, new int[6] { 1, 1, 1, 1, 1, 1 }, new int[6] { 1, 1, 1, 1, 1, 1 } }; //Make all actions valid, except for two per planet for (int i = 0; i < 6; i++) { int a = Random.Range(0, 6); int b = Random.Range(0, 5); if (b == a) { b = 5; } planetActions[i][a] = 0; planetActions[i][b] = 0; } //Make self-actions error for (int i = 0; i < 6; i++) { planetActions[i][i] = -1; } //Add sun int sunPos = -1; for (int i = 0; i < 6; i++) { if (planetPatterns[i] == 0) { sunPos = i; for (int x = 0; x < 6; x++) { planetActions[i][x] = -1; } } } for (int n = 0; n < 5; n++) { int j = n; if (n == sunPos) { j = 5; } planetActions[j][sunPos] = 0; } //Add sixth location int fromPlanet = Random.Range(0, 5); if (fromPlanet == sunPos) { fromPlanet = 5; } int toPlanet = Random.Range(0, 4); if (toPlanet == fromPlanet) { toPlanet = 5; } planetActions[fromPlanet][toPlanet] = 2; if (toPlanet == sunPos) { toPlanet = 4; } //Check each planet is visitable for (int i = 0; i < 5; i++) { int j = i; if (i == sunPos) { j = 5; } int goodNum = 0; for (int k = 0; k < 6; k++) { if (k == sunPos || k == j) { continue; } if (planetActions[k][j] == 1) { goodNum++; } } while (goodNum < 2) { for (int k = 0; k < 5; k++) { if (planetActions[k][j] == 0) { planetActions[k][j] = 1; goodNum++; break; } } } } Debug.LogFormat("[Nomai #{0}] Action table:", _moduleId); Debug.LogFormat("[Nomai #{0}] 0 1 2 3 4 5", _moduleId); int ct = 0; foreach (int[] x in planetActions) { Debug.LogFormat("[Nomai #{6}] {7} [{0} {1} {2} {3} {4} {5}]", x[0].ToString().Replace("-1", "x"), x[1].ToString().Replace("-1", "x"), x[2].ToString().Replace("-1", "x"), x[3].ToString().Replace("-1", "x"), x[4].ToString().Replace("-1", "x"), x[5].ToString().Replace("-1", "x"), _moduleId, ct); ct++; } Debug.LogFormat("[Nomai #{0}] (Row = Planet traveled from | Column = Planet traveled to | x = Not possible | 0 = Strike | 1 = Nothing | 2 = Sixth Location)", _moduleId); //Determine deactivation condition. redo: switch (ordered[5]) { case 1: Regex a = new Regex("[" + KMBombInfoExtensions.GetSerialNumberLetters(Info).Join("") + "]", RegexOptions.IgnoreCase); if (a.Match(KMBombInfoExtensions.GetIndicators(Info).Join("")).Success) { deactMethod = 1; addColorsRandom(-1); } else { deactMethod = 2; //Make sure this method is possible if it occurs. for (int i = 0; i < 6; i++) { if (planetActions[i][5] == 0) { planetActions[i][5] = 1; break; } } addColorsRandom(-1); } break; case 2: if (KMBombInfoExtensions.GetOffIndicators(Info).Count() >= 2) { deactMethod = 3; addColorsRandom(6); } else { deactMethod = 4; //Add colors int next = -1; int count = 0; for (int i = 0; i < 7; i++) { colorActionsLight[i] = Random.Range(0, 5) == 0 ? next++ % 3 + 1 : 0; count += Min(colorActionsLight[i], 1); if (count > 5) { break; } } while (count < 3) { int i = Random.Range(0, 7); if (colorActionsLight[i] == 0) { colorActionsLight[i] = next++ % 3 + 1; count++; } } } break; case 3: if (KMBombInfoExtensions.GetOnIndicators(Info).Count() >= 2) { deactMethod = 5; addColorsRandom(-1); } else { deactMethod = 6; addColorsRandom(-1); } break; case 4: if (KMBombInfoExtensions.GetBatteryCount(Info) >= 3) { deactMethod = 7; addColorsRandom(-1); } else { deactMethod = 8; addColorsRandom(-1); } break; case 5: if (KMBombInfoExtensions.GetBatteryHolderCount(Info) >= 2) { deactMethod = 9; addColorsRandom(sunPos); } else { deactMethod = 10; addColorsRandom(-1); } break; case 6: Regex b = new Regex("[aeiou]", RegexOptions.IgnoreCase); if (b.Match(KMBombInfoExtensions.GetSerialNumberLetters(Info).Join()).Success) { deactMethod = 11; addColorsRandom(6); } else { deactMethod = 12; //Add colors int next = -1; int count = 0; for (int i = 0; i < 7; i++) { colorActionsMain[i] = Random.Range(0, 5) == 0 ? next++ % 3 + 1 : 0; count += Min(colorActionsMain[i], 1); if (count > 5) { break; } } while (count < 3) { int i = Random.Range(0, 7); if (colorActionsMain[i] == 0) { colorActionsMain[i] = next++ % 3 + 1; count++; } } } break; } //Make sure the sun has no interactions which change colors if (colorActionsLight[sunPos] != 0 || colorActionsMain[sunPos] != 0) { goto redo; } //Make sure all colors are present only once bool[] present = new bool[3]; for (int i = 0; i < 7; i++) { if (colorActionsLight[i] != 0) { if (present[colorActionsLight[i] - 1]) { goto redo; } else { present[colorActionsLight[i] - 1] = true; } } if (colorActionsMain[i] != 0) { if (present[colorActionsMain[i] - 1]) { goto redo; } else { present[colorActionsMain[i] - 1] = true; } } } if (present.Contains(false)) { goto redo; } Debug.LogFormat("[Nomai #{0}] Deactivation method: {1}", _moduleId, DEACTMETHODS[deactMethod - 1]); goalColor = Random.Range(1, 4); Debug.LogFormat("[Nomai #{0}] Goal color: {1}", _moduleId, COLORS[goalColor]); Debug.LogFormat("[Nomai #{0}] Color interactions:", _moduleId); for (int i = 0; i < 7; i++) { if (colorActionsLight[i] != 0) { Debug.LogFormat("[Nomai #{0}] Interacting with the status light on {1} causes the timer to turn {2}.", _moduleId, i == 6 ? "the sixth location" : "planet " + i, COLORS[colorActionsLight[i]]); } if (colorActionsMain[i] != 0) { Debug.LogFormat("[Nomai #{0}] Interacting with the main planet on {1} causes the timer to turn {2}.", _moduleId, i == 6 ? "the sixth location" : "planet " + i, COLORS[colorActionsMain[i]]); } } }