Exemple #1
0
    void Start()
    {
        words = new string[100] {
            "child", "style", "shake", "alive", "axion", "wreck", "cause", "pupil", "cheat", "watch",
            "jelly", "clock", "quark", "grass", "laser", "jeans", "yacht", "rumor", "fault", "hover",
            "sheet", "aware", "shell", "jolly", "giant", "vague", "image", "acute", "arena", "visit",
            "table", "force", "chair", "quick", "suite", "large", "chord", "power", "aloof", "attic",
            "cover", "prize", "trail", "cycle", "sight", "zeros", "glare", "angle", "ranch", "upset",
            "mixer", "drive", "xenon", "water", "venom", "right", "sweet", "gloom", "clash", "abbey",
            "level", "quilt", "climb", "tease", "knock", "fairy", "queen", "zebra", "guide", "south",
            "funny", "proud", "young", "jumpy", "staff", "query", "trunk", "zooms", "smart", "ghost",
            "judge", "yield", "brain", "helix", "small", "noise", "seize", "robot", "stain", "where",
            "world", "shark", "beard", "disco", "yummy", "title", "story", "color", "short", "fresh"
        };

        letterTaps = new string[25] {
            "A", "B", "C", "D", "E",
            "F", "G", "H", "I", "J",
            "L", "M", "N", "O", "P",
            "Q", "R", "S", "T", "U",
            "V", "W", "X", "Y", "Z"
        };

        submission       = new int[10];
        paused           = true;
        submissionString = "";
        serialNum        = KMBombInfoExtensions.GetSerialNumber(bombInfo);

        module.OnActivate      += Activate;
        button.OnInteract      += delegate { ButtonPressed(); return(false); };
        button.OnInteractEnded += ButtonReleased;
    }
Exemple #2
0
    //-----------------------------
    // Failed attempt at making a unique puzzle generator. Anyone reading this can try making a unique puzzle generator and I will implement it. Until then, I will have pre-made puzzles.
    //-----------------------------

    void Start()
    {
        serialNumber       = KMBombInfoExtensions.GetSerialNumber(info);
        module.OnActivate += ActivateModule;

        // First # is button number, Second # is label of button. Label '10' is a blank square.
        puzzleList = new string[, ]
        {
            { "3 2", "11 2", "14 1", "15 0", "21 1" },
            { "1 2", "9 2", "12 4", "15 2", "24 1" },
            { "1 2", "4 1", "20 1", "24 2", "x" },
            { "1 2", "4 2", "23 2", "24 0", "x" },
            { "10 3", "19 1", "22 10", "23 1", "x" },
            { "0 2", "3 2", "14 2", "20 10", "22 1" },
            { "0 2", "12 2", "14 10", "22 10", "x" },
            { "0 2", "4 0", "20 0", "24 2", "x" },
            { "2 3", "14 3", "20 2", "x", "x" },
            { "4 2", "10 10", "12 3", "24 10", "x" },
            { "0 10", "2 0", "7 1", "12 3", "20 1" },
        };

        //The space after each index is nessisary.
        //{" ", " ", " ", " "},
        puzzleSolutions = new string[, ]
        {
            { "1 17 ", "2 8 18 ", "6 12 22 ", "13 23 " },
            { "2 5 13 16 ", "3 6 14 17 ", "7 10 18 21 ", "8 11 19 22 " },
            { "2 6 10 13 17 ", "3 14 ", "15 22 ", "8 12 16 19 23 " },
            { "2 6 10 ", "3 9 ", "15 21 ", "14 18 22 " },
            { "0 3 15 ", "1 4 7 13 16 ", "5 8 11 17 20 ", "9 18 21 " },
            { "1 5 18 ", "2 8 19 ", "10 16 23 ", "13 17 24 " },
            { "1 3 5 15 18 ", "2 4 16 19 ", "8 10 20 23 ", "7 9 11 21 24 " },
            { "1 5 ", "2 8 14 ", "10 16 22 ", "19 23 " },
            { "0 3 7 10 18 ", "1 4 11 17 19 ", "5 12 15 21 23 ", "6 9 13 22 24 " },
            { "0 2 15 17 ", "1 3 9 16 18 ", "5 7 13 20 22 ", "6 14 21 23 " },
            { "5 13 16 ", "6 14 17 ", "10 18 21 ", "11 19 22 " },
        };

        submitedSolution = new string[4];
        currentPuzzle    = new string[25] {
            "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
        };

        submit.OnInteract += SubmitPressed();

        for (int i = 0; i < buttons.Length; i++)
        {
            buttons[i].OnInteract += ButtonPressed(i);
        }

        for (int i = 0; i < pieceButtons.Length; i++)
        {
            pieceButtons[i].OnInteract += PieceButtonPressed(i);
        }
    }
    void Start()
    {
        if (KTMissionGetter.Mission.ID == MISSION_ID)
        {
            _isTFA = true;
            ghost.material.mainTexture = tweet;
            Debug.LogFormat("[Salts #{0}] This Salts is secretly Twitter. It will solve automatically at the end of the other bomb.", _id);
            return;
        }

        int sum = 0;

        foreach (int i in KMBombInfoExtensions.GetSerialNumberNumbers(GetComponent <KMBombInfo>()))
        {
            sum += i;
        }
        answer1 = sum / 5;
        answer2 = sum % 5;

        Debug.LogFormat("[Salts #{0}] Tap the ghost {1} times, then {2} times.", _id, answer1 + 1, answer2 + 1);

        button.OnInteract += Press;
    }
    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();
    }
Exemple #5
0
    // 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]);
    }
 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;
 }
Exemple #7
0
    //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]]);
            }
        }
    }
Exemple #8
0
    void Init()
    {
        for (int i = 0; i < formulaShow.Length; i++)
        {
            formulaShow[i] = Random.value < .5 ? true : false;
        }
        AmountGroup.SetActive(false);

        readChar       = (char)Random.Range(65, 91);
        readColor      = Random.Range(0, 8);
        ReadText.text  = "" + readChar;
        ReadText.color = readColors[readColor];
        DebugLog("Displayed letter is " + readColorLogs[readColor] + " " + readChar);

        int serialSum   = KMBombInfoExtensions.GetSerialNumberNumbers(Info).Sum();
        int reactionNum = readChar - 65;

        if (reactionNum > serialSum)
        {
            reactionNum -= serialSum;
        }
        reactionNum   %= 8;
        chosenReaction = reactions[reactionNum];

        productAmount  = readColorValues[readColor];
        productAmount += KMBombInfoExtensions.GetOffIndicators(Info).Count();
        int portCount = KMBombInfoExtensions.GetPortCount(Info);

        if (portCount > 1)
        {
            productAmount *= portCount;
        }
        productAmount %= 50;
        if (productAmount == 0)
        {
            productAmount = 50;
        }
        productAmount *= 10;
        productAmount -= KMBombInfoExtensions.GetOnIndicators(Info).Count();
        if (productAmount <= 0)
        {
            DebugLog("That's a lot of lit indicators. I guess you deserve this.");
            SolveModule();
            return;
        }

        if (chosenReaction.Solvent == null)
        {
            solventAdded = 100.000m;
        }

        DebugLog("Reaction: " + chosenReaction.Product.GetLogString());
        DebugLog("Product amount: " + productAmount + "g");
        DebugLog("Solvent: " + (chosenReaction.Solvent == null ? "None" : chosenReaction.Solvent.GetLogString()));
        DebugLog("Required reagents:");
        foreach (Compound r in chosenReaction.Reagents)
        {
            DebugLog(" - " + chosenReaction.GetReagentAmount(r, productAmount) + r.GetUnit() + " of " + r.GetLogString());
        }
        DebugLog("----------------------------------");
    }