private IEnumerator Reset()
    {
        for (int i = 0; i < 11; i++)
        {
            if (i > 0)
            {
                remaining = 10 - i;
                if (open == true && pressable == false)
                {
                    pressable = true;
                }
                if (i > 1)
                {
                    arrows[i - 2].material = arrowcol[1];
                    arrows[i + 7].material = arrowcol[1];
                }
                if (i > 9)
                {
                    i = -1;
                }
                if (i != -1)
                {
                    if (twitchActive && open && i == 1 && !solvable)
                    {
                        yield return(new WaitForSeconds(9));
                    }
                    yield return(new WaitForSeconds(1));
                }
            }
            else
            {
                if (i == 0)
                {
                    if (open == true)
                    {
                        if (solvable == false)
                        {
                            open      = false;
                            movehatch = true;
                            disp.text = string.Empty;
                            button.GetComponent <Renderer>().material = arrowcol[1];
                        }
                        if (submitted == false && solvable == false)
                        {
                            GetComponent <KMBombModule>().HandleStrike();
                            screen.material = arrowcol[0];
                            Debug.LogFormat("[The Very Annoying Button #{0}] Error: Button not pressed", moduleId);
                        }
                        else if (submitted == true && !valid[buttoncolour].Where(x => !record.Contains(x)).Contains(submission))
                        {
                            GetComponent <KMBombModule>().HandleStrike();
                            screen.material = arrowcol[0];
                            Debug.LogFormat("[The Very Annoying Button #{0}] Error: Invalid submission", moduleId);
                        }
                        else if (submitted == true)
                        {
                            if (solvable == true)
                            {
                                GetComponent <KMBombModule>().HandlePass();
                                screen.material = arrowcol[3];
                                disp.text       = string.Empty;
                                button.GetComponent <Renderer>().material = arrowcol[1];
                                Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform);
                                Debug.Log("OK");
                                moduleSolved = true;
                            }
                            else
                            {
                                record[buttoncolour] = submission;
                                Debug.LogFormat("[The Very Annoying Button #{0}] OK: The {2} button has recorded the value {1}", moduleId, submission, collog[buttoncolour]);
                                Audio.PlaySoundAtTransform("InputCorrect", transform);
                            }
                        }
                        submitted  = false;
                        pressable  = false;
                        submission = -1;
                    }
                    else
                    {
                        int r = Random.Range(0, 10);
                        if (solvable == true || r < counter)
                        {
                            counter = Mathf.FloorToInt(4 * bomb.GetSolvedModuleNames().Where(x => !exempt.Contains(x)).Count() / (bomb.GetSolvableModuleNames().Where(x => !exempt.Contains(x)).Count() + 1)) - 1;
                            if (open == false)
                            {
                                open      = true;
                                movehatch = true;
                            }
                            if (movehatch == false)
                            {
                                movehatch = true;
                            }
                            buttoncolour = Random.Range(0, 4);
                            disp.text    = "RYGB"[buttoncolour].ToString();
                            button.GetComponent <Renderer>().material = buttoncol[buttoncolour];
                            switch (buttoncolour)
                            {
                            case 0:
                                disp.color = new Color32(255, 0, 0, 255);
                                break;

                            case 1:
                                disp.color = new Color32(255, 255, 0, 255);
                                break;

                            case 2:
                                disp.color = new Color32(0, 255, 0, 255);
                                break;

                            case 3:
                                disp.color = new Color32(0, 0, 255, 255);
                                break;
                            }
                            Debug.LogFormat("[The Very Annoying Button #{0}] The button had turned {1} at {2}", moduleId, collog[buttoncolour], bomb.GetFormattedTime());
                        }
                        else
                        {
                            counter++;
                        }
                    }
                    if (movehatch == true)
                    {
                        for (int j = 0; j < 10; j++)
                        {
                            if (open == true)
                            {
                                hatch[0].transform.localEulerAngles += new Vector3(0, 0, 4);
                                hatch[1].transform.localEulerAngles -= new Vector3(0, 0, 4);
                            }
                            else
                            {
                                hatch[0].transform.localEulerAngles -= new Vector3(0, 0, 4);
                                hatch[1].transform.localEulerAngles += new Vector3(0, 0, 4);
                            }
                            yield return(new WaitForSeconds(0.1f));
                        }
                        movehatch = false;
                    }
                    if (bomb.GetSolvableModuleNames().Where(x => !exempt.Contains(x)).Count() == bomb.GetSolvedModuleNames().Count() || bomb.GetTime() < 60)
                    {
                        solvable = true;
                    }
                    if (moduleSolved == true)
                    {
                        break;
                    }
                }
                for (int j = 0; j < 9; j++)
                {
                    arrows[j].material     = arrowcol[0];
                    arrows[j + 9].material = arrowcol[0];
                    yield return(new WaitForSeconds(0.1f));
                }
                screen.material = arrowcol[1];
            }
        }
        for (int j = 0; j < 18; j++)
        {
            if (j < 9)
            {
                arrows[j].material     = arrowcol[3];
                arrows[j + 9].material = arrowcol[3];
            }
            else
            {
                arrows[j - 9].material = arrowcol[1];
                arrows[j].material     = arrowcol[1];
            }
            if (j == 17)
            {
                j = -1;
            }
            yield return(new WaitForSeconds(0.1f));
        }
    }
示例#2
0
    private void Awake()
    {
        moduleId = moduleIdCounter++;
        foreach (KMSelectable button in buttons)
        {
            button.OnInteract += delegate() { PressButton(button); return(false); }
        }
        ;
        submit.OnInteract += delegate() { PressSubmit(); return(false); };
        clear.OnInteract  += delegate() { PressClear(); return(false); };
    }

    void Start()
    {
        SetupDict();
        int moduleCode = Random.Range(0, moduleNames.Length);

        answer = moduleNames[moduleCode];
        string anagram = modules[answer];

        ana.text = anagram.ToUpper();
        ans.text = "";
        foreach (GameObject but in buttonObjects)
        {
            but.SetActive(false);
        }

        foreach (char letter in answer.ToUpper().ToCharArray())
        {
            buttonObjects[keys[letter]].SetActive(true);
        }
        Debug.LogFormat("[Insanagrams #{0}] Anagram: '{1}', Answer: '{2}'", moduleId, anagram, answer);
    }

    void PressButton(KMSelectable button)
    {
        newAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, button.transform);
        button.AddInteractionPunch(.5f);
        if (moduleSolved)
        {
            return;
        }
        if (Array.IndexOf(buttons, button) == 45)
        {
            ans.text += " ";
        }
        else
        {
            ans.text += button.GetComponentInChildren <TextMesh>().text;
        }
    }

    void PressSubmit()
    {
        newAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, submit.transform);
        if (moduleSolved)
        {
            return;
        }
        if (ans.text.ToUpper().Equals(answer.ToUpper()))
        {
            module.HandlePass();
            moduleSolved = true;
            newAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, submit.transform);
            Debug.LogFormat("[Insanagrams #{0}] Solved!", moduleId);
        }
        else
        {
            module.HandleStrike();
            Debug.LogFormat("[Insanagrams #{0}] Strike! Inputted: '{1}'. If you feel like this is an error, contact TasThing#5896 on Discord with a copy of this log file.", moduleId, ans.text);
            ans.text = "";
        }
    }

    void PressClear()
    {
        newAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, submit.transform);
        if (moduleSolved)
        {
            return;
        }
        Debug.LogFormat("[Insanagrams #{0}] Clear pressed. Text cleared: '{1}'.", moduleId, ans.text);
        ans.text = "";
    }

    void SetupDict()
    {
        keys.Add('A', 0);
        keys.Add('B', 1);
        keys.Add('C', 2);
        keys.Add('D', 3);
        keys.Add('E', 4);
        keys.Add('F', 5);
        keys.Add('G', 6);
        keys.Add('H', 7);
        keys.Add('I', 8);
        keys.Add('J', 9);
        keys.Add('K', 10);
        keys.Add('L', 11);
        keys.Add('M', 12);
        keys.Add('N', 13);
        keys.Add('O', 14);
        keys.Add('P', 15);
        keys.Add('Q', 16);
        keys.Add('R', 17);
        keys.Add('S', 18);
        keys.Add('T', 19);
        keys.Add('U', 20);
        keys.Add('V', 21);
        keys.Add('W', 22);
        keys.Add('X', 23);
        keys.Add('Y', 24);
        keys.Add('Z', 25);
        keys.Add('1', 26);
        keys.Add('2', 27);
        keys.Add('3', 28);
        keys.Add('4', 29);
        keys.Add('5', 30);
        keys.Add('6', 31);
        keys.Add('7', 32);
        keys.Add('8', 33);
        keys.Add('9', 34);
        keys.Add('0', 35);
        keys.Add('-', 36);
        keys.Add('[', 37);
        keys.Add(']', 38);
        keys.Add('\'', 39);
        keys.Add('.', 40);
        keys.Add('!', 41);
        keys.Add('?', 42);
        keys.Add('&', 43);
        keys.Add('^', 44);
        keys.Add(' ', 45);
        keys.Add(',', 46);


        moduleNames = new String[] { "101 Dalmatians", "3D Maze", "3D Tunnels", "Accumulation", "Adjacent Letters", "Adventure Game", "Air Traffic Controller", "Alchemy", "Algebra", "Alphabetical Order", "Alphabet Numbers", "Alphabet", "Anagrams", "Answering Questions", "Astrology", "Backgrounds", "Bartending", "Bases", "Battleship", "Benedict Cumberbatch", "Big Circle", "Binary LEDs", "Binary Puzzle", "Binary Tree", "Bitmaps", "Bitwise Operations", "Black Hole", "Blackjack", "Blind Alley", "Blind Maze", "Blockbusters", "Blue Cipher", "Boggle", "Boolean Maze", "Boolean Venn Diagram", "Braille", "British Slang", "Broken Buttons", "Broken Guitar Chords", "Burglar Alarm", "Button Masher", "Button Sequence", "Caesar Cipher", "Calendar", "Capacitor Discharge", "Catchphrase", "Challenge & Contact", "Character Shift", "Chinese Counting", "Cheap Checkout", "Chess", "Chord Qualities", "Christmas Presents", "Coffeebucks", "Color Addition", "Color Decoding", "Colored Squares", "Colored Switches", "Color Flash", "Colorful Insanity", "Colorful Madness", "Color Generator", "Color Match", "Color Math", "Color Morse", "Combination Lock", "Command Prompt", "Complex Keypad", "Complicated Buttons", "Complicated Wires", "Connection Check", "Connection Device", "Cookie Jars", "Cooking", "Coordinates", "Countdown", "Crackbox", "Crazy Talk", "Creation", "Cruel Countdown", "Cruel Piano Keys", "Cryptography", "Curriculum", "Cursed Double-Oh", "Decolored Squares", "Determinants", "DetoNATO", "Digital Cipher", "Digital Root", "Discolored Squares", "Divided Squares", "Dominoes", "Double-Oh", "Double Color", "Dr. Doctor", "Dragon Energy", "Edgework", "Elder Futhark", "Emoji Math", "Encrypted Morse", "Encryption Bingo", "English Test", "Equations", "Error Codes", "European Travel", "Extended Password", "Factoring", "Factory Maze", "Fast Math", "Faulty Backgrounds", "Festive Piano Keys", "Filibuster", "FizzBuzz", "Flags", "Flashing Lights", "Flavor Text EX", "Flavor Text", "Flip The Coin", "Follow the Leader", "Font Select", "Foreign Exchange Rates", "Forget Everything", "Forget Me Not", "Forget This", "Free Parking", "Friendship", "Functions", "Gadgetron Vendor", "Game of Life Cruel", "Game of Life Simple", "Geometry Dash", "Genetic Sequence", "Graffiti Numbers", "Greek Calculus", "Green Cipher", "Gridlock", "Grid Matching", "Guitar Chords", "Harmony Sequence", "Hexamaze", "Hex To Decimal", "Hieroglyphics", "Hogwarts", "Homophones", "Horrible Memory", "Hot Potato", "HTTP Response", "Human Resources", "Hunting", "Ice Cream", "Identity Parade", "IKEA", "Indigo Cipher", "Insanagrams", "Instructions", "Keypad", "Knob", "Know Your Way", "Krazy Talk", "Kudosudoku", "Lasers", "Laundry", "LED Encryption", "LED Grid", "LED Math", "Left And Right", "LEGO", "Letter Keys", "Light Cycle", "Lights Out", "Lightspeed", "Lion's Share", "Listening", "Logical Buttons", "Logic Gates", "Logic", "Mad Memory", "Mafia", "Mahjong", "Maintenance", "Manometers", "Marble Tumble", "Maritime Flags", "Mashematics", "Mastermind Cruel", "Mastermind Simple", "Math", "Maze Scrambler", "Maze", "Melody Sequencer", "Memory", "Micro-Modules", "Microcontroller", "Mineseeker", "Minesweeper", "Modern Cipher", "Module Homework", "Module Maze", "Modules Against Humanity", "Modulo", "Monsplode, Fight!", "Monsplode Trading Cards", "Morse-A-Maze", "Morse Code", "Morse Identification", "Morsematics", "Morse War", "Mortal Kombat", "Motion Sense", "Mouse In The Maze", "Murder", "Mystic Square", "Needy Mrs Bob", "Neutralization", "Nonogram", "Number Nimbleness", "Number Pad", "Numbers", "Only Connect", "Orientation Cube", "Painting", "Party Time", "Passport Control", "Password", "Pattern Cube", "Pay Respects", "Periodic Table", "Perplexing Wires", "Perspective Pegs", "Piano Keys", "Pie", "Pigpen Rotations", "Playfair Cipher", "Plumbing", "Poetry", "Point of Order", "Poker", "Polyhedral Maze", "Press X", "Probing", "QR Code", "Question Mark", "Quintuples", "Radiator", "Random Number Generator", "Rapid Buttons", "Refill that Beer!", "Regular Crazy Talk", "Resistors", "Retirement", "Reverse Morse", "Rhythms", "Rock-Paper-Scissors-Lizard-Spock", "Rotary Phone", "Round Keypad", "Rubik's Clock", "Rubik's Cube", "S.E.T.", "Safety Safe", "Schlag den Bomb", "Scripting", "Sea Shells", "Semaphore", "Shape Memory", "Shapes And Bombs", "Shape Shift", "Shikaku", "Signals", "Silly Slots", "Simon's Sequence", "Simon's Stages", "Simon's Star", "Simon Samples", "Simon Says", "Simon Scrambles", "Simon Screams", "Simon Sends", "Simon Shrieks", "Simon Sings", "Simon Sounds", "Simon Speaks", "Simon Spins", "Simon Squawks", "Simon States", "Sink", "Skewed Slots", "Skinny Wires", "Skyrim", "Snooker", "Sonic & Knuckles", "Sonic the Hedgehog", "Souvenir", "Spinning Buttons", "Splitting The Loot", "Square Button", "Street Fighter", "Subways", "Sueet Wall", "Superlogic", "Switches", "Symbol Cycle", "Symbolic Coordinates", "Symbolic Password", "SYNC-125 [3]", "Synchronization", "Synonyms", "T-Words", "Tangrams", "Tap Code", "Tasha Squeals", "Tax Returns", "Ten-Button Color Code", "Tennis", "Ternary Converter", "Tetris", "Text Field", "The Bulb", "The Button", "The Clock", "The Code", "The Crystal Maze", "The Cube", "The Digit", "The Festive Jukebox", "The Fidget Spinner", "The Gamepad", "The Hangover", "The Hexabutton", "The iPhone", "The Jack-O'-Lantern", "The Jewel Vault", "The Jukebox", "The Labyrinth", "The London Underground", "The Moon", "The Number Cipher", "The Number", "The Plunger Button", "The Plunger", "The Radio", "The Screw", "The Sphere", "The Stock Market", "The Stopwatch", "The Sun", "The Swan", "The Switch", "The Time Keeper", "The Triangle", "The Wire", "Third Base", "Tic Tac Toe", "Timezone", "Tower of Hanoi", "Turn The Keys", "Turn The Key", "Turtle Robot", "Two Bits", "Ultrastores", "Uncolored Squares", "Unfair Cipher", "Unrelated Anagrams", "USA Maze", "Valves", "Varicolored Squares", "Venting Gas", "Violet Cipher", "Visual Impairment", "Waste Management", "Web Design", "Westeros", "Who's on First", "Who's That Monsplode", "Wingdings", "Wire Placement", "Wire Sequence", "Wire Spaghetti", "Wires", "Word Scramble", "Word Search", "X-Ray", "X01", "Yahtzee", "Zoni", "Zoo", "Subscribe to Pewdiepie", "Grocery Store", "Draw", "Burger Alarm", "Purgatory", "Mega Man 2", "Lombax Cubes", "The Stare", "Graphic Memory", "Quiz Buzz", "Wavetapping", "The Hypercube", "Speak English", "Stack'em", "Seven Wires", "Colored Keys", "The Troll", "Planets", "The Necronomicon", "Four-Card Monte", "Aa", "The Witness", "The Giant's Drink", "Digit String", "Alpha", "Snap!", "Hidden Colors", "Colour Code", "Vexillology", "Brush Strokes", "Odd One Out", "The Triangle Button", "Mazematics", "Equations X", "Maze^3", "Yellow Cipher", "Orange Cipher", "Red Cipher", "Faulty RGB Maze", "Forget Me Later", "Garfield Kart", "Footnotes", "Bamboozling Button", "Fruits", "The Modkit", "Tetravex", "Flower Patch", "Matchematics", "Caesar Cycle", "Playfair Cycle", "Cryptic Cycle", "Ultimate Cycle", "Bamboozling Button Grid", "Old Fogey", "The Ultracube", "Snakes and Ladders", "Module Movements", "Roman Numerals", "Red Buttons", "The Rule", "Lousy Chess", "Keypad Lock", "Eight Pages", "The Colored Maze", "White Cipher", "Gray Cipher", "Black Cipher", "The Hyperlink", "Corners", "The High Score",
                                     "Ingredients", "Intervals", "Cheep Checkout", "Spelling Bee", "Thinking Wires", "Seven Choose Four", "Object Shows", "Lunchtime", "Natures", "Neutrinos", "Scavenger Hunt", "Polygons", "Codenames", "Odd Mod Out", "Blinkstop", "Forget It Not", "Rainbow Arrows", "Passcodes", "Digital Dials", "Lines of Code", "Encrypted Dice", "Colorful Dials", "Atbash Cipher", "Addition", "Matrices", "Cruel Keypads", "The Black Page", "Simon Forgets", "Greek Letter Grid", "Going Backwards", "Scalar Dials", "Keywords", "The Crafting Table" };

        modules.Add("101 Dalmatians", "101 Natal Maids");
        modules.Add("3D Maze", "Am Zed 3");
        modules.Add("3D Tunnels", "Lend 3 Nuts");
        modules.Add("Accumulation", "I Am Uncut Cola");
        modules.Add("Adjacent Letters", "Calendar Jet Test");
        modules.Add("Adventure Game", "Meet Guava Nerd");
        modules.Add("Air Traffic Controller", "Antarctic Floor Rifler");
        modules.Add("Alchemy", "Hey Clam");
        modules.Add("Algebra", "Lab Gear");
        modules.Add("Alphabetical Order", "A Birthplace Reload");
        modules.Add("Alphabet Numbers", "A Bat Burns Me Help");
        modules.Add("Alphabet", "Bath Leap");
        modules.Add("Anagrams", "A Mr Sagan");
        modules.Add("Answering Questions", "Earn Wings Noses Quit");
        modules.Add("Astrology", "Royals Tog");
        modules.Add("Backgrounds", "Dragon Bucks");
        modules.Add("Bartending", "Intend Brag");
        modules.Add("Bases", "Sea BS");
        modules.Add("Battleship", "Hip Tablets");
        modules.Add("Benedict Cumberbatch", "Butch Em Bent Iced Crab");
        modules.Add("Big Circle", "Big Cleric");
        modules.Add("Binary LEDs", "Badly Risen");
        modules.Add("Binary Puzzle", "Early Buzz Pin");
        modules.Add("Binary Tree", "Bye Terrain");
        modules.Add("Bitmaps", "Ms Pi Bat");
        modules.Add("Bitwise Operations", "Is It Web Arose Point");
        modules.Add("Black Hole", "Be Lo Chalk");
        modules.Add("Blackjack", "Cab JK Lack");
        modules.Add("Blind Alley", "A Lend By Ill");
        modules.Add("Blind Maze", "Me Land Biz");
        modules.Add("Blockbusters", "Rubble Stocks");
        modules.Add("Blue Cipher", "Burp Lichee");
        modules.Add("Boggle", "Log Beg");
        modules.Add("Boolean Maze", "Enable A Zoom");
        modules.Add("Boolean Venn Diagram", "Drag Aim Ban Novel One");
        modules.Add("Braille", "Ill Bear");
        modules.Add("British Slang", "Snails Bright");
        modules.Add("Broken Buttons", "Stubborn Token");
        modules.Add("Broken Guitar Chords", "A Corgi Dubs Horn Trek");
        modules.Add("Burglar Alarm", "Rural Lamb Rag");
        modules.Add("Button Masher", "Share Tomb Nut");
        modules.Add("Button Sequence", "On Ten Cube Quest");
        modules.Add("Caesar Cipher", "Crisp Ear Ache");
        modules.Add("Calendar", "Red Canal");
        modules.Add("Capacitor Discharge", "It Graced His Orca Cap");
        modules.Add("Catchphrase", "Cash Chapter");
        modules.Add("Challenge & Contact", "Agent Cloth & Cancel");
        modules.Add("Character Shift", "Scratch Hat Fire");
        modules.Add("Chinese Counting", "Eugenic Notch Sin");
        modules.Add("Cheap Checkout", "Oh Cupcake Tech");
        modules.Add("Chess", "SS Ech");
        modules.Add("Chord Qualities", "Quad Ostrich Lie");
        modules.Add("Christmas Presents", "Pens Rest Charm Sits");
        modules.Add("Coffeebucks", "Beck Cue Offs");
        modules.Add("Color Addition", "Cation Lid Door");
        modules.Add("Color Decoding", "Diced Corn Logo");
        modules.Add("Colored Squares", "Dress Or Coequal");
        modules.Add("Colored Switches", "Witches Close Rod");
        modules.Add("Color Flash", "Call For Hos");
        modules.Add("Colorful Insanity", "Run So Fictionally");
        modules.Add("Colorful Madness", "Mad Focus Enrolls");
        modules.Add("Color Generator", "Lone Rotor Grace");
        modules.Add("Color Match", "Halt Mr Coco");
        modules.Add("Color Math", "Roam Cloth");
        modules.Add("Color Morse", "Mr Sore Cool");
        modules.Add("Combination Lock", "Black Coin Motion");
        modules.Add("Command Prompt", "Mr Mod Pant Comp");
        modules.Add("Complex Keypad", "My Explode Pack");
        modules.Add("Complicated Buttons", "Placed Bottom Tunics");
        modules.Add("Complicated Wires", "Rides Camel Tip Cow");
        modules.Add("Connection Check", "Chick Con One Cent");
        modules.Add("Connection Device", "Once Vented Iconic");
        modules.Add("Cookie Jars", "Is Orca Joke");
        modules.Add("Cooking", "Nick Goo");
        modules.Add("Coordinates", "Second Ratio");
        modules.Add("Countdown", "On Duct Now");
        modules.Add("Crackbox", "Cork Cab X");
        modules.Add("Crazy Talk", "Lazy Track");
        modules.Add("Creation", "Rate Icon");
        modules.Add("Cruel Countdown", "Run Coconut Weld");
        modules.Add("Cruel Piano Keys", "Recoup Sky Alien");
        modules.Add("Cryptography", "Try Choppy Rag");
        modules.Add("Curriculum", "I Curl Mu Cur");
        modules.Add("Cursed Double-Oh", "Should Cube-Redo");
        modules.Add("Decolored Squares", "A Corroded Sequels");
        modules.Add("Determinants", "Tanned Mister");
        modules.Add("DetoNATO", "To Donate");
        modules.Add("Digital Cipher", "Pi Acid Lighter");
        modules.Add("Digital Root", "Dog Tail Riot");
        modules.Add("Discolored Squares", "Careless Squid Door");
        modules.Add("Divided Squares", "Revise Dad Squid");
        modules.Add("Dominoes", "Dime Soon");
        modules.Add("Double-Oh", "Blood-hue");
        modules.Add("Double Color", "Cool Boulder");
        modules.Add("Dr. Doctor", "Cord. Trod");
        modules.Add("Dragon Energy", "Grand Grey One");
        modules.Add("Edgework", "Word Geek");
        modules.Add("Elder Futhark", "Father Lurked");
        modules.Add("Emoji Math", "He Omit Jam");
        modules.Add("Encrypted Morse", "Ms Creed Entropy");
        modules.Add("Encryption Bingo", "Benign Cry Option");
        modules.Add("English Test", "Tense Lights");
        modules.Add("Equations", "In Quote As");
        modules.Add("Error Codes", "Score Order");
        modules.Add("European Travel", "A Nepal Overture");
        modules.Add("Extended Password", "Next Spades Worded");
        modules.Add("Factoring", "Acorn Gift");
        modules.Add("Factory Maze", "To Crazy Fame");
        modules.Add("Fast Math", "That Ms Fa");
        modules.Add("Faulty Backgrounds", "Arguably Duck Fonts");
        modules.Add("Festive Piano Keys", "Pokeys Vine Fiesta");
        modules.Add("Filibuster", "Built Fires");
        modules.Add("FizzBuzz", "Bizz Fuzz");
        modules.Add("Flags", "SF Lag");
        modules.Add("Flashing Lights", "Gall Fish Things");
        modules.Add("Flavor Text EX", "To Flax Vertex");
        modules.Add("Flavor Text", "Flat Vortex");
        modules.Add("Flip The Coin", "Fiction Help");
        modules.Add("Follow the Leader", "Defeat Whole Roll");
        modules.Add("Font Select", "Elf Net Cost");
        modules.Add("Foreign Exchange Rates", "A Teachers Genre Foxing");
        modules.Add("Forget Everything", "Very Tethering Fog");
        modules.Add("Forget Me Not", "Ten Foot Germ");
        modules.Add("Forget This", "To Fighters");
        modules.Add("Free Parking", "Fire Rank Peg");
        modules.Add("Friendship", "Shred If Pin");
        modules.Add("Functions", "Unfit Cons");
        modules.Add("Gadgetron Vendor", "Not Graded Govern");
        modules.Add("Game of Life Cruel", "Cameo Figure Fell");
        modules.Add("Game of Life Simple", "Female Implies Fog");
        modules.Add("Geometry Dash", "Gated Rye Ohms");
        modules.Add("Genetic Sequence", "Get Science Queen");
        modules.Add("Graffiti Numbers", "Rift Beam Surfing");
        modules.Add("Greek Calculus", "Glue Us Crackle");
        modules.Add("Green Cipher", "He Rep Cringe");
        modules.Add("Gridlock", "Gold Rick");
        modules.Add("Grid Matching", "Mind Chart Gig");
        modules.Add("Guitar Chords", "Guard Ostrich");
        modules.Add("Harmony Sequence", "Shy Queen Romance");
        modules.Add("Hexamaze", "Haze Exam");
        modules.Add("Hex To Decimal", "Aced Hotel Mix");
        modules.Add("Hieroglyphics", "Holy Pig Riches");
        modules.Add("Hogwarts", "Raw Goths");
        modules.Add("Homophones", "No Home Hops");
        modules.Add("Horrible Memory", "Me Blimey Horror");
        modules.Add("Hot Potato", "Tattoo Hop");
        modules.Add("HTTP Response", "Hen Strep Stop");
        modules.Add("Human Resources", "Ace Nurses Humor");
        modules.Add("Hunting", "Hint Gun");
        modules.Add("Ice Cream", "Mice Race");
        modules.Add("Identity Parade", "Painted Dietary");
        modules.Add("IKEA", "I Eak");
        modules.Add("Indigo Cipher", "Heroic Pidgin");
        modules.Add("Insanagrams", "Assign An Arm");
        modules.Add("Instructions", "Us Or Instinct");
        modules.Add("Keypad", "APK Dye");
        modules.Add("Knob", "Bonk");
        modules.Add("Know Your Way", "Yuk Yo Own Raw");
        modules.Add("Krazy Talk", "Talky Ark Z");
        modules.Add("Kudosudoku", "Duo Kou Dusk");
        modules.Add("Lasers", "Re Lass");
        modules.Add("Laundry", "Run Lady");
        modules.Add("LED Encryption", "Lyric Deponent");
        modules.Add("LED Grid", "Girdled");
        modules.Add("LED Math", "Mat Held");
        modules.Add("Left And Right", "Darling Theft");
        modules.Add("LEGO", "El Go");
        modules.Add("Letter Keys", "Elk Tyre Set");
        modules.Add("Light Cycle", "Eight LLC YC");
        modules.Add("Lights Out", "Tight Soul");
        modules.Add("Lightspeed", "Hedge Split");
        modules.Add("Lion's Share", "Hon's Serial");
        modules.Add("Listening", "In Tin Legs");
        modules.Add("Logical Buttons", "Bacon Guilt Lost");
        modules.Add("Logic Gates", "Locates Gig");
        modules.Add("Logic", "I Clog");
        modules.Add("Mad Memory", "Dear Mommy");
        modules.Add("Mafia", "I Am Fa");
        modules.Add("Mahjong", "Mag John");
        modules.Add("Maintenance", "Mice Antenna");
        modules.Add("Manometers", "Rename Most");
        modules.Add("Marble Tumble", "Met Lemur Blab");
        modules.Add("Maritime Flags", "Legit Mrs Mafia");
        modules.Add("Mashematics", "Sea Mismatch");
        modules.Add("Mastermind Cruel", "Unclear Midterms");
        modules.Add("Mastermind Simple", "Smeared Mint Limps");
        modules.Add("Math", "Hat M");
        modules.Add("Maze Scrambler", "Blame Mrs Craze");
        modules.Add("Maze", "M Eaz");
        modules.Add("Melody Sequencer", "Elm Encodes Query");
        modules.Add("Memory", "Me Or My");
        modules.Add("Micro-Modules", "Room-Dice Slum");
        modules.Add("Microcontroller", "Correct Ill Moron");
        modules.Add("Mineseeker", "Me Rise Keen");
        modules.Add("Minesweeper", "Newer Pi Seem");
        modules.Add("Modern Cipher", "Perched Mr Ion");
        modules.Add("Module Homework", "Lowered Hook Mum");
        modules.Add("Module Maze", "Mum Ole Daze");
        modules.Add("Modules Against Humanity", "Yum Dalmatians Toes In Ugh");
        modules.Add("Modulo", "Om Loud");
        modules.Add("Monsplode, Fight!", "Golfed Months, Pi!");
        modules.Add("Monsplode Trading Cards", "Landscaped Dorm Sorting");
        modules.Add("Morse-A-Maze", "Mrs A-Zee-Roam");
        modules.Add("Morse Code", "Do Some Rec");
        modules.Add("Morse Identification", "A Moist Iron Deficient");
        modules.Add("Morsematics", "Scariest Mom");
        modules.Add("Morse War", "Ear Worms");
        modules.Add("Mortal Kombat", "Mr Balk Tomato");
        modules.Add("Motion Sense", "No Semitones");
        modules.Add("Mouse In The Maze", "Seem To Humanize");
        modules.Add("Murder", "Mr Rude");
        modules.Add("Mystic Square", "Yes Squirm Cat");
        modules.Add("Needy Mrs Bob", "Ye Bomb Nerds");
        modules.Add("Neutralization", "Outran Alien Zit");
        modules.Add("Nonogram", "Moron Nag");
        modules.Add("Number Nimbleness", "Nine Emblems Burns");
        modules.Add("Number Pad", "Damper Bun");
        modules.Add("Numbers", "Burns Me");
        modules.Add("Only Connect", "Cent Con Only");
        modules.Add("Orientation Cube", "Iceboat Neutrino");
        modules.Add("Painting", "Giant Pin");
        modules.Add("Party Time", "I Am Pretty");
        modules.Add("Passport Control", "Clan Troop Sports");
        modules.Add("Password", "Saw Drops");
        modules.Add("Pattern Cube", "Pecan Butter");
        modules.Add("Pay Respects", "Pease Crypts");
        modules.Add("Periodic Table", "Tidier Placebo");
        modules.Add("Perplexing Wires", "Griper Pixel News");
        modules.Add("Perspective Pegs", "I Respect Vegs Pep");
        modules.Add("Piano Keys", "Noisy Peak");
        modules.Add("Pie", "I PE");
        modules.Add("Pigpen Rotations", "Orientating Pops");
        modules.Add("Playfair Cipher", "Reply Hip Africa");
        modules.Add("Plumbing", "Blimp Gun");
        modules.Add("Poetry", "Pry Toe");
        modules.Add("Point of Order", "Portioned For");
        modules.Add("Poker", "Rope K");
        modules.Add("Polyhedral Maze", "Amazed Hype Roll");
        modules.Add("Press X", "SS Prex");
        modules.Add("Probing", "Pig Born");
        modules.Add("QR Code", "CEO Dr Q");
        modules.Add("Question Mark", "A Squirm Token");
        modules.Add("Quintuples", "Lupin Quest");
        modules.Add("Radiator", "Radio Art");
        modules.Add("Random Number Generator", "A Bartender Moon Germ Run");
        modules.Add("Rapid Buttons", "Bad Printouts");
        modules.Add("Refill that Beer!", "Fret Hill Berate!");
        modules.Add("Regular Crazy Talk", "A Larger Lazy Truck");
        modules.Add("Resistors", "Sis Resort");
        modules.Add("Retirement", "Entire Term");
        modules.Add("Reverse Morse", "Me Server Rose");
        modules.Add("Rhythms", "Mrs Hyth");
        modules.Add("Rock-Paper-Scissors-Lizard-Spock", "Socks-Carload-Crops-Zipper-Risks");
        modules.Add("Rotary Phone", "Rare Typhoon");
        modules.Add("Round Keypad", "Yup Dank Redo");
        modules.Add("Rubik's Clock", "Irk Cub's Lock");
        modules.Add("Rubik's Cube", "Rubie's Buck");
        modules.Add("S.E.T.", "E.S.T.");
        modules.Add("Safety Safe", "Eases Taffy");
        modules.Add("Schlag den Bomb", "Belch Bangs Mod");
        modules.Add("Scripting", "Pic String");
        modules.Add("Sea Shells", "Eels Slash");
        modules.Add("Semaphore", "Hear Poems");
        modules.Add("Shape Memory", "My Semaphore");
        modules.Add("Shapes And Bombs", "Mesh Bobs Pandas");
        modules.Add("Shape Shift", "The Spa Fish");
        modules.Add("Shikaku", "Us Khaki");
        modules.Add("Signals", "Is Slang");
        modules.Add("Silly Slots", "Still Lossy");
        modules.Add("Simon's Sequence", "Ms Queen's Conies");
        modules.Add("Simon's Stages", "Tango's Misses");
        modules.Add("Simon's Star", "Smart's Ions");
        modules.Add("Simon Samples", "Misnames Slop");
        modules.Add("Simon Says", "Noisy Mass");
        modules.Add("Simon Scrambles", "Blames Crimsons");
        modules.Add("Simon Screams", "Miss Romances");
        modules.Add("Simon Sends", "Noses Minds");
        modules.Add("Simon Shrieks", "Skirmish Ones");
        modules.Add("Simon Sings", "Missing Son");
        modules.Add("Simon Sounds", "Mid Suns Soon");
        modules.Add("Simon Speaks", "Eskimo Snaps");
        modules.Add("Simon Spins", "Miss No Snip");
        modules.Add("Simon Squawks", "Ms Quasi Knows");
        modules.Add("Simon States", "Season Mitts");
        modules.Add("Sink", "Inks");
        modules.Add("Skewed Slots", "Slowest Desk");
        modules.Add("Skinny Wires", "Sky Is Winner");
        modules.Add("Skyrim", "My Risk");
        modules.Add("Snooker", "Rooks En");
        modules.Add("Sonic & Knuckles", "Conk & Luckiness");
        modules.Add("Sonic the Hedgehog", "Eighth Echoed Song");
        modules.Add("Souvenir", "One Virus");
        modules.Add("Spinning Buttons", "Tin Snot Snub Ping");
        modules.Add("Splitting The Loot", "Telling Tooth Spit");
        modules.Add("Square Button", "Rants Bouquet");
        modules.Add("Street Fighter", "Register Theft");
        modules.Add("Subways", "Buy Saws");
        modules.Add("Sueet Wall", "Wallet Use");
        modules.Add("Superlogic", "Police Rugs");
        modules.Add("Switches", "Chew Sits");
        modules.Add("Symbol Cycle", "My Cos By Cell");
        modules.Add("Symbolic Coordinates", "Cabs Consider Limo Toy");
        modules.Add("Symbolic Password", "Bypass Limo Crowds");
        modules.Add("SYNC-125 [3]", "NYCs-123 [5]");
        modules.Add("Synchronization", "Crazy Thin Onions");
        modules.Add("Synonyms", "My SS Nony");
        modules.Add("T-Words", "Sword-T");
        modules.Add("Tangrams", "Grant Sam");
        modules.Add("Tap Code", "Cape Dot");
        modules.Add("Tasha Squeals", "He Salsa Squat");
        modules.Add("Tax Returns", "Ranters Tux");
        modules.Add("Ten-Button Color Code", "Outdo Nettle-Corncob");
        modules.Add("Tennis", "Nest In");
        modules.Add("Ternary Converter", "Contrary Reverent");
        modules.Add("Tetris", "Sitter");
        modules.Add("Text Field", "Fed Ex Tilt");
        modules.Add("The Bulb", "Belt Hub");
        modules.Add("The Button", "Hot Tub Ten");
        modules.Add("The Clock", "Etch Lock");
        modules.Add("The Code", "Doc Thee");
        modules.Add("The Crystal Maze", "Zesty Cream Halt");
        modules.Add("The Cube", "He Be Cut");
        modules.Add("The Digit", "It Get Hid");
        modules.Add("The Festive Jukebox", "Bee Jive Text Of Husk");
        modules.Add("The Fidget Spinner", "Deepening Thrifts");
        modules.Add("The Gamepad", "Aged Pet Ham");
        modules.Add("The Hangover", "Her Hot Vegan");
        modules.Add("The Hexabutton", "Beneath Hot Tux");
        modules.Add("The iPhone", "Oh Hip Teen");
        modules.Add("The Jack-O'-Lantern", "Can't Not-Heal-Jerk");
        modules.Add("The Jewel Vault", "We Jut Have Tell");
        modules.Add("The Jukebox", "But Hex Joke");
        modules.Add("The Labyrinth", "Try Health Bin");
        modules.Add("The London Underground", "Goldenrod Thunder Noun");
        modules.Add("The Moon", "One Moth");
        modules.Add("The Number Cipher", "Breech Hermit Pun");
        modules.Add("The Number", "Mr Hen Tube");
        modules.Add("The Plunger Button", "Tenth Upturn Globe");
        modules.Add("The Plunger", "Nether Gulp");
        modules.Add("The Radio", "Head Riot");
        modules.Add("The Screw", "Chew Rest");
        modules.Add("The Sphere", "Eh Her Step");
        modules.Add("The Stock Market", "Hack Treks Totem");
        modules.Add("The Stopwatch", "Two Step Hatch");
        modules.Add("The Sun", "Uh Sent");
        modules.Add("The Swan", "New Hats");
        modules.Add("The Switch", "Which Test");
        modules.Add("The Time Keeper", "Met Tepee Hiker");
        modules.Add("The Triangle", "Hanger Title");
        modules.Add("The Wire", "Were Hit");
        modules.Add("Third Base", "Bead Shirt");
        modules.Add("Tic Tac Toe", "Cat Cot Tie");
        modules.Add("Timezone", "Monetize");
        modules.Add("Tower of Hanoi", "Antihero Woof");
        modules.Add("Turn The Keys", "Try Hut Knees");
        modules.Add("Turn The Key", "Then Turkey");
        modules.Add("Turtle Robot", "Torture Bolt");
        modules.Add("Two Bits", "Bit Stow");
        modules.Add("Ultrastores", "Laser Tutors");
        modules.Add("Uncolored Squares", "Our Sons Lacquered");
        modules.Add("Unfair Cipher", "Hi Rip Furnace");
        modules.Add("Unrelated Anagrams", "A Guardsman Eternal");
        modules.Add("USA Maze", "Amaze Us");
        modules.Add("Valves", "Slave V");
        modules.Add("Varicolored Squares", "Discover Quasar Lore");
        modules.Add("Venting Gas", "Vegan Sting");
        modules.Add("Violet Cipher", "Hitler Cove Pi");
        modules.Add("Visual Impairment", "A Minus Lit Vampire");
        modules.Add("Waste Management", "New Nag Teammates");
        modules.Add("Web Design", "Bed Sewing");
        modules.Add("Westeros", "Two Seers");
        modules.Add("Who's on First", "Frown's Hoist");
        modules.Add("Who's That Monsplode", "Topmost How's Handle");
        modules.Add("Wingdings", "Ding Swing");
        modules.Add("Wire Placement", "Replace Me Twin");
        modules.Add("Wire Sequence", "We Quire Scene");
        modules.Add("Wire Spaghetti", "Pirates Weight");
        modules.Add("Wires", "Wiser");
        modules.Add("Word Scramble", "Marble Crowds");
        modules.Add("Word Search", "Crew Hoards");
        modules.Add("X-Ray", "Y-Arx");
        modules.Add("X01", "10X");
        modules.Add("Yahtzee", "Hey Zeta");
        modules.Add("Zoni", "I No Z");
        modules.Add("Zoo", "Ooz");
        modules.Add("Subscribe to Pewdiepie", "I Purities Deep Cobwebs");
        modules.Add("Grocery Store", "Retry Scrooge");
        modules.Add("Draw", "Ward");
        modules.Add("Burger Alarm", "Larger Umbra");
        modules.Add("Purgatory", "Yogurt Rap");
        modules.Add("Mega Man 2", "2 Name Mag");
        modules.Add("Lombax Cubes", "Able Box Scum");
        modules.Add("The Stare", "Theaters");
        modules.Add("Graphic Memory", "Impeach Mr Gyro");
        modules.Add("Quiz Buzz", "IQ Buuzzz");
        modules.Add("Wavetapping", "VIP Agent Paw");
        modules.Add("The Hypercube", "Yep Butch Here");
        modules.Add("Speak English", "Shaking Peels");
        modules.Add("Stack'em", "'Tacks Me");
        modules.Add("Seven Wires", "Reeves Wins");
        modules.Add("Colored Keys", "Yodeler Sock");
        modules.Add("The Troll", "Hell Tort");
        modules.Add("Planets", "Nest Lap");
        modules.Add("The Necronomicon", "Homer Connection");
        modules.Add("Four-Card Monte", "Unread-Comfort");
        modules.Add("Aa", "aA");
        modules.Add("The Witness", "These Twins");
        modules.Add("The Giant's Drink", "Tinker's Night Ad");
        modules.Add("Digit String", "Grid Sitting");
        modules.Add("Alpha", "Ha Pal");
        modules.Add("Snap!", "Naps!");
        modules.Add("Hidden Colors", "Scolded Rhino");
        modules.Add("Colour Code", "Louder Coco");
        modules.Add("Vexillology", "Lily Glove Ox");
        modules.Add("Brush Strokes", "Be Rush Storks");
        modules.Add("Odd One Out", "No Dude Too");
        modules.Add("The Triangle Button", "North Baguette Lint");
        modules.Add("Mazematics", "Sam Zit Acme");
        modules.Add("Equations X", "Quiet Axons");
        modules.Add("Maze^3", "Za Me^3");
        modules.Add("Yellow Cipher", "Hip Celery Owl");
        modules.Add("Orange Cipher", "Charger On Pie");
        modules.Add("Red Cipher", "Priced Her");
        modules.Add("Faulty RGB Maze", "Zebra At Fly Mug");
        modules.Add("Forget Me Later", "Telegram Forte");
        modules.Add("Garfield Kart", "Rag Dirt Flake");
        modules.Add("Footnotes", "To Soft One");
        modules.Add("Bamboozling Button", "Blab Butt Gizmo Noon");
        modules.Add("Fruits", "Surf It");
        modules.Add("The Modkit", "Kited Moth");
        modules.Add("Tetravex", "Ax Tree Tv");
        modules.Add("Flower Patch", "Chapter Wolf");
        modules.Add("Matchematics", "Schematic Mat");
        modules.Add("Organization", "A Train Oozing");
        modules.Add("Caesar Cycle", "Scarcely Ace");
        modules.Add("Playfair Cycle", "Clay Elf Piracy");
        modules.Add("Cryptic Cycle", "Cyclic Cry Pet");
        modules.Add("Ultimate Cycle", "Mutate Icy Cell");
        modules.Add("Colour Talk", "All Cork Out");
        modules.Add("Bamboozling Button Grid", "A Bubbling Ding Zoom Trot");
        modules.Add("Old Fogey", "Goofy Led");
        modules.Add("The Ultracube", "Blue Hut Crate");
        modules.Add("Snakes and Ladders", "Kens Sadder Sandal");
        modules.Add("Module Movements", "Melt Nosedove Mum");
        modules.Add("Safety Square", "Faster Queasy");
        modules.Add("Roman Numerals", "Marmoreal Nuns");
        modules.Add("Red Buttons", "Bend Trouts");
        modules.Add("The Rule", "Lee Hurt");
        modules.Add("Lousy Chess", "Holy Cusses");
        modules.Add("Keypad Lock", "Packed Yolk");
        modules.Add("Eight Pages", "Ape Egg Shit");
        modules.Add("The Colored Maze", "Reached Melt Zoo");
        modules.Add("White Cipher", "Heretic Whip");
        modules.Add("Gray Cipher", "Preachy Rig");
        modules.Add("Black Cipher", "Bar Check Lip");
        modules.Add("The Hyperlink", "Hyphen Kilter");
        modules.Add("Corners", "Scorner");
        modules.Add("The High Score", "Secret High Ho");
        modules.Add("Ingredients", "Needing Stir");
        modules.Add("Intervals", "Van Tilers");
        modules.Add("Cheep Checkout", "Heck Cope Cut He");
        modules.Add("Spelling Bee", "Legible Pens");
        modules.Add("Thinking Wires", "Shriek Twining");
        modules.Add("Seven Choose Four", "Confuse Overshoe");
        modules.Add("Object Shows", "Cob Jew Hosts");
        modules.Add("Lunchtime", "He Cum Lint");
        modules.Add("Natures", "Saunter");
        modules.Add("Neutrinos", "Nine Tours");
        modules.Add("Scavenger Hunt", "Arch Even Stung");
        modules.Add("Polygons", "Slog Pony");
        modules.Add("Codenames", "Encased Om");
        modules.Add("Odd Mod Out", "Dodo To Mud");
        modules.Add("Blinkstop", "Pink Blots");
        modules.Add("Forget It Not", "Gift No Otter");
        modules.Add("Rainbow Arrows", "Raw Barrio Snow");
        modules.Add("Passcodes", "Ed Ass Cops");
        modules.Add("Digital Dials", "A Sail Did Gilt");
        modules.Add("Lines of Code", "Encodes Foil");
        modules.Add("Encrypted Dice", "Cynic Ed Red Pet");
        modules.Add("Colorful Dials", "A Colloid Furls");
        modules.Add("Atbash Cipher", "Beach Harpist");
        modules.Add("Addition", "India Dot");
        modules.Add("Matrices", "Scream It");
        modules.Add("Cruel Keypads", "Capered Sulky");
        modules.Add("The Black Page", "Gal Kept Beach");
        modules.Add("Simon Forgets", "Feigns Motors");
        modules.Add("Greek Letter Grid", "Regretted Elk Rig");
        modules.Add("Going Backwards", "Ragbag Disc Wonk");
        modules.Add("Scalar Dials", "A Cars All Dis");
        modules.Add("Keywords", "Rod We Sky");
        modules.Add("The Crafting Table", "Fractal Beet Thing");
    }
 void Start()
 {
     disarmButton.OnInteract += delegate {
         audioSelf.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
         isPressedDisarm = true;
         return(false);
     };
     disarmButton.OnInteractEnded += delegate
     {
         disarmButton.AddInteractionPunch(1f);
         audioSelf.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
         isPressedDisarm = false;
         if (isSolved)
         {
             if (!hasDisarmed)
             {
                 Debug.LogFormat("[Singularity Button #{0}]: Module disarmed.", curmodID);
                 string[] possibleDisarmMessages = { "MODULE\nDISARMED", "CHECK\nYOUR\nMODULES" };
                 textDisarm.text = possibleDisarmMessages.PickRandom();
                 disarmBacking.material.color = Color.green * 0.5f;
             }
             modSelf.HandlePass();
             hasDisarmed = true;
         }
     };
     buttonFront.OnInteract += delegate
     {
         audioSelf.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
         if (!isSolved && hasActivated && !singularityButtonInfo.canDisarm)
         {
             singularityButtonInfo.HandleInteraction(this, (int)bombInfo.GetTime());
         }
         isPressedMain = true;
         onHoldState   = hasActivated;
         return(false);
     };
     buttonFront.OnInteractEnded += delegate
     {
         audioSelf.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonRelease, transform);
         buttonFront.AddInteractionPunch();
         if (!isSolved && hasActivated && onHoldState && !singularityButtonInfo.canDisarm)
         {
             singularityButtonInfo.HandleInteraction(this, (int)bombInfo.GetTime());
             singularityButtonInfo.HandleButtonRelease();
         }
         isPressedMain = false;
     };
     modSelf.OnActivate += delegate
     {
         textDisarm.text = "";
         // Setup Global Interaction
         KMBomb bombAlone = entireModule.GetComponentInParent <KMBomb>();            // Get the bomb that the module is attached on. Required for intergration due to modified value.
         //Required for Multiple Bombs stable interaction in case of different bomb seeds.
         if (!groupedSingularityButtons.ContainsKey(bombAlone))
         {
             groupedSingularityButtons[bombAlone] = new SingularityButtonInfo();
         }
         singularityButtonInfo = groupedSingularityButtons[bombAlone];
         singularityButtonInfo.singularButtons.Add(this);
         // Start Main Handling
         //AddOthersModulesOntoList();
         StartCoroutine(HandleGlobalModule());
     };
     bombInfo.OnBombExploded += delegate
     {
         singularityButtonInfo.StopAll();
         StopAllCoroutines();
     };
     lightStrike.range *= modSelf.transform.lossyScale.x;
     textDisarm.text    = "";
     hasActivated       = true;
 }
    void Start()
    {
        ModSelf.OnActivate += delegate
        {
            try
            {
                List <string> solvablemodNames = Info.GetSolvableModuleNames().Where(a => !ignoredModuleNames.Contains(a)).ToList();
                List <string> allModNames      = Info.GetModuleNames().ToList();
                if (solvablemodNames.Count > 1)
                {
                    if (!allModNames.Contains("Organization") || organIgnoredModNames.Contains("Forget Infinity"))
                    {
                        stagestoGenerate = solvablemodNames.Count > 3 ? UnityEngine.Random.Range(3, Math.Min(solvablemodNames.Count, 100)) : solvablemodNames.Count - 1;

                        if (solvablemodNames.Count <= 100)
                        {
                            Debug.LogFormat("[Forget Infinity #{0}]: Total stages generatable: {1}", curModID, solvablemodNames.Count - 1);
                        }
                        else
                        {
                            Debug.LogFormat("[Forget Infinity #{0}]: Too many non-ignored modules, capping at 99 total stages generatable.", curModID);
                        }

                        Debug.LogFormat("[Forget Infinity #{0}]: Total stages generated: {1}", curModID, stagestoGenerate);
                        Debug.LogFormat("[Forget Infinity #{0}]: All stages: ", curModID, stagestoGenerate);

                        for (int x = 0; x < stagestoGenerate; x++)
                        {
                            int[] output = new int[5];
                            do
                            {
                                for (int a = 0; a < output.Length; a++)
                                {
                                    output[a] = UnityEngine.Random.Range(0, 10);
                                }
                            }while (stages.Count > 0 && stages.Contains(output));
                            stages.Add(output);
                        }
                        for (int x = 0; x < stages.Count; x++)
                        {
                            bool  hasSwapped        = false;
                            int[] finalStageNumbers = new int[5];
                            stages[x].CopyTo(finalStageNumbers, 0);

                            int lastDigitInSerial     = Info.GetSerialNumberNumbers().Any() ? Info.GetSerialNumberNumbers().Last() : 0;
                            int firstDigitInSerial    = Info.GetSerialNumberNumbers().Any() ? Info.GetSerialNumberNumbers().First() : 0;
                            int smallestDigitInSerial = Info.GetSerialNumberNumbers().Any() ? Info.GetSerialNumberNumbers().Min() : 0;
                            int largestDigitInSerial  = Info.GetSerialNumberNumbers().Any() ? Info.GetSerialNumberNumbers().Max() : 0;
                            // Begin Solution Calculations
                            // Culumulative Slot Calculations
                            if (Info.IsPortPresent(Port.StereoRCA))
                            {
                                finalStageNumbers = finalStageNumbers.Reverse().ToArray();
                                hasSwapped        = true;
                            }

                            int batterycount = Info.GetBatteryCount();
                            for (int idx = 0; idx < finalStageNumbers.Length; idx++)
                            {
                                finalStageNumbers[idx] += batterycount;
                            }

                            List <char> LettersInSerial = Info.GetSerialNumberLetters().ToList();
                            if (LettersInSerial.Contains('F') || LettersInSerial.Contains('I'))
                            {
                                for (int idx = 0; idx < finalStageNumbers.Length; idx++)
                                {
                                    finalStageNumbers[idx] -= LettersInSerial.Count;
                                }
                            }
                            // Individual Slots
                            // Slot 1
                            if (allModNames.Contains("Tetris"))
                            {
                                finalStageNumbers[0] = stages[x][0] + 7;
                            }
                            else if (finalStageNumbers[0] >= 10 && finalStageNumbers[0] % 2 == 0)
                            {
                                finalStageNumbers[0] /= 2;
                            }
                            else if (finalStageNumbers[0] < 5)
                            {
                                finalStageNumbers[0] += lastDigitInSerial;
                            }
                            else
                            {
                                finalStageNumbers[0] += 1;
                            }
                            // Slot 2
                            if (Info.CountDuplicatePorts() > 0)
                            {
                                finalStageNumbers[1] += Info.CountDuplicatePorts();
                            }
                            else if (Info.GetPortCount() == 0)
                            {
                                finalStageNumbers[1] += stages[x][0] + stages[x][2];
                            }
                            else
                            {
                                finalStageNumbers[1] += Info.GetPortCount();
                            }
                            // Slot 3
                            if (!hasSwapped)
                            {
                                if (finalStageNumbers[2] >= 7)
                                {
                                    int currentValue    = stages[x][2];
                                    int finalValueSlot3 = 0;
                                    while (currentValue > 0)
                                    {
                                        finalValueSlot3 += currentValue % 2;
                                        currentValue    /= 2;
                                    }
                                    finalStageNumbers[2] = finalValueSlot3;
                                }
                                else if (finalStageNumbers[2] < 3)
                                {
                                    finalStageNumbers[2] = Math.Abs(finalStageNumbers[2]);
                                }
                                else
                                {
                                    finalStageNumbers[2] = stages[x][2] + smallestDigitInSerial;
                                }
                            }
                            // Slot 4
                            if (finalStageNumbers[3] < 0)
                            {
                                finalStageNumbers[3] += largestDigitInSerial;
                            }
                            else if (stagestoGenerate > 5)
                            {
                                finalStageNumbers[3] = 18 - finalStageNumbers[3];
                            }
                            // Slot 5
                            int[,] slotTable5th = new int[, ] {
                                { 0, 1, 2, 3, 4 },
                                { 5, 6, 7, 8, 9 },
                                { stages[x][4], 1 + stages[x][4], 9 - stages[x][4], stages[x][4] - 1, stages[x][4] + 5 },
                                { 9, 8, 5, 6, 7 },
                                { 4, 3, 0, 1, 2 }
                            };
                            int rowCellToGrab = finalStageNumbers[4] - (Mathf.FloorToInt(finalStageNumbers[4] / 5.0f) * 5);
                            finalStageNumbers[4] = slotTable5th[rowCellToGrab, firstDigitInSerial / 2];
                            // Within 0-9
                            while (!finalStageNumbers.ToList().TrueForAll(a => a >= 0 && a <= 9))
                            {
                                for (int idx = 0; idx < finalStageNumbers.Length; idx++)
                                {
                                    if (finalStageNumbers[idx] < 0)
                                    {
                                        finalStageNumbers[idx] += 10;
                                    }
                                    else if (finalStageNumbers[idx] > 9)
                                    {
                                        finalStageNumbers[idx] -= 10;
                                    }
                                }
                            }
                            solution.Add(finalStageNumbers);
                            // End Solution Calculations
                            Debug.LogFormat("[Forget Infinity #{0}]: Stage {1}: Display = {2}, Answer = {3}", curModID, (x + 1).ToString("00"), stages[x].Join(""), solution[x].Join(""));
                        }
                        while (possibleStages.Count < Math.Min(stagestoGenerate, 3))// Memoryless Randomizer Starts Here
                        {
                            int randomStage = UnityEngine.Random.Range(0, stagestoGenerate);
                            if (!possibleStages.Contains(randomStage))
                            {
                                possibleStages.Add(randomStage);
                            }
                        }
                        Debug.LogFormat("[Forget Infinity #{0}]: Stages required to solve: {1}", curModID, FormatIntListWithCommas(possibleStages.ToArray()));
                    }
                    else
                    {     // Implement Failsafe to enforce this module to be solvable if Forget Infinity is NOT ignored by Organization AND Organization is present on the bomb.
                        string[] dialog = new string[]
                        { // A reminder of why Forget Infinity was received poorly to the community. Yes. It's a thing still. -VFlyer
                            "Organization: Why do you even exist!? No one wanted you to show up anyway!",
                            "Forget Infinity: But... I am made by a Tetris legend who has made bunch of Tetris videos!",
                            "Organization: It doesn't matter! These people saw you a few times and they didn't like how you operate in the factory.",
                            "Forget Infinity: But... This one person said I would get a second chance, right?",
                            "Organization: Pff. I saw an module better than yours and that module, who goes by Forget It Not, is more praiseworthy than you! Get out.",
                            "Forget Infinity: But...",
                            "Organization: GET OUT! No more \"but's\"! I'm done talking with you!"
                        };
                        foreach (string line in dialog)
                        {
                            Debug.LogFormat("[Forget Infinity #{0}]: {1}", curModID, line);
                        }
                        Debug.LogFormat("[Forget Infinity #{0}]: Organization is present AND not ignoring Forget Infinity! This module can be auto-solved by pressing any button.", curModID);
                        autosolvable = true;
                    }
                }
                else
                {
                    Debug.LogFormat("[Forget Infinity #{0}]: No stages can be generated, the module can be auto-solved by pressing any button.", curModID);
                    autosolvable = true;
                }
            }
            catch (Exception error)
            {
                Debug.LogErrorFormat("[Forget Infinity #{0}]: Looks like you found a bug, the module has been automatically primed to auto-solve because of this.", curModID);
                Debug.LogErrorFormat("[Forget Infinity #{0}]: The error is the following:", curModID);
                Debug.LogException(error);
                Debug.LogFormat("[Forget Infinity #{0}]: For reference, the module's display stages were the following: ", curModID);
                for (int x = 0; x < stages.Count; x++)
                {
                    Debug.LogFormat("[Forget Infinity #{0}]: Stage {1}: Display = {2}", curModID, x + 1, stages[x].Join(""));
                }
                Debug.LogFormat("[Forget Infinity #{0}]: Please send this log to VFlyer so that he can get this fixed.", curModID);
                Debug.LogFormat("[Forget Infinity #{0}]: Press any button to solve the module.", curModID);
                autosolvable = true;
            }
            finally
            {
                hasStarted = true;
            }
        };
        BackSpaceButton.OnInteract += delegate
        {
            AudioHandler.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            BackSpaceButton.AddInteractionPunch();
            StartCoroutine(HandleButtonAnim(BackSpaceButton.gameObject));
            if (!interactable || solved)
            {
                return(false);
            }
            if (inFinale)
            {
                if (input.Length <= 0)
                {
                    isRecapturing      = !isRecapturing;
                    ScreenStages.color = isRecapturing ? Color.green : Color.white;
                }
                else if (!isRecapturing)
                {
                    input = input.Substring(0, input.Length - 1);
                }
                else
                {
                    int stageToGrab = int.Parse(input);
                    Debug.LogFormat("[Forget Infinity #{0}]: Attempting to recapture stage {1} at a cost of a strike", curModID, stageToGrab);
                    if (!hasStruck)
                    {
                        ModSelf.HandleStrike();
                    }
                    else
                    {
                        Debug.LogFormat("[Forget Infinity #{0}]: The module has a free capture; consuming it.", curModID);
                    }
                    hasStruck     = false;
                    interactable  = false;
                    isRecapturing = false;
                    StartCoroutine(RegrabStage(stageToGrab));
                    input = "";
                    ScreenStages.color = Color.white;
                }
            }
            else if (autosolvable)
            {
                solved = true;
                StartCoroutine(AnimateSolveAnim());
            }
            else
            {
                ModSelf.HandleStrike();
                Debug.LogFormat("[Forget Infinity #{0}]: Defuser pressed a button before module is ready.", curModID);
            }
            return(false);
        };
        for (int x = 0; x < ButtonDigits.Length; x++)
        {
            int y = x;
            ButtonDigits[x].OnInteract += delegate
            {
                AudioHandler.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
                ButtonDigits[y].AddInteractionPunch();
                StartCoroutine(HandleButtonAnim(ButtonDigits[y].gameObject));
                if (!interactable || solved)
                {
                    return(false);
                }
                if (inFinale)
                {
                    if (input.Length < 5)
                    {
                        input += y.ToString();
                    }
                    if (input.Length >= 5 && !isRecapturing)
                    {
                        interactable = false;
                        StartCoroutine(ProcessSubmittion());
                    }
                }
                else if (autosolvable)
                {
                    solved = true;
                    StartCoroutine(AnimateSolveAnim());
                }
                else
                {
                    ModSelf.HandleStrike();
                    Debug.LogFormat("[Forget Infinity #{0}]: Defuser pressed a button before module is ready.", curModID);
                }
                return(false);
            };
        }
    }
示例#5
0
    void Start()
    {
        disarmButton.OnInteract += delegate {
            audioSelf.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            isPressedDisarm = true;
            return(false);
        };
        disarmButton.OnInteractEnded += delegate
        {
            disarmButton.AddInteractionPunch(1f);
            audioSelf.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
            isPressedDisarm = false;
            if (isSolved)
            {
                modSelf.HandlePass();
                hasDisarmed = true;
            }
        };
        buttonFront.OnInteract += delegate
        {
            audioSelf.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            if (!isSolved && hasActivated)
            {
                singularityButtonInfo.HandleInteraction(this, (int)bombInfo.GetTime());
            }
            isPressedMain = true;
            onHoldState   = hasActivated;
            return(false);
        };
        buttonFront.OnInteractEnded += delegate
        {
            audioSelf.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonRelease, transform);
            buttonFront.AddInteractionPunch();
            if (!isSolved && hasActivated && onHoldState)
            {
                singularityButtonInfo.HandleInteraction(this, (int)bombInfo.GetTime());
            }
            isPressedMain = false;
        };
        modSelf.OnActivate += delegate
        {
            // Setup Global Interaction
            KMBomb bombAlone = entireModule.GetComponentInParent <KMBomb>();            // Get the bomb that the module is attached on. Required for intergration due to modified value.
            //Required for Multiple Bombs stable interaction in case of different bomb seeds.

            if (!groupedSingularityButtons.ContainsKey(bombAlone))
            {
                groupedSingularityButtons[bombAlone] = new SingularityButtonInfo();
            }
            singularityButtonInfo = groupedSingularityButtons[bombAlone];
            singularityButtonInfo.singularButtons.Add(this);
            colorblindDetected = colorblindMode.ColorblindModeActive;
            // Start Main Handling
            //AddOthersModulesOntoList();
            StartCoroutine(HandleGlobalModule());
            hasActivated = true;
        };
        bombInfo.OnBombExploded += delegate
        {
            singularityButtonInfo.StopAll();
        };
    }
示例#6
0
    // Submit button pressed
    private void SubmitButtonPressed()
    {
        SubmitButton.AddInteractionPunch();
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, SubmitButton.transform);
        bool correct = false;

        if (moduleSolved == false)
        {
            Debug.LogFormat("[Training Text #{0}] You submitted {1}", moduleId, FormatTime(currentTime));

            // If the correct time is within an hour of the real time
            if (DateTime.Now.DayOfWeek.ToString() != "Friday")
            {
                // Gets the real time
                realTime = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
                Debug.LogFormat("[Training Text #{0}] The current local time when pressing the button was {1}", moduleId, FormatTime(realTime));

                // Compares the time
                if ((correctTime >= realTime - 60 && correctTime <= realTime + 60) ||
                    (correctTime + 1440 >= realTime - 60 && correctTime + 1440 <= realTime + 60) ||
                    (correctTime - 1440 >= realTime - 60 && correctTime - 1440 <= realTime + 60))
                {
                    correctTime = realTime;
                }
            }

            else
            {
                Debug.LogFormat("[Training Text #{0}] The answer was submitted on a Friday.", moduleId);
            }


            // Correct answer
            if (currentTime == correctTime)
            {
                Debug.LogFormat("[Training Text #{0}] Module solved!", moduleId);
                GetComponent <KMBombModule>().HandlePass();
                Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, gameObject.transform);
                moduleSolved = true;
                correct      = true;
            }

            // Incorrect answer
            else
            {
                Debug.LogFormat("[Training Text #{0}] Strike!", moduleId);
                GetComponent <KMBombModule>().HandleStrike();
            }
        }

        // Displays the module name on the top screen
        if (displayingModuleName == false)
        {
            displayingModuleName = true;

            if (correct == true)
            {
                AnswerText.text = module.getModuleName();
            }

            else
            {
                StartCoroutine(ModuleNameFlash());
            }
        }
    }
    void KeyPress(KMSelectable Key)
    {
        Key.AddInteractionPunch(.25f);
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Key.transform);
        if (moduleSolved)
        {
            return;
        }
        for (int i = 0; i < Keyboard.Count(); i++)
        {
            if (Key == Keyboard[i])
            {
                if (i <= 12 && !shift)
                {
                    Input += TopRow[i];
                    EmotiguyInsertion.text = Input;
                }
                else if (i == 40 && Input == "Thanos" && !started)
                {
                    Animation = true;
                    Input     = "";
                    EmotiguyInsertion.text = Input;
                }
                else if (i == 13 && Input.Length == 0)
                {
                    return;
                }
                else if (i == 13)
                {
                    Input = Input.Substring(0, Input.Length - 1);
                    EmotiguyInsertion.text = Input;
                }
                else if (i == 14 || i == 53 || i == 54 || i == 55 || i == 57 || i == 58 || i == 59 || i == 60)
                {
                    return;
                }
                else if (i >= 15 && i <= 27 && !shift)
                {
                    Input += SecondTopRow[i - 15];
                    EmotiguyInsertion.text = Input;
                }
                else if (i == 28 || i == 41 || i == 52)
                {
                    shift = !shift;
                    for (int j = 0; j < 47; j++)
                    {
                        if (shift)
                        {
                            LettersButShift[j].text = KeyboardButShift[j].ToString();
                        }
                        else
                        {
                            LettersButShift[j].text = KeyboardButNotShift[j].ToString();
                        }
                    }
                }
                else if (i >= 29 && i <= 39 && !shift)
                {
                    Input += HomeRow[i - 29];
                    EmotiguyInsertion.text = Input;
                }
                else if (i >= 42 && i <= 51 && !shift)
                {
                    Input += BottomRow[i - 42];
                    EmotiguyInsertion.text = Input;
                }
                else if (i <= 12)
                {
                    Input += TopRowButShift[i];
                    EmotiguyInsertion.text = Input;
                    shift = false;
                    for (int j = 0; j < 47; j++)
                    {
                        LettersButShift[j].text = KeyboardButNotShift[j].ToString();
                    }
                }
                else if (i >= 15 && i <= 27)
                {
                    Input += SecondTopRowButShift[i - 15];
                    EmotiguyInsertion.text = Input;
                    shift = false;
                    for (int j = 0; j < 47; j++)
                    {
                        LettersButShift[j].text = KeyboardButNotShift[j].ToString();
                    }
                }
                else if (i >= 29 && i <= 39)
                {
                    Input += HomeRowButShift[i - 29];
                    EmotiguyInsertion.text = Input;
                    shift = false;
                    for (int j = 0; j < 47; j++)
                    {
                        LettersButShift[j].text = KeyboardButNotShift[j].ToString();
                    }
                }
                else if (i >= 42 && i <= 51)
                {
                    Input += BottomRowButShift[i - 42];
                    EmotiguyInsertion.text = Input;
                    shift = false;
                    for (int j = 0; j < 47; j++)
                    {
                        LettersButShift[j].text = KeyboardButNotShift[j].ToString();
                    }
                }
                else if (i == 56)
                {
                    Input += " ";
                    EmotiguyInsertion.text = Input;
                    shift = false;
                    for (int j = 0; j < 47; j++)
                    {
                        LettersButShift[j].text = KeyboardButNotShift[j].ToString();
                    }
                }
                else if (i == 40 && !started)
                {
                    EmotiguySelector = UnityEngine.Random.Range(0, Emotiguy.Count());
                    Display.GetComponent <MeshRenderer>().material = Emotiguy[EmotiguySelector];
                    Debug.LogFormat("[Emotiguy Identification #{0}] The shown Emotiguy is {1}.", moduleId, Names[EmotiguySelector]);
                    started = true;
                    shift   = false;
                    for (int j = 0; j < 47; j++)
                    {
                        LettersButShift[j].text = KeyboardButNotShift[j].ToString();
                    }
                }
                else if (i == 40 && started && Input == Names[EmotiguySelector])
                {
                    started = false;
                    Input   = "";
                    EmotiguyInsertion.text = Input;
                    shift = false;
                    for (int j = 0; j < 47; j++)
                    {
                        LettersButShift[j].text = KeyboardButNotShift[j].ToString();
                    }
                    Display.GetComponent <MeshRenderer>().material = Gay;
                    Stage++;
                    switch (Stage)
                    {
                    case 1:
                        LEDs[0].GetComponent <MeshRenderer>().material = Lights[1];
                        Debug.LogFormat("[Emotiguy Identification #{0}] You submitted {1}. That is correct.", moduleId, Names[EmotiguySelector]);
                        break;

                    case 2:
                        LEDs[1].GetComponent <MeshRenderer>().material = Lights[1];
                        Debug.LogFormat("[Emotiguy Identification #{0}] You submitted {1}. That is correct.", moduleId, Names[EmotiguySelector]);
                        break;

                    case 3:
                        LEDs[2].GetComponent <MeshRenderer>().material = Lights[1];
                        Debug.LogFormat("[Emotiguy Identification #{0}] You submitted {1}. That is correct. Module disarmed.", moduleId, Names[EmotiguySelector]);
                        moduleSolved = true;
                        Display.GetComponent <MeshRenderer>().material = Emotiguy[4];
                        GetComponent <KMBombModule>().HandlePass();
                        if (Animation)
                        {
                            StartCoroutine(SolveAnimation());
                        }
                        break;
                    }
                }
                else
                {
                    GetComponent <KMBombModule>().HandleStrike();
                    Debug.LogFormat("[Emotiguy Identification #{0}] You submitted {1}. That is incorrect, uuwaaaaaaaaaaaaaaaaaah.", moduleId, Input);
                    Input = "";
                    EmotiguyInsertion.text = Input;
                    Audio.PlaySoundAtTransform("Wahhh", transform);
                    started = false;
                    for (int j = 0; j < 47; j++)
                    {
                        LettersButShift[j].text = KeyboardButNotShift[j].ToString();
                    }
                    Display.GetComponent <MeshRenderer>().material = Gay;
                }
            }
        }
    }
示例#8
0
    void Check()
    {
        if (!_lightsOn || _isSolved)
        {
            return;
        }

        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, submit.transform);
        submit.AddInteractionPunch();

        if (correctLine == currentLine)
        {
            Debug.LogFormat("[The Witness #{0}] Expected line: {1} or {2}, input line: {3}.", _moduleId, correctLine, alternativeLine, currentLine);
            Debug.LogFormat("[The Witness #{0}] Module defused. Well done :)", _moduleId);

            Audio.PlaySoundAtTransform("disarmed", Module.transform);
            wireGray.SetActive(false);
            wireGreen.SetActive(true);
            Module.HandlePass();
            _isSolved = true;
        }
        else if (alternativeLine == currentLine)
        {
            Debug.LogFormat("[The Witness #{0}] Expected line: {1} or {2}, input line: {3}.", _moduleId, correctLine, alternativeLine, currentLine);
            Debug.LogFormat("[The Witness #{0}] Module defused. Well done :)", _moduleId);

            Audio.PlaySoundAtTransform("disarmed", Module.transform);
            wireGray.SetActive(false);
            wireGreen.SetActive(true);
            Module.HandlePass();
            _isSolved = true;
        }
        else
        {
            Debug.LogFormat("[The Witness #{0}] Expected line: {1} or {2}, input line: {3}. Strike!", _moduleId, correctLine, alternativeLine, currentLine);

            Module.HandleStrike();

            StartCoroutine(RedWireHandle());

            tl.SetActive(false);
            tr.SetActive(false);
            tsl.SetActive(false);
            tsm.SetActive(false);
            tsr.SetActive(false);
            ml.SetActive(false);
            mr.SetActive(false);
            bsl.SetActive(false);
            bsm.SetActive(false);
            bsr.SetActive(false);
            bl.SetActive(false);
            br.SetActive(false);

            tmOn = false;
            trOn = false;
            mlOn = false;
            mmOn = false;
            mrOn = false;
            blOn = false;
            bmOn = false;
            brOn = false;

            currentLine = "";
            lastPress   = 0;
            isFirst     = true;
        }
    }
    public void run()
    {
        numButtonPresses = 0;
        moduleSolved     = false;
        Debug.LogFormat("[Colored Hexabuttons #{0}] Color Generated: Orange", moduleId);
        string[] wordList =
        {
            "ABACUS", "ACTION", "ADVICE", "AFFECT", "AGENCY", "ALMOND", "AMOUNT", "ANARCH", "APPEAR", "ARRIVE",
            "BALLAD", "BAKERY", "BEACON", "BINARY", "BLEACH", "BRONZE", "BOXING", "BREEZE", "BELIEF", "BITTER",
            "CACTUS", "CEREAL", "CHERRY", "CITRUS", "CLOSET", "COFFEE", "CRISIS", "CURSOR", "CONVEX", "CELLAR",
            "DANGER", "DEBRIS", "DINNER", "DOODLE", "DRIVER", "DUSTER", "DEFEAT", "DIRECT", "DOMINO", "DRAWER",
            "EASTER", "EDITOR", "EFFECT", "EGGNOG", "EMBLEM", "ENROLL", "EQUALS", "ERASER", "ESCAPE", "EXPERT",
            "FABRIC", "FELINE", "FILTER", "FLAVOR", "FOREST", "FREEZE", "FUTURE", "FACADE", "FOLLOW", "FINISH",
            "GALLON", "GEYSER", "GALAXY", "GLANCE", "GROWTH", "GUTTER", "GAMBLE", "GERBIL", "GINGER", "GIVING",
            "HAMMER", "HEIGHT", "HIDING", "HOLLOW", "HUNTER", "HYBRID", "HANDLE", "HELMET", "HAZARD", "HURDLE",
            "ICICLE", "IMPORT", "INSERT", "ITALIC", "IMPAIR", "INCOME", "IMPACT", "INSULT", "INSECT", "INTENT",
            "JESTER", "JINGLE", "JOGGER", "JUNGLE", "JERSEY", "JOCKEY", "JUGGLE", "JUMBLE", "JUNIOR", "JAILER",
            "KETTLE", "KIDNEY", "KNIGHT", "KENNEL", "KINGLY", "KITTEN", "KRAKEN", "KINDLY", "KERNEL", "KEEPER",
            "LAGOON", "LEADER", "LIMBER", "LOCKET", "LUXURY", "LYCHEE", "LADDER", "LEGACY", "LIQUID", "LOTION",
            "MAGNET", "MEADOW", "MIDDLE", "MOMENT", "MUSEUM", "MYSTIC", "MATRIX", "MELODY", "MIRROR", "MUFFIN",
            "NAPKIN", "NEEDLE", "NICKEL", "NOBODY", "NUTMEG", "NATION", "NECTAR", "NINETY", "NOTICE", "NARROW",
            "OBJECT", "OCELOT", "OFFICE", "OPTION", "ORANGE", "OUTPUT", "OXYGEN", "OYSTER", "OFFSET", "OUTFIT",
            "PALACE", "PEBBLE", "PICNIC", "PLAQUE", "POCKET", "PROFIT", "PUDDLE", "PENCIL", "PIGEON", "POETRY",
            "QUARTZ", "QUIVER", "QUARRY", "QUEASY", "RABBIT", "REFLEX", "RHYTHM", "RIBBON", "ROCKET", "RAFFLE",
            "RECIPE", "RUBBER", "RADIUS", "RECORD", "SAILOR", "SCHEME", "SEARCH", "SHADOW", "SIGNAL", "SLEIGH",
            "SMUDGE", "SNEEZE", "SOCIAL", "SQUEAK", "TAILOR", "TEACUP", "THIRST", "TICKET", "TOGGLE", "TRAVEL",
            "TUNNEL", "TWITCH", "TEMPLE", "THEORY", "UNISON", "UPWARD", "UTMOST", "UTOPIA", "UNIQUE", "UNREST",
            "UNSEEN", "UNWRAP", "UNVIEL", "UPHOLD", "VACUUM", "VECTOR", "VIEWER", "VORTEX", "VALLEY", "VERBAL",
            "VICTIM", "VOLUME", "VANISH", "VERMIN", "WAFFLE", "WEALTH", "WHEEZE", "WIDGET", "WOLVES", "WRENCH",
            "WALNUT", "WEIGHT", "WISDOM", "WONDER", "YEARLY", "YELLOW", "YONDER", "ZEALOT", "ZEBRAS", "ZODIAC"
        };
        string temp = wordList[UnityEngine.Random.Range(0, wordList.Length)].ToUpper();

        solution = temp.ToUpper();
        Debug.LogFormat("[Colored Hexabuttons #{0}] Generated Word: {1}", moduleId, solution);
        scramble = "";
        for (int aa = 0; aa < 6; aa++)
        {
            int pos = UnityEngine.Random.Range(0, temp.Length);
            scramble = scramble + "" + temp[pos];
            temp     = temp.Remove(pos, 1);
        }
        Debug.LogFormat("[Colored Hexabuttons #{0}] Scrambled Word: {1}", moduleId, scramble);
        foreach (int i in buttonIndex)
        {
            hexButtons[i].OnInteract = delegate { pressedOrange(i); return(false); }
        }
        ;
        hexButtons[6].OnInteract = delegate { pressedOrangeCenter(); return(false); };
        string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        switch (UnityEngine.Random.Range(0, 7))
        {
        case 0:                //Atbash

            voiceMessage    = new string[1];
            voiceMessage[0] = "ATBASH";
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                buttonText[aa].text  = alpha[25 - alpha.IndexOf(scramble[aa])] + "";
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using ATBASH: {1}{2}{3}{4}{5}{6}", moduleId, buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        case 1:                //Caesar
            voiceMessage    = new string[3];
            voiceMessage[0] = "CAESAR";
            int r1 = UnityEngine.Random.Range(1, 26);
            if (r1 < 10)
            {
                voiceMessage[1] = "0";
                voiceMessage[2] = r1 + "";
            }
            else
            {
                voiceMessage[1] = (r1 / 10) + "";
                voiceMessage[2] = (r1 % 10) + "";
            }
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                buttonText[aa].text  = alpha[mod(alpha.IndexOf(scramble[aa]) - r1, 26)] + "";
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using CAESAR {1}{2}: {3}{4}{5}{6}{7}{8}", moduleId, voiceMessage[1], voiceMessage[2], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        case 2:                //Condi
            voiceMessage    = new string[3];
            voiceMessage[0] = "CONDI";
            int r2 = UnityEngine.Random.Range(1, 26);
            if (r2 < 10)
            {
                voiceMessage[1] = "0";
                voiceMessage[2] = r2 + "";
            }
            else
            {
                voiceMessage[1] = (r2 / 10) + "";
                voiceMessage[2] = (r2 % 10) + "";
            }
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                buttonText[aa].text  = alpha[mod(alpha.IndexOf(scramble[aa]) + r2, 26)] + "";
                r2 = alpha.IndexOf(scramble[aa]) + 1;
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using CONDI {1}{2}: {3}{4}{5}{6}{7}{8}", moduleId, voiceMessage[1], voiceMessage[2], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        case 3:                //Monoalphabetic
            voiceMessage    = new string[7];
            voiceMessage[0] = "MONOALPHABETIC";
            temp            = alpha.ToUpper();
            for (int aa = 1; aa < 7; aa++)
            {
                voiceMessage[aa] = temp[UnityEngine.Random.Range(0, temp.Length)] + "";
                temp             = temp.Replace(voiceMessage[aa], "");
            }
            for (int aa = 6; aa >= 1; aa--)
            {
                temp = voiceMessage[aa] + "" + temp;
            }
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                buttonText[aa].text  = temp[alpha.IndexOf(scramble[aa])] + "";
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using MONOALPHABETIC {1}{2}{3}{4}{5}{6}: {7}{8}{9}{10}{11}{12}", moduleId, voiceMessage[1], voiceMessage[2], voiceMessage[3], voiceMessage[4], voiceMessage[5], voiceMessage[6], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        case 4:                //Porta
            voiceMessage    = new string[7];
            voiceMessage[0] = "PORTA";
            temp            = alpha.ToUpper();
            for (int aa = 1; aa < 7; aa++)
            {
                voiceMessage[aa] = temp[UnityEngine.Random.Range(0, temp.Length)] + "";
                temp             = temp.Replace(voiceMessage[aa], "");
            }
            string[] portaChart =
            {
                "NOPQRSTUVWXYZ",
                "OPQRSTUVWXYZN",
                "PQRSTUVWXYZNO",
                "QRSTUVWXYZNOP",
                "RSTUVWXYZNOPQ",
                "STUVWXYZNOPQR",
                "TUVWXYZNOPQRS",
                "UVWXYZNOPQRST",
                "VWXYZNOPQRSTU",
                "WXYZNOPQRSTUV",
                "XYZNOPQRSTUVW",
                "YZNOPQRSTUVWX",
                "ZNOPQRSTUVWXY"
            };
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                if (alpha.IndexOf(scramble[aa]) < 13)
                {
                    buttonText[aa].text = portaChart[alpha.IndexOf(voiceMessage[aa + 1]) / 2][alpha.IndexOf(scramble[aa])] + "";
                }
                else
                {
                    buttonText[aa].text = alpha[portaChart[alpha.IndexOf(voiceMessage[aa + 1]) / 2].IndexOf(scramble[aa])] + "";
                }
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using PORTA {1}{2}{3}{4}{5}{6}: {7}{8}{9}{10}{11}{12}", moduleId, voiceMessage[1], voiceMessage[2], voiceMessage[3], voiceMessage[4], voiceMessage[5], voiceMessage[6], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        case 5:                //Ragbaby
            voiceMessage    = new string[3];
            voiceMessage[0] = "RAGBABY";
            int r3 = UnityEngine.Random.Range(0, 26);
            if (r3 < 10)
            {
                voiceMessage[1] = "0";
                voiceMessage[2] = r3 + "";
            }
            else
            {
                voiceMessage[1] = (r3 / 10) + "";
                voiceMessage[2] = (r3 % 10) + "";
            }
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                buttonText[aa].text  = alpha[mod(alpha.IndexOf(scramble[aa]) + r3, 26)] + "";
                r3++;
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using RAGBABY {1}{2}: {3}{4}{5}{6}{7}{8}", moduleId, voiceMessage[1], voiceMessage[2], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        default:                //Vigenere
            voiceMessage    = new string[7];
            voiceMessage[0] = "VIGENERE";
            temp            = alpha.ToUpper();
            string alpha2 = "-ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            for (int aa = 1; aa < 7; aa++)
            {
                voiceMessage[aa] = temp[UnityEngine.Random.Range(0, temp.Length)] + "";
                temp             = temp.Replace(voiceMessage[aa], "");
                int r4 = alpha2.IndexOf(scramble[aa - 1]) + alpha2.IndexOf(voiceMessage[aa]);
                while (r4 > 26)
                {
                    r4 -= 26;
                }
                buttonText[aa - 1].color = Color.black;
                buttonText[aa - 1].text  = alpha2[r4] + "";
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using VIGENERE {1}{2}{3}{4}{5}{6}: {7}{8}{9}{10}{11}{12}", moduleId, voiceMessage[1], voiceMessage[2], voiceMessage[3], voiceMessage[4], voiceMessage[5], voiceMessage[6], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;
        }
    }

    void pressedOrange(int n)
    {
        if (!(moduleSolved))
        {
            Debug.LogFormat("[Colored Hexabuttons #{0}] User pressed {1}. Which is the decrypted letter {2}.", moduleId, positions[n], scramble[n]);
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            if (solution[numButtonPresses] == scramble[n])
            {
                Vector3 pos = buttonMesh[n].transform.localPosition;
                pos.y = 0.0126f;
                buttonMesh[n].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                hexButtons[n].OnInteract = null;
                ledMesh[n].material      = ledColors[1];
                if (numButtonPresses == 5)
                {
                    moduleSolved = true;
                    coloredHexabuttons.Solve();
                }
                else
                {
                    numButtonPresses++;
                }
            }
            else
            {
                numButtonPresses = 0;
                Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! I was expecting {1}!", moduleId, solution[numButtonPresses]);
                coloredHexabuttons.Strike();
                for (int aa = 0; aa < 6; aa++)
                {
                    Vector3 pos = buttonMesh[aa].transform.localPosition;
                    pos.y = 0.0169f;
                    buttonMesh[aa].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                    ledMesh[aa].material = ledColors[0];
                }
                foreach (int i in buttonIndex)
                {
                    hexButtons[i].OnInteract = delegate { pressedOrange(i); return(false); }
                }
                ;
            }
        }
    }

    void pressedOrangeCenter()
    {
        if (!(moduleSolved))
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            Vector3 pos = buttonMesh[6].transform.localPosition;
            pos.y = 0.0126f;
            buttonMesh[6].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
            coloredHexabuttons.StartCoroutine(playAudio());
        }
    }

    IEnumerator playAudio()
    {
        hexButtons[6].OnInteract = null;
        yield return(new WaitForSeconds(0.5f));

        for (int aa = 0; aa < voiceMessage.Length; aa++)
        {
            Audio.PlaySoundAtTransform(voiceMessage[aa], transform);
            yield return(new WaitForSeconds(1.5f));
        }
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
        Vector3 pos = buttonMesh[6].transform.localPosition;

        pos.y = 0.0169f;
        buttonMesh[6].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
        hexButtons[6].OnInteract = delegate { pressedOrangeCenter(); return(false); };
    }

    private int mod(int n, int m)
    {
        while (n < 0)
        {
            n += 26;
        }
        return(n % 26);
    }
}
    void Activate()
    {
        SyncButton.OnInteract += () =>
        {
            if (Lights.Where(l => l.speed != 0).Select(l => l.speed).Distinct().Count() == 1 && !Solved)
            {
                SyncButton.AddInteractionPunch(0.5f);
                Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);

                if (((int)BombInfo.GetTime() % 60).ToString().Contains(DisplayNumber.ToString()))
                {
                    Module.HandlePass();
                    Solved = true;

                    foreach (Light light in Lights)
                    {
                        light.StopFlashing();
                        light.State = true;
                    }

                    Audio.PlaySoundAtTransform("Solve", transform);
                    StartCoroutine(PlayWinAnimation());
                }
                else
                {
                    Module.HandleStrike();
                }
            }
            else
            {
                resetCoroutine = StartCoroutine(HoldToReset());
            }

            return(false);
        };

        SyncButton.OnInteractEnded += () =>
        {
            if (resetCoroutine != null && !syncPause)
            {
                StopCoroutine(resetCoroutine);
                resetCoroutine = null;
            }
        };

        foreach (Light l in Lights)
        {
            l.gObject.GetComponent <KMSelectable>().OnInteract += SetupInteraction(l);
        }

        List <int> speeds = new List <int>()
        {
            1, 2, 3, 4, 5
        };
        List <int> lightIndexes = new List <int>()
        {
            0, 1, 2, 3, 4, 5, 6, 7, 8
        };

        for (int i = 0; i < 5; i++)
        {
            Lights[ExtractRandom(lightIndexes)].speed = ExtractRandom(speeds);
        }

        foreach (int lightIndex in lightIndexes)
        {
            Lights[lightIndex].State = true;
        }

        for (int i = 0; i < 9; i++)
        {
            InitialSpeeds[i] = Lights[i].speed;
        }

        foreach (Light light in Lights)
        {
            light.StartFlashing();
        }

        Log("Light speeds:\n{0} {1} {2}\n{3} {4} {5}\n{6} {7} {8}", Lights.Select(l => (object)l.speed).ToArray());

        // Find which way the user needs to sync

        int        fastestLight = Array.IndexOf(Lights, Lights.Where(l => l.speed != 0).Aggregate((l1, l2) => l1.speed > l2.speed ? l1 : l2));
        int        slowestLight = Array.IndexOf(Lights, Lights.Where(l => l.speed != 0).Aggregate((l1, l2) => l1.speed < l2.speed ? l1 : l2));
        Vector2Int chartPos     = new Vector2Int(
            lightToCol[fastestLight],
            Mathf.FloorToInt((DisplayNumber - 1) / 3)
            );

        var startingCell = chart[(int)chartPos.y][(int)chartPos.x];

        Log("Started at column {0}, row {1} ({2} {3})", chartPos.x + 1, chartPos.y + 1, orders[startingCell[0]], states[startingCell[1]]);

        for (int i = 0; i < Lights[4].speed; i++)
        {
            chartPos  += lightToDir[slowestLight];
            chartPos.x = (chartPos.x % 9 + 9) % 9;
            chartPos.y = (chartPos.y % 3 + 3) % 3;
        }
        Log("Ended at column {0}, row {1}", chartPos.x + 1, chartPos.y + 1);

        SyncMethod = chart[(int)chartPos.y][(int)chartPos.x];
        Log("Lights need to be synced in {0} {1} order", orders[SyncMethod[0]], states[SyncMethod[1]]);
    }
示例#11
0
    /// <summary>
    /// Handles pressing of all buttons and screens (aside from submit)
    /// </summary>
    /// <param name="num">The index for the 5 buttons so the program can differentiate which button was pushed.</param>
    private void HandlePress(int num)
    {
        //plays button sound effect
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, btn[num].transform);
        btn[num].AddInteractionPunch();
        Audio.PlaySoundAtTransform(Sounds.Srt.Tick, Module.transform);

        //if lights are off, the buttons should do
        if (!_lightsOn || isSolved || _buttonDelay || _piano)
        {
            Audio.PlaySoundAtTransform(Sounds.Srt.Button(num + 1), Module.transform);

            if (_piano)
            {
                btn[num].GetComponent <MeshRenderer>().material.color = btn[num].GetComponent <MeshRenderer>().material.color == _highlightColor
                                                                     ? btn[num].GetComponent <MeshRenderer>().material.color = _buttonColor
                                                                     : btn[num].GetComponent <MeshRenderer>().material.color = _highlightColor;
            }
            return;
        }

        //selecting a button
        if (!_selected.Contains((byte)num))
        {
            Audio.PlaySoundAtTransform(Sounds.Srt.Select, Module.transform);
            _selected.Add((byte)num);
            btn[num].GetComponent <MeshRenderer>().material.color = _highlightColor;
            _pushTimes++;
        }

        //unselecting a button
        else
        {
            Audio.PlaySoundAtTransform(Sounds.Srt.Deselect, Module.transform);
            _selected.Remove((byte)num);
            btn[num].GetComponent <MeshRenderer>().material.color = _buttonColor;
        }

        //if you selected 2 buttons
        if (_selected.Count == 2)
        {
            //block inputs from user temporarily
            _buttonDelay = true;

            Audio.PlaySoundAtTransform(Sounds.Srt.Swap, Module.transform);
            CheckSwap();
        }

        //bogosort easter egg activation
        if (_pushTimes == 55)
        {
            Audio.PlaySoundAtTransform(Sounds.Srt.Bogosort, Module.transform);
            _pushTimes = 0;

            //regenerates the numbers to prevent memorization
            for (int i = 0; i < btn.Length; i++)
            {
                GenerateNumber(i);
            }

            Debug.LogFormat("[Sorting #{0}] The buttons are laid out as follows: {1}, {2}, {3}, {4}", _moduleId, _initialButtons[0], _initialButtons[1], _initialButtons[2], _initialButtons[3]);

            //bogosort
            if (!_bogoSort)
            {
                Debug.LogFormat("[Sorting #{0}] BogoSort activated!", _moduleId);
                Debug.LogFormat("[Sorting #{0}] All logs from this module are now disabled to prevent spam during BogoSort.", _moduleId);

                _bogoSort = true;

                //set screen text to bogosort and run bogosort method
                Screen.text = "BOGO";

                for (int i = 0; i < _buttons.Length; i++)
                {
                    byte rng = (byte)Random.Range(10, 100);

                    //get random numbers
                    if (!_buttons.Contains(rng))
                    {
                        _buttons[i] = rng;

                        Debug.LogFormat("[Sorting #{0}] Button {1} has the label \"{2}\".", _moduleId, i + 1, rng);
                    }

                    //duplicate number prevention
                    else
                    {
                        i--;
                    }
                }
            }

            else
            {
                Debug.LogFormat("[Sorting #{0}] BogoSort deactivated!", _moduleId);
                Debug.LogFormat("[Sorting #{0}] All logs from this module are now reenabled.", _moduleId);

                _bogoSort = false;

                ResetNumber();
            }
        }
    }
示例#12
0
    void Activate()
    {
        InitGrid();
        ReinitializeGrid();

        for (int i = 0; i < 4; i++)
        {
            int j = i;
            ArrowButtons[i].OnInteract += delegate
            {
                Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
                ArrowButtons[j].AddInteractionPunch(0.4f);
                if (isSolved || !interactable)
                {
                    return(false);
                }
                OnArrowPress(j);
                return(false);
            };
        }

        for (int i = 0; i < 10; i++)
        {
            int j = i;
            NumberedButtons[i].OnInteract += delegate
            {
                Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
                NumberedButtons[j].AddInteractionPunch(0.4f);
                if (isSolved || !interactable)
                {
                    return(false);
                }
                OnNumberButtonPress(j);
                return(false);
            };
        }

        CheckButton.OnInteract += delegate
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            CheckButton.AddInteractionPunch();
            if (isSolved || !interactable)
            {
                return(false);
            }
            var solved = CrackboxLogic.IsSolved(gridItems);
            Debug.LogFormat("[Crackbox #{0}] Submitted:", _moduleId);
            GridDebugLog(gridItems, x => string.Format("{0}", (x.IsBlack ? "B" : (x.Value == 0 ? "*" : x.Value.ToString()))));
            if (solved)
            {
                isSolved = true;
                Debug.LogFormat("[Crackbox #{0}] That is correct, module solved!", _moduleId);
                StartCoroutine("SolveAnimation", GridBoxSelected);
            }
            else
            {
                Debug.LogFormat("[Crackbox #{0}] That is incorrect, strike!", _moduleId);
                StartCoroutine("SolveAnimation", GridBoxWrong);
            }
            return(false);
        };
    }
    void PressButton(int Collect)
    {
        buttons[Collect].AddInteractionPunch(0.3f);
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
        if (!ModuleSolved)
        {
            if (IsActivated)
            {
                TextMesh buttonTextMesh = buttons[Collect].GetComponentInChildren <TextMesh>();
                Debug.LogFormat("[What's on Second #{0}] You pressed the button with the label \"{1}\".", moduleId, buttonTextMesh.text);
                if (buttonTextMesh.text == TrueAnswer)
                {
                    foreach (MeshRenderer Render in LEDs[Stage].GetComponentsInChildren <MeshRenderer>())
                    {
                        if (Render.name == "On")
                        {
                            Render.enabled = true;
                        }
                        else if (Render.name == "Off")
                        {
                            Render.enabled = false;
                        }
                    }
                    Stage++;
                    if (Stage == 3)
                    {
                        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform);
                        Debug.LogFormat("[What's on Second #{0}] All three stage solved successfully. Module solved.", moduleId, (Stage + 1).ToString());
                        Module.HandlePass();
                        ModuleSolved = true;
                        Stage        = 0;
                    }
                    else
                    {
                        Answers[Stage - 1] = Phrase[DisplayNumber];
                        string[] Colors = { "Red", "Green", "Blue", "Yellow", "Magenta", "Cyan" };
                        AnswerColors[Stage - 1] = Colors[Color];
                        Debug.LogFormat("[What's on Second #{0}] You pressed the correct label. Moving forward to another stage.", moduleId);
                        StartCoroutine(NewStage(false));
                    }
                }

                else
                {
                    Stage = 0;
                    Debug.LogFormat("[What's on Second #{0}] You pressed the incorrect label. The module striked and performed a reset.", moduleId);
                    for (int i = 0; i < LEDs.Length; i++)
                    {
                        foreach (MeshRenderer Render in LEDs[i].GetComponentsInChildren <MeshRenderer>())
                        {
                            if (Render.name == "On")
                            {
                                Render.enabled = false;
                            }
                        }
                    }
                    Module.HandleStrike();
                    StartCoroutine(NewStage(false));
                }
            }
        }
    }
示例#14
0
    IEnumerator TheCountdown()
    {
        Sounds.clip = SFX[3];
        Sounds.Play();
        Downcount = true;
        yield return(new WaitForSeconds(2.4f));

        Text[1].text          = "PUSH";
        Text[2].text          = "IT";
        Text[3].text          = "NOW";
        Text[0].characterSize = 0.35f;
        Text[0].text          = TimeLeft.ToString();
        yield return(new WaitForSeconds(0.1674f));

        while (TimeLeft > 0)
        {
            TimeLeft = TimeLeft - 1m;
            if (TimeLeft < 10m)
            {
                Text[0].text = "00" + TimeLeft.ToString();
            }
            else if (TimeLeft < 100m)
            {
                Text[0].text = "0" + TimeLeft.ToString();
            }
            else
            {
                Text[0].text = TimeLeft.ToString();
            }
            Text[0].color = Colors[0];
            yield return(new WaitForSeconds(0.05f));

            Text[0].color = Colors[1];
            yield return(new WaitForSeconds(0.1174f));

            TimeLeft = TimeLeft - 1m;
            if (TimeLeft < 10m)
            {
                Text[0].text = "00" + TimeLeft.ToString();
            }
            else if (TimeLeft < 100m)
            {
                Text[0].text = "0" + TimeLeft.ToString();
            }
            else
            {
                Text[0].text = TimeLeft.ToString();
            }
            yield return(new WaitForSeconds(0.1674f));

            TimeLeft = TimeLeft - 1m;
            if (TimeLeft < 10m)
            {
                Text[0].text = "00" + TimeLeft.ToString();
            }
            else if (TimeLeft < 100m)
            {
                Text[0].text = "0" + TimeLeft.ToString();
            }
            else
            {
                Text[0].text = TimeLeft.ToString();
            }
            yield return(new WaitForSeconds(0.1674f));
        }
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.Strike, Module.transform);
        Sounds.Stop();
        yield return(new WaitForSeconds(2f));

        Text[0].text          = "OH";
        Text[0].characterSize = 0.4f;
        Text[1].text          = "SORRY,";
        Text[2].text          = "FALSE";
        Text[3].text          = "ALARM";
        yield return(new WaitForSeconds(2.5f));

        Text[0].text = "";
        Text[1].text = "";
        Text[2].text = "";
        Text[3].text = "";
        yield return(new WaitForSeconds(0.5f));

        StartCoroutine(Respawn());
    }
    // Use this for initialization
    void Start()
    {
        _moduleId++;

        _startmin = int.Parse(BombInfo.GetFormattedTime().Split(':').First());
        _startsec = int.Parse(BombInfo.GetFormattedTime().Split(':').Last());

        LogTheFile(string.Format("The bomb's starting time was {0} minutes and {1} seconds.", _startmin, _startsec));

        _questions = new List <ReversedEdgeworkQuestion>
        {
            new ReversedEdgeworkQuestion("# of INDs", BombInfo.GetIndicators().Count()),
            new ReversedEdgeworkQuestion("# of lit INDs", BombInfo.GetOnIndicators().Count()),
            new ReversedEdgeworkQuestion("# of off INDs", BombInfo.GetOffIndicators().Count()),
            new ReversedEdgeworkQuestion("# of ports", BombInfo.GetPortCount()),
            new ReversedEdgeworkQuestion("# of port p.s", BombInfo.GetPortPlateCount()),
            new ReversedEdgeworkQuestion("# of batts", BombInfo.GetBatteryCount()),
            new ReversedEdgeworkQuestion("# of D batts", BombInfo.GetBatteryCount(Battery.D)),
            new ReversedEdgeworkQuestion("# of AA batts", BombInfo.GetBatteryCount(Battery.AA)),
            new ReversedEdgeworkQuestion("# of batt hds", BombInfo.GetBatteryHolderCount()),
            new ReversedEdgeworkQuestion("First # of SN", BombInfo.GetSerialNumberNumbers().First()),
            new ReversedEdgeworkQuestion("Last # of SN", BombInfo.GetSerialNumberNumbers().Last()),
            new ReversedEdgeworkQuestion("# of mod", BombInfo.GetModuleNames().Count),
            new ReversedEdgeworkQuestion("# of r. mod", BombInfo.GetSolvableModuleNames().Count),
            new ReversedEdgeworkQuestion("# of n. mod",
                                         BombInfo.GetModuleNames().Count - BombInfo.GetSolvableModuleNames().Count),
            new ReversedEdgeworkQuestion("b. st. min", _startmin),
            new ReversedEdgeworkQuestion("b. st. sec", _startsec)
        };
        for (var i = 0; i < 4; ++i)
        {
            int index = i;
            Buttons[index].OnInteract += delegate
            {
                Buttons[index].AddInteractionPunch();
                ModuleAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Buttons[index].transform);
                if (!_active)
                {
                    return(false);
                }

                if (_mainQuestion.Answer != _assignedQuestions[index].Answer)
                {
                    _active = false;
                    foreach (var text in texts)
                    {
                        text.text = "";
                    }

                    screenText.text = "";
                    LogTheFile(string.Format("You pressed {0}({1}), which was wrong. Handling Strike and going to sleep.",
                                             _assignedQuestions[index].Question, _assignedQuestions[index].Answer.ToString()));
                    Module.HandleStrike();
                    Module.HandlePass();
                }
                else
                {
                    _active = false;
                    foreach (var text in texts)
                    {
                        text.text = "";
                    }

                    screenText.text = "";
                    Module.HandlePass();
                    LogTheFile("Correct button pressed, going to sleep.");
                }

                return(false);
            };
            Buttons[index].OnInteractEnded += delegate
            {
                ModuleAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease,
                                                     Buttons[index].transform);
            };
        }

        Module.OnNeedyActivation   += GenerateQuestion;
        Module.OnNeedyDeactivation += delegate
        {
            _active = false;
            foreach (var text in texts)
            {
                text.text = "";
            }
            screenText.text = "";
        };
        Module.OnTimerExpired += delegate
        {
            foreach (var text in texts)
            {
                text.text = "";
            }

            screenText.text = "";
            LogTheFile("Timer expired, handling Strike");
            Module.HandleStrike();
        };
    }
    private void Press(int l, int m, int b, int s)
    {
        buttons[b].AddInteractionPunch();
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, buttons[b].transform);
        push = new int[3] {
            l, selectedmod[1], b
        };
        switch (rule)
        {
        case 0:
            switch (s)
            {
            default: pass = m == selectedmod[1] && b == 0; break;

            case 1: pass = m == presses.Last()[1] && b == 1; break;

            case 2: pass = m == presses[presses.Count() - 2][1] && b == values.IndexOf(0) % 4; break;

            case 3: pass = m == presses[presses.Count() - 2][1] && b == 1; break;

            case 4: pass = m == presses.Last()[1] && b == values.IndexOf(1) % 4; break;
            }
            break;

        case 1:
            switch (s)
            {
            default: pass = l == 1; break;

            case 1: pass = l == presses.Last()[0]; break;

            case 2: pass = l == presses.First(x => x[1] == selectedmod[1])[0]; break;

            case 3: pass = l == presses.Where(x => x[1] == selectedmod[1]).ToArray()[1][0]; break;

            case 4: pass = m == selectedmod[1] && b == presses.First(x => x[1] == selectedmod[1])[2]; break;
            }
            break;

        case 2:
            switch (s)
            {
            default: pass = m == selectedmod[1] && b == values.IndexOf(2) % 4; break;

            case 1: pass = m == presses.Last()[1] && b == presses.First(x => x[1] == selectedmod[1])[2]; break;

            case 2: pass = m == selectedmod[1] && b == 1; break;

            case 3: pass = l == presses.Where(x => x[1] == selectedmod[1]).ToArray()[2][0]; break;

            case 4: pass = m == selectedmod[1] && b == values.IndexOf(presses.Last()[0]) % 4; break;
            }
            break;

        case 3:
            switch (s)
            {
            default: pass = m == selectedmod[1] && b == 3; break;

            case 1: pass = m == selectedmod[1] && b == values.IndexOf(presses.First(x => x[1] == selectedmod[1])[0]) % 4; break;

            case 2: pass = m == presses[presses.Count() - 2][1] && b == values.IndexOf(3) % 4; break;

            case 3: pass = m == values.IndexOf(2) / 4 && b == presses.Where(x => x[1] == selectedmod[1]).ToArray()[1][2]; break;

            case 4: pass = l == presses[presses.Count() - 4][0]; break;
            }
            break;

        case 4:
            switch (s)
            {
            default: pass = m == values.IndexOf(1) / 4 && b == 2; break;

            case 1: pass = m == values.IndexOf(2) / 4 && b == presses.First(x => x[1] == selectedmod[1])[2]; break;

            case 2: pass = l == presses.Where(x => x[1] == selectedmod[1]).ToArray()[1][0]; break;

            case 3: pass = m == values.IndexOf(3) / 4 && b == presses.Last()[2]; break;

            case 4: pass = m == values.IndexOf(0) / 4 && b == presses.Where(x => x[1] == selectedmod[1]).ToArray()[2][2]; break;
            }
            break;

        case 5:
            switch (s)
            {
            default: pass = l == 2; break;

            case 1: pass = m == selectedmod[1] && b == presses.First(x => x[1] == selectedmod[1])[2]; break;

            case 2: pass = m == selectedmod[1] && b == presses[presses.Count() - 2][2]; break;

            case 3: pass = m == presses[presses.Count() - 3][1] && b == presses.First(x => x[1] == selectedmod[1])[2]; break;

            case 4: pass = l == presses.First(x => x[1] == selectedmod[1])[0]; break;
            }
            break;

        case 6:
            switch (s)
            {
            default: pass = m == selectedmod[1] && b == 1; break;

            case 1: pass = l == presses.First(x => x[1] == selectedmod[1])[0]; break;

            case 2: pass = m == selectedmod[1] && b == presses.First(x => x[1] == selectedmod[1])[2]; break;

            case 3: pass = m == selectedmod[1] && b == values.IndexOf(presses[presses.Count() - 3][0]) % 4; break;

            case 4: pass = l == presses[presses.Count() - 3][0]; break;
            }
            break;

        case 7:
            switch (s)
            {
            default: pass = m == selectedmod[1] && b == values.IndexOf(0) % 4; break;

            case 1: pass = m == selectedmod[1] && b == values.IndexOf(presses.Last()[0]) % 4; break;

            case 2: pass = m == presses.Last()[1] && b == 1; break;

            case 3: pass = m == presses[presses.Count() - 2][1] && b == values.IndexOf(0) % 4; break;

            case 4: pass = m == values.IndexOf(presses.First(x => x[1] == selectedmod[1])[0]) / 4 && b == 3; break;
            }
            break;

        default:
            switch (s)
            {
            default: pass = m == values.IndexOf(3) / 4 && b == 0; break;

            case 1: pass = m == values.IndexOf(presses.First(x => x[1] == selectedmod[1])[0]) / 4 && b == 3; break;

            case 2: pass = m == selectedmod[1] && b == presses[presses.Count() - 2][2]; break;

            case 3: pass = m == values.IndexOf(presses.Where(x => x[1] == selectedmod[1]).ToArray()[2][0]) / 4 && b == values.IndexOf(2) % 4; break;

            case 4: pass = m == selectedmod[1] && b == values.IndexOf(presses[presses.Count() - 2][0]) % 4; break;
            }
            break;
        }
        next    = false;
        advance = advance.Select(x => true).ToArray();
    }
示例#17
0
    bool ButtonPressed(int button, bool repeat)
    {
        if (!repeat)
        {
            buttons[button].AddInteractionPunch(0.25f);
            bAnims[button].Play("AnimDown", 0, 0);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);

            // Work around double-press bug in the game
            if (holdRoutine != null)
            {
                StopCoroutine(holdRoutine);
            }

            // Arrow buttons can repeat if held for long enough.
            if (button <= 1)
            {
                holdRoutine = StartCoroutine(HoldRepeat(button));
            }
        }

        if (moduleSolved || moduleStruck || correctName[0] == '_')
        {
            return(false);
        }

        switch (button)
        {
        case 0:                 // Up button
            highScores[entryNum].name[cursorOn] =
                (highScores[entryNum].name[cursorOn] == 'Z') ? 'A' : (char)(highScores[entryNum].name[cursorOn] + 1);
            break;

        case 1:                 // Down button
            highScores[entryNum].name[cursorOn] =
                (highScores[entryNum].name[cursorOn] == 'A') ? 'Z' : (char)(highScores[entryNum].name[cursorOn] - 1);
            break;

        case 2:                 // Submit button
            if (++cursorOn <= 2)
            {
                highScores[entryNum].name[cursorOn] = highScores[entryNum].name[cursorOn - 1];
            }
            else if (highScores[entryNum].name.SequenceEqual(correctName))
            {
                Debug.LogFormat("[The High Score #{0}] SOLVE: Submitted '{1}'. Correct.", thisLogID, new string(highScores[entryNum].name));
                moduleSolved = true;
                bombAudio.PlaySoundAtTransform("OK", transform);
                bombModule.HandlePass();
            }
            else if (BadWordPresent(highScores[entryNum].name))
            {
                Debug.LogFormat("[The High Score #{0}] STRIKE: Submitted a word on the bad words filter. Wrong.", thisLogID);
                highScores[entryNum].name = "NO!".ToCharArray();
                moduleStruck = true;
                bombAudio.PlaySoundAtTransform("NO", transform);
                bombModule.HandleStrike();
            }
            else
            {
                Debug.LogFormat("[The High Score #{0}] STRIKE: Submitted '{1}'. Wrong.", thisLogID, new string(highScores[entryNum].name));
                moduleStruck = true;
                bombAudio.PlaySoundAtTransform("NO", transform);
                bombModule.HandleStrike();
            }
            break;

        case 3:                 // Back button
            if (cursorOn > 0)
            {
                highScores[entryNum].name[cursorOn--] = '_';
            }
            break;
        }
        return(false);
    }
示例#18
0
    void KeyPress(KMSelectable Key)
    {
        if (!moduleSolved && !currentlyCalculating)
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Key.transform);
            Key.AddInteractionPunch(.4f);
            Debug.LogFormat("[Kanji #{0}] You pressed '{1}'.", moduleId, Key.GetComponentInChildren <TextMesh>().text);

            if (unicorn && Key == Keys[3])
            {
                HandleSolve();
                return;
            }

            if (Stage == 1)
            {
                if (s1CorrectButton == 0 && Key == Keys[0])
                {
                    StageAdvance();
                }
                else if (s1CorrectButton == 1 && Key == Keys[1])
                {
                    StageAdvance();
                }
                else if (s1CorrectButton == 2 && Key == Keys[2])
                {
                    StageAdvance();
                }
                else if (s1CorrectButton == 3 && Key == Keys[3])
                {
                    StageAdvance();
                }
                else
                {
                    HandleStrike();
                }
            }
            else if (Stage == 2)
            {
                if (s2CorrectButton == 0 && Key == Keys[0])
                {
                    StageAdvance();
                }
                else if (s2CorrectButton == 1 && Key == Keys[1])
                {
                    StageAdvance();
                }
                else if (s2CorrectButton == 2 && Key == Keys[2])
                {
                    StageAdvance();
                }
                else if (s2CorrectButton == 3 && Key == Keys[3])
                {
                    StageAdvance();
                }
                else
                {
                    HandleStrike();
                }
            }
            else if (Stage == 3)
            {
                if (s3CorrectButton == 0 && Key == Keys[0])
                {
                    StageAdvance();
                }
                else if (s3CorrectButton == 1 && Key == Keys[1])
                {
                    StageAdvance();
                }
                else if (s3CorrectButton == 2 && Key == Keys[2])
                {
                    StageAdvance();
                }
                else if (s3CorrectButton == 3 && Key == Keys[3])
                {
                    StageAdvance();
                }
                else
                {
                    HandleStrike();
                }
            }
        }
    }
示例#19
0
    void Awake()
    {
        moduleId = moduleIdCounter++;
        foreach (KMSelectable button in buttons)
        {
            button.OnInteract += delegate() { ButtonPress(button); return(false); }
        }
        ;
        isCorasComputer = Environment.MachineName == "CREAMMACHINE";
        Debug.LogFormat("<Symbolic Tasha #{0}> System name is {1}.", moduleId, Environment.MachineName);
        colorblindText.gameObject.SetActive(GetComponent <KMColorblindMode>().ColorblindModeActive);
    }

    void Start()
    {
        float scalar = transform.lossyScale.x;

        for (int i = 0; i < 4; i++)
        {
            lights[i].range  *= scalar;
            lights[i].enabled = false;
        }
        buttonColors = buttonColors.Shuffle().ToArray();
        var letters = "IGYB".Select(x => x.ToString()).ToArray();

        colorblindText.text = string.Format("  {0}  \n{1}    {2}\n  {3}  ", letters[(int)buttonColors[0]], letters[(int)buttonColors[3]], letters[(int)buttonColors[1]], letters[(int)buttonColors[2]]);
        soundNames          = soundNames.Shuffle().ToArray();
        for (int i = 0; i < 4; i++)
        {
            btnRenderers[i].material.color = materialColors[(int)buttonColors[i]];
            lights[i].color   = materialColors[(int)buttonColors[i]];
            presentSymbols[i] = (stSymbol)rnd.Range(1, 19);
            buttonSymbols[i].material.mainTexture = symbols[(int)presentSymbols[i] - 1];
            Debug.LogFormat("[Symbolic Tasha #{0}] The {1} button is {2}, with the symbol titled '{3}'.", moduleId, positionNames[i], buttonColors[i], presentSymbols[i]);
        }
        string[] ordinals = new string[5] {
            "First", "Second", "Third", "Fourth", "Fifth"
        };
        for (int i = 0; i < 5; i++)
        {
            flashing[i] = rnd.Range(0, 4);
        }
        Debug.LogFormat("[Symbolic Tasha #{0}] Flashing Colors: {1}: {2} | {3}: {4} | {5}: {6} | {7}: {8} | {9}: {10}", moduleId, ordinals[0], buttonColors[flashing[0]], ordinals[1], buttonColors[flashing[1]], ordinals[2], buttonColors[flashing[2]], ordinals[3], buttonColors[flashing[3]], ordinals[4], buttonColors[flashing[4]]);
        solution.Add(CalculateStage());
        Debug.LogFormat("[Symbolic Tasha #{0}] The first color to press is {1}.", moduleId, solution[0]);
        sequenceFlashing = StartCoroutine(SequenceFlash());
    }

    void ButtonPress(KMSelectable button)
    {
        anyBtnPressed = true;
        var ix = Array.IndexOf(buttons, button);

        button.AddInteractionPunch(2);
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, button.transform);
        audio.PlaySoundAtTransform(soundNames[ix], button.transform);
        if (!cracked[ix])
        {
            cracked[ix]        = true;
            presentSymbols[ix] = (stSymbol)(-(int)presentSymbols[ix]);
            btnRenderers[ix].material.mainTexture = crackedTexture;
            buttonSymbols[ix].gameObject.SetActive(false);
            if (!isCorasComputer)
            {
                audio.PlaySoundAtTransform("shatter" + rnd.Range(1, 5), button.transform);
            }
            if (!moduleSolved)
            {
                Debug.LogFormat("[Symbolic Tasha #{0}] The {1} button cracked!", moduleId, buttonColors[ix]);
            }
        }
        if (moduleSolved)
        {
            return;
        }
        if (enteringStage == 0)
        {
            StopCoroutine(sequenceFlashing);
            foreach (Light l in lights)
            {
                l.enabled = false;
            }
        }
        StartCoroutine(SingleFlash(ix));
        if (waiting != null)
        {
            StopCoroutine(waiting);
            waiting = null;
        }
        waiting = StartCoroutine(Wait());
        if (buttonColors[ix] != solution[enteringStage])
        {
            enteringStage = 0;
            Debug.LogFormat("[Symbolic Tasha #{0}] You pressed the {1} button. That was incorrect. Strike!", moduleId, buttonColors[ix]);
            if (waiting != null)
            {
                StopCoroutine(waiting);
                waiting = null;
            }
            module.HandleStrike();
            StopCoroutine(sequenceFlashing);
            sequenceFlashing = StartCoroutine(SequenceFlash());
        }
        else
        {
            enteringStage++;
        }
        if (enteringStage > stage)
        {
            enteringStage = 0;
            if (waiting != null)
            {
                StopCoroutine(waiting);
                waiting = null;
            }
            AdvanceStage();
        }
    }

    void AdvanceStage()
    {
        stage++;
        if (bomb.GetStrikes() >= 2 && !trueConditions[0])
        {
            trueConditions[0] = true;
            Debug.LogFormat("[Symbolic Tasha #{0}] The number of strikes has reached 2 or more. The first condition is now true.", moduleId);
        }
        if (cracked.Count(b => b) >= 2 && !trueConditions[1])
        {
            trueConditions[1] = true;
            Debug.LogFormat("[Symbolic Tasha #{0}] The number of cracked buttons has reached 2 or more. The second condition is now true.", moduleId);
        }
        if (bomb.GetPortPlates().Any(x => x.Length == 0))
        {
            trueConditions[2] = true;
        }
        currentTable = Array.IndexOf(trueConditions, true);
        if (stage == 5)
        {
            module.HandlePass();
            moduleSolved = true;
            if (waiting != null)
            {
                StopCoroutine(waiting);
            }
            StopCoroutine(sequenceFlashing);
            foreach (Light l in lights)
            {
                l.enabled = false;
            }
            Debug.LogFormat("[Symbolic Tasha #{0}] Module solved!", moduleId);
        }
        else
        {
            solution.Add(CalculateStage());
            sequenceFlashing = StartCoroutine(SequenceFlash());
            var colorName            = solution[stage].ToString();
            var capitalizedColorName = colorName[0].ToString().ToUpperInvariant() + colorName.Substring(1);
            Debug.LogFormat("[Symbolic Tasha #{0}] {1} was added to the sequence of colors to press.", moduleId, capitalizedColorName);
        }
    }

    IEnumerator SingleFlash(int ix)
    {
        flashingButtons[ix] = true;
        lights[ix].enabled  = true;
        yield return(new WaitForSeconds(.5f));

        lights[ix].enabled  = false;
        flashingButtons[ix] = false;
    }

    IEnumerator SequenceFlash()
    {
        while (flashingButtons.Contains(true))
        {
            yield return(null);
        }
        yield return(new WaitForSeconds(1.75f));

sequenceReset:
        for (int i = 0; i <= stage; i++)
        {
            int ix = flashing[i];
            lights[ix].enabled = true;
            if (anyBtnPressed)
            {
                audio.PlaySoundAtTransform(soundNames[ix], buttons[ix].transform);
            }
            yield return(new WaitForSeconds(.8f));

            lights[ix].enabled = false;
            yield return(new WaitForSeconds(.4f));
        }
        yield return(new WaitForSeconds(3.5f));

        goto sequenceReset;
    }

    IEnumerator Wait()
    {
        yield return(new WaitForSeconds(7f));

        enteringStage    = 0;
        sequenceFlashing = StartCoroutine(SequenceFlash());
    }

    stColor CalculateStage()
    {
        Debug.LogFormat("[Symbolic Tasha #{0}] Rule being applied for Stage {1}: {2} ", moduleId, stage + 1, rules[currentTable]);
        stSymbol usingSymbol = presentSymbols[flashing[stage]];

        for (int i = 0; i < 12; i++)
        {
            if (Tables.symbolColumns[currentTable][i].Contains(usingSymbol))
            {
                return(Tables.colorRows[currentTable][Array.IndexOf(trueColors, buttonColors[flashing[stage]])][i]);
            }
        }
        return(stColor.pink);
    }
    private IEnumerator BeginDeal()
    {
        // TODO: Disable buttons

        Credits             -= BetAmount;
        CreditsText.Text     = String.Format("CREDIT {0}", Credits);
        BetText.Text         = String.Format("BET {0}", BetAmount);
        GameMessageText.Text = "GOOD LUCK";
        State = KtaneVideoPoker.State.FirstDeal;

        for (int i = 0; i < 5; i++)
        {
            CardObjects[i].Card = null;
            CardObjects[i].Held = false;
        }

        GameInfoButton.Disable();
        SpeedButton.Disable();
        BetOneButton.Disable();
        BetMaxButton.Disable();
        DealButton.Disable();

        yield return(new WaitForSeconds(2 * SpeedButton.GetDelay()));

        int deckSize = KtaneVideoPoker.Core.Util.StandardDeckSize + VariantInfo.VariantIfUsingMaxBet(BetAmount == 5).JokerCount;

        AvailableCards = new Stack <KtaneVideoPoker.Core.Card>(Enumerable.Range(0, deckSize).Select(KtaneVideoPoker.Core.Card.CreateWithId).ToList().Shuffle());

        for (int i = 0; i < 5; i++)
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.TypewriterKey, transform);
            CardObjects[i].Card = AvailableCards.Pop();
            yield return(new WaitForSeconds(SpeedButton.GetDelay()));
        }

        // Log cards
        if (!IsSolved)
        {
            ModuleLog("Dealt cards: {0}", CardObjects.Select(co => co.CardAsLogString()).Join(" "));
        }

        var hand           = new KtaneVideoPoker.Core.Hand(CardObjects.Select(co => co.Card).Where(c => c.HasValue).Select(c => c.Value));
        var strategyResult = VariantInfo.StrategyMaxBet.Evaluate(hand);

        if (BetAmount == 5)
        {
            AcceptablePlays = new HashSet <int>(strategyResult.Strategies);

            if (!IsSolved)
            {
                if (strategyResult.RuleIndex >= 0)
                {
                    ModuleLog("Use rule {0}", strategyResult.RuleIndex + 1);
                    ModuleLog("Applicable special rules: {0}", strategyResult.ExtraRules.Length > 0 ? strategyResult.ExtraRules.Join(", ") : "none");
                }
                else
                {
                    ModuleLog("Applicable exceptions: {0}", strategyResult.ExtraRules.Length > 0 ? strategyResult.ExtraRules.Join(", ") : "none");
                    ModuleLog("No valid rules found");
                }

                ModuleLog("Acceptable plays:");
                foreach (int strategy in strategyResult.Strategies)
                {
                    if (strategy == 0)
                    {
                        ModuleLog("• Discard everything");
                    }
                    else
                    {
                        ModuleLog("• Hold {0}", CardObjects.Where((co, i) => (strategy & (1 << i)) != 0).Select(co => co.RankText.text + co.SuitText.text).Join(" "));
                    }
                }
            }
        }


        State = KtaneVideoPoker.State.ChooseHolds;

        var intermediateHandType = VariantInfo.VariantIfUsingMaxBet(BetAmount == 5).Evaluate(hand);

        if (intermediateHandType == KtaneVideoPoker.Core.HandResult.Nothing)
        {
            GameMessageText.Text = "";
        }
        else
        {
            Audio.PlaySoundAtTransform("gliss1", transform);
            GameMessageText.Text = intermediateHandType.ToFriendlyString();
        }

        GameInfoButton.Text.text = "Game Info";
        GameInfoButton.Enable();

        SpeedButton.Enable();

        DealButton.Text.text = "Draw";
        DealButton.Enable();
    }
示例#21
0
文件: boxing.cs 项目: tasthing/Boxing
    void Awake()
    {
        moduleId = moduleIdCounter++;
        boxingGlove.OnInteract   += delegate() { PressBoxingGlove(); return(false); };
        hireButton.OnInteract    += delegate() { Hire(); return(false); };
        abstainButton.OnInteract += delegate() { Abstain(); return(false); };
        foreach (KMSelectable arrowButton in arrowButtons)
        {
            arrowButton.OnInteract += delegate() { PressArrowButton(arrowButton); return(false); }
        }
        ;
        GetComponent <KMBombModule>().OnActivate += OnActivate;
    }

    void Start()
    {
        contestantStrengths = Enumerable.Range(0, 5).ToList().Shuffle().ToArray();
        contestantIndices   = Enumerable.Range(0, 25).ToList().Shuffle().Take(5).ToArray();
        var ordinals = new string[5] {
            "1st", "2nd", "3rd", "4th", "5th"
        };
        var count = 0;

        for (int i = 0; i < 5; i++)
        {
            lastNameIndices[i]           = rnd.Range(0, possibleLastNames.Length);
            substituteIndices[i]         = rnd.Range(0, possibleSubstituteNames.Length);
            substituteLastNameIndices[i] = rnd.Range(0, possibleLastNames.Length);
            var value1         = contestantStrengths[contestantIndices[i] / 5];
            var value2         = contestantStrengths[contestantIndices[i] % 5];
            var contestantChar = alphabet[5 * value1 + value2];
            var letterPresent  = possibleNames[contestantIndices[i]].ToUpperInvariant().Contains(contestantChar) || possibleLastNames[lastNameIndices[i]].ToUpperInvariant().Contains(contestantChar) || possibleSubstituteNames[substituteIndices[i]].ToUpperInvariant().Contains(contestantChar) || possibleLastNames[substituteLastNameIndices[i]].ToUpperInvariant().Contains(contestantChar);
            if (letterPresent)
            {
                count += 1 << (4 - i);
            }
            Debug.LogFormat("[Boxing #{0}] The {1} contestant is {2} {3}, with punch strength {4}, and his substitute is {5} {6}. His base 5 pair forms the letter {7}, which is{8} present on the page.", moduleId, ordinals[i], possibleNames[contestantIndices[i]], possibleLastNames[lastNameIndices[i]], contestantStrengths[i], possibleSubstituteNames[substituteIndices[i]], possibleLastNames[substituteLastNameIndices[i]], contestantChar, letterPresent ? "" : " not");
        }
        var unmodifiedCount = count;

        count %= 6;
        Debug.LogFormat("[Boxing #{0}] The final number is {1}, modulo 6 is {2}.", moduleId, unmodifiedCount, count % 6);
        switch (count)
        {
        case 5:
            solution = 10;
            Debug.LogFormat("[Boxing #{0}] Every contestant is on steroids. Abstain from participating.", moduleId);
            break;

        case 4:
            solution = Array.IndexOf(contestantStrengths, 0);
            Debug.LogFormat("[Boxing #{0}] The strongest contestant not on steroids is {1}.", moduleId, possibleNames[contestantIndices[solution]]);
            break;

        case 3:
            solution = Array.IndexOf(contestantStrengths, 1);
            Debug.LogFormat("[Boxing #{0}] The strongest contestant not on steroids is {1}.", moduleId, possibleNames[contestantIndices[solution]]);
            break;

        case 2:
            solution = Array.IndexOf(contestantStrengths, 2);
            Debug.LogFormat("[Boxing #{0}] The strongest contestant not on steroids is {1}.", moduleId, possibleNames[contestantIndices[solution]]);
            break;

        case 1:
            solution = Array.IndexOf(contestantStrengths, 3);
            Debug.LogFormat("[Boxing #{0}] The strongest contestant not on steroids is {1}.", moduleId, possibleNames[contestantIndices[solution]]);
            break;

        default:
            solution = Array.IndexOf(contestantStrengths, 4);
            Debug.LogFormat("[Boxing #{0}] The strongest contestant not on steroids is {1}.", moduleId, possibleNames[contestantIndices[solution]]);
            break;
        }
        screenTexts[0].text = "";
        screenTexts[1].text = "";
        screenTexts[2].text = "";
        screenTexts[3].text = "";
    }

    void OnActivate()
    {
        var oldMessages = new string[4] {
            screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
        };
        var newMessages = new string[4] {
            possibleNames[contestantIndices[chosenContestant]], possibleLastNames[lastNameIndices[chosenContestant]], possibleSubstituteNames[substituteIndices[chosenContestant]], possibleLastNames[substituteLastNameIndices[chosenContestant]]
        };

        for (int i = 0; i < 4; i++)
        {
            StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
        }
    }

    void PressBoxingGlove()
    {
        if (moduleSolved)
        {
            return;
        }
        boxingGlove.AddInteractionPunch(strengths[contestantStrengths[chosenContestant]]);
        audio.PlaySoundAtTransform("punch" + rnd.Range(0, 6).ToString(), boxingGlove.transform);
    }

    void PressArrowButton(KMSelectable button)
    {
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, button.transform);
        button.AddInteractionPunch(.5f);
        if (moduleSolved)
        {
            return;
        }
        var offsets = new int[2] {
            -1, 1
        };
        var ix = Array.IndexOf(arrowButtons, button);

        if (!(chosenContestant == 0 && ix == 0) && !(chosenContestant == 4 && ix == 1))
        {
            chosenContestant += offsets[ix];
            StopAllCoroutines();
            var oldMessages = new string[4] {
                screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
            };
            var newMessages = new string[4] {
                possibleNames[contestantIndices[chosenContestant]], possibleLastNames[lastNameIndices[chosenContestant]], possibleSubstituteNames[substituteIndices[chosenContestant]], possibleLastNames[substituteLastNameIndices[chosenContestant]]
            };
            for (int i = 0; i < 4; i++)
            {
                StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
            }
        }
        else
        {
            audio.PlaySoundAtTransform("error", button.transform);
        }
    }

    void Hire()
    {
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, hireButton.transform);
        hireButton.AddInteractionPunch(.75f);
        if (moduleSolved)
        {
            return;
        }
        if (chosenContestant == solution)
        {
            module.HandlePass();
            Debug.LogFormat("[Boxing #{0}] You submitted {1}. That is correct. Module solved!", moduleId, possibleNames[contestantIndices[chosenContestant]]);
            moduleSolved = true;
            var oldMessages = new string[4] {
                screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
            };
            var newMessages = new string[4] {
                "Ready", "for", "the", "match!"
            };
            for (int i = 0; i < 4; i++)
            {
                StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
            }
            audio.PlaySoundAtTransform("bell", hireButton.transform);
        }
        else
        {
            module.HandleStrike();
            Debug.LogFormat("[Boxing #{0}] You submitted {1}. That is incorrect. Strike!", moduleId, possibleNames[contestantIndices[chosenContestant]]);
            audio.PlaySoundAtTransform("strike", hireButton.transform);
        }
    }

    void Abstain()
    {
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, abstainButton.transform);
        abstainButton.AddInteractionPunch(.75f);
        if (moduleSolved)
        {
            return;
        }
        if (solution == 10)
        {
            module.HandlePass();
            Debug.LogFormat("[Boxing #{0}] You abstained from participating. That is correct. Module solved!", moduleId);
            audio.PlaySoundAtTransform("abstain", abstainButton.transform);
            moduleSolved = true;
            var oldMessages = new string[4] {
                screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
            };
            var newMessages = new string[4] {
                "No", "contest", "this", "time..."
            };
            for (int i = 0; i < 4; i++)
            {
                StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
            }
        }
        else
        {
            module.HandleStrike();
            Debug.LogFormat("[Boxing #{0}] You abstained from participating. That is incorrect. Strike!", moduleId);
            audio.PlaySoundAtTransform("strike", abstainButton.transform);
        }
    }

    IEnumerator CycleText(TextMesh display, string oldMessage, string newMessage)
    {
        var currentMessage = oldMessage;
        var messageLength  = currentMessage.Length;

        for (int i = 0; i < messageLength; i++)
        {
            currentMessage = currentMessage.Remove(currentMessage.Length - 1);
            display.text   = currentMessage;
            audio.PlaySoundAtTransform("beep", display.transform);
            yield return(new WaitForSeconds(.05f));
        }
        currentMessage = "";
        if (!moduleSolved)
        {
            display.color = Color.white; //sss
        }
        else
        {
            display.color = solveColor;
        }
        for (int i = 0; i < newMessage.Length; i++)
        {
            currentMessage = currentMessage + newMessage[i];
            display.text   = currentMessage;
            audio.PlaySoundAtTransform("beep", display.transform);
            yield return(new WaitForSeconds(.05f));
        }
    }
    void Awake()
    {
        needySelf.OnActivate += delegate()
        {
            mustInvert = bombInfo.GetSerialNumberNumbers().ToList().Count > 0 ? bombInfo.GetSerialNumberNumbers().Last() % 2 != 0 : false;
            // If there is at least 1 number in the serial number, grab the last one and check if it's odd or even. Otherwise set it to false by default.
        };
        needySelf.OnNeedyActivation += delegate()
        {// Generate board with goal presses and mix up interactable board with lit/unilt tiles
            if (forceDisable)
            {
                needySelf.HandlePass();
                return;
            }
            hasActivated = true;
            bool[] choices = new bool[] { true, false };
            for (int pos = 0; pos < lightstate.Count(); pos++)
            {
                lightstate[pos] = choices[UnityEngine.Random.Range(0, choices.Count())];
            }

            for (int pos = 0; pos < goallights.Count(); pos++)
            {
                goallights[pos] = choices[UnityEngine.Random.Range(0, choices.Count())];
            }
        };
        needySelf.OnNeedyDeactivation += delegate() // If the module is force-deactivated
        {
            hasActivated = false;
            for (int x = 0; x < buttonColors.Count(); x++)
            {
                buttonColors[x].material = buttonDeactivated;
                lightKeys[x].enabled     = false;
            }
        };

        needySelf.OnTimerExpired += delegate()
        {
            StopCoroutine(FlashGoalOnWarning());
            isWarning = false;
            if (IsCorrect(lightstate))
            {
                sound.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform);
                StartCoroutine(PlayCorrectAnim());
            }
            else
            {
                needySelf.HandleStrike();
                StartCoroutine(PlayStrikeAnim());
            }
            hasActivated = false;
        };
        for (int x = 0; x < buttons.Count(); x++)
        {
            int pos = x;
            buttonSelectables[pos].OnInteract += delegate()
            {
                if (!hasActivated)
                {
                    return(false);
                }
                buttonSelectables[pos].AddInteractionPunch(0.5f);
                sound.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
                lightstate[pos] = !lightstate[pos];
                return(false);
            };
        }
    }
    /// <summary>
    /// Helper method that will change the numbers based on which arrow button is pressed
    /// </summary>
    /// <param name="index">Index of the button pushed (0 is top-left, then goes along the rows; 5 is bottom-right)</param>
    private void ChangeNumber(int index)
    {
        switch (index)
        {
        //Add to left digit
        case 0:
            digits[0]     = (digits[0] + 1) % 10;
            leftText.text = digits[0].ToString();
            upButtonLeft.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 1's up button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        //Add to middle digit
        case 1:
            digits[1]       = (digits[1] + 1) % 10;
            middleText.text = digits[1].ToString();
            upButtonMiddle.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 2's up button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        //Add to right digit
        case 2:
            digits[2]      = (digits[2] + 1) % 10;
            rightText.text = digits[2].ToString();
            upButtonRight.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 3's up button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        //Subtract from left digit
        case 3:
            digits[0]     = (digits[0] + 9) % 10;
            leftText.text = digits[0].ToString();
            downButtonLeft.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 1's down button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        //Subtract from middle digit
        case 4:
            digits[1]       = (digits[1] + 9) % 10;
            middleText.text = digits[1].ToString();
            downButtonMiddle.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 2's down button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        //Subtract from right digit
        case 5:
            digits[2]      = (digits[2] + 9) % 10;
            rightText.text = digits[2].ToString();
            downButtonRight.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 3's down button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        default:
            break;
        }
    }
 private void KeyPress(KMSelectable key)
 {
     if (alreadypressed[keys.IndexOf(key)] == false && moduleSolved == false && pressable == true)
     {
         Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, key.transform);
         alreadypressed[keys.IndexOf(key)] = true;
         key.transform.localPosition       = new Vector3(0, 0, -1f);
         key.AddInteractionPunch();
         if (!recovery)
         {
             presses.Add((keys.IndexOf(key) + 1).ToString());
             if (pressCount < 5)
             {
                 pressCount++;
             }
             else
             {
                 pressCount = 0;
                 string[] answ = new string[6];
                 for (int i = 0; i < 6; i++)
                 {
                     answ[i] = (answer.IndexOf(i + 1) + 1).ToString();
                 }
                 string   ans   = string.Join(string.Empty, answ);
                 string[] press = presses.ToArray();
                 string   pr    = string.Join(string.Empty, press);
                 Debug.LogFormat("[Tallordered Keys #{0}] After {1} reset(s), the buttons were pressed in the order: {2}", moduleID, resetCount, pr);
                 if (ans == pr)
                 {
                     Audio.PlaySoundAtTransform("InputCorrect", transform);
                     moduleSolved = true;
                 }
                 else
                 {
                     GetComponent <KMBombModule>().HandleStrike();
                     recovery      = true;
                     pressable     = false;
                     recoveryIndex = 0;
                 }
                 presses.Clear();
                 labelList.Clear();
                 resetCount++;
                 Reset();
             }
         }
         else
         {
             int[] offsets = { -100, -10, -1, 1, 10, 100 };
             recoveryIndex += offsets[keys.IndexOf(key)];
             if (recoveryIndex < 0)
             {
                 recoveryIndex = 0;
             }
             else if (recoveryIndex > recoveryList.Count - 1)
             {
                 recovery      = false;
                 recoveryIndex = recoveryList.Count - 1;
                 disp.text     = stage.ToString();
             }
             pressable = false;
             Reset();
         }
     }
 }
示例#25
0
    void Awake()
    {
        moduleId = moduleIdCounter++;
        foreach (KMSelectable button in planetButtons)
        {
            button.OnInteract += delegate() { PressPlanet(button); return(false); }
        }
        ;
        starButton.OnInteract += delegate() { PressStar(); return(false); };
        bomb.OnBombExploded   += delegate { HandleDetonation(); };
    }

    void Start()
    {
        StartCoroutine(DisableDummies());
        statusLight.SetActive(false);
        starCcw      = rnd.Range(0, 2) != 0;
        planetSizes  = Enumerable.Range(0, 3).ToList().Shuffle().ToArray();
        planetSpeeds = speeds.ToList().Shuffle().Take(3).ToArray();
        for (int i = 0; i < 3; i++)
        {
            planetSurfaces[i] = rnd.Range(0, 10);
            planetsCcw[i]     = rnd.Range(0, 2) != 0;
            spinningCcw[i]    = rnd.Range(0, 2) != 0;
            Debug.LogFormat("[Exoplanets #{0}] The {1} planet has an angular velocity of {2}.", moduleId, positionNames[i], (int)planetSpeeds[i]);
            Debug.LogFormat("[Exoplanets #{0}] The {1} planet is {2}.", moduleId, positionNames[i], sizeNames[planetSizes[i]]);
        }
        for (int i = 0; i < 3; i++)
        {
            orbits[i] = StartCoroutine(Orbit(pivots[i], i));
        }
        foreach (Renderer planet in planets)
        {
            var ix = Array.IndexOf(planets, planet);
            planet.material.mainTexture = surfaces[planetSurfaces[ix]];
            var sizecord = sizes[planetSizes[ix]];
            planet.transform.localScale           = new Vector3(sizecord, sizecord, sizecord);
            dummyPlanets[ix].transform.localScale = new Vector3(sizecord, sizecord, sizecord);
            planet.transform.localRotation        = rnd.rotation;
            tilts[ix] = StartCoroutine(Spinning(planet, ix));
        }
        starSpinning = StartCoroutine(StarMovement());
        GenerateSolution();
    }

    void GenerateSolution()
    {
        if (!planetsCcw.Contains(true))
        {
            targetPlanet = 0;
            Debug.LogFormat("[Exoplanets #{0}] All planets are oribiting clockwise, so the initial target planet is the one closest to the star.", moduleId);
        }
        else if (!planetsCcw.Contains(false))
        {
            targetPlanet = 2;
            Debug.LogFormat("[Exoplanets #{0}] All planets are orbiting counterclockwise, so the initial target planet is the one farthest from the star.", moduleId);
        }
        else
        {
            if (planetsCcw.Count(x => x) == 2)
            {
                targetPlanet = Array.IndexOf(planetsCcw, planetsCcw.First(x => !x));
            }
            else
            {
                targetPlanet = Array.IndexOf(planetsCcw, planetsCcw.First(x => x));
            }
            Debug.LogFormat("[Exoplanets #{0}] The {1} planet is orbiting {2}, so it is the initial target planet.", moduleId, positionNames[targetPlanet], planetsCcw[targetPlanet] ? "counterclockwise" : "clockwise");
        }
        targetDigit         = planetSurfaces[targetPlanet];
        startingTargetDigit = targetDigit;
        Debug.LogFormat("[Exoplanets #{0}] The initial target digit is {1}.", moduleId, targetDigit);
        tablePosition = (tablePosition + bomb.GetBatteryCount() * (starCcw ? 7 : 1)) % 8;
        Debug.LogFormat("[Exoplanets #{0}] The star is rotating {1} and there are {2} batteries.", moduleId, !starCcw ? "clockwise" : "counterclockwise", bomb.GetBatteryCount());
        tableRing = targetPlanet;
        for (int i = 0; i < 3; i++)
        {
            Modify(i);
        }
        Debug.LogFormat("[Exoplanets #{0}] The final solution is to press the {1} planet on a {2}.", moduleId, positionNames[targetPlanet], targetDigit);
    }

    void Modify(int j)
    {
        var offset = ((int)planetSpeeds[tableRing]);

        if (bomb.GetBatteryHolderCount() != 0)
        {
            offset %= bomb.GetBatteryHolderCount();
        }
        else
        {
            offset %= 5;
        }
        offset       += bomb.GetPortCount();
        tablePosition = (tablePosition + offset * (planetsCcw[tableRing] ? 7 : 1)) % 8;
        var prevPlanet = targetPlanet;
        var prevDigit  = targetDigit;

        Debug.LogFormat("[Exoplanets #{0}] Using rule {1}.", moduleId, table[tableRing][tablePosition]);
        switch (table[tableRing][tablePosition])
        {
        case "A":
            if (planetSizes[targetPlanet] == 2)
            {
                targetPlanet = Array.IndexOf(planetSizes, 0);
            }
            else
            {
                targetPlanet = Array.IndexOf(planetSizes, planetSizes.Where(x => x > planetSizes[targetPlanet]).Min());
            }
            break;

        case "B":
            targetDigit = (targetDigit + startingTargetDigit) % 10;
            break;

        case "C":
            if (planetSizes[targetPlanet] == 0)
            {
                targetPlanet = Array.IndexOf(planetSizes, 2);
            }
            else
            {
                targetPlanet = Array.IndexOf(planetSizes, planetSizes.Where(x => x < planetSizes[targetPlanet]).Max());
            }
            break;

        case "D":
            var differencesMax = new int[3];
            for (int i = 0; i < 3; i++)
            {
                differencesMax[i] = planetSurfaces[targetPlanet] - planetSurfaces[i];
                if (differencesMax[i] < 0)
                {
                    differencesMax[i] *= -1;
                }
            }
            targetPlanet = Array.IndexOf(differencesMax, differencesMax.Max());
            break;

        case "E":
            targetDigit = 9 - targetDigit;
            break;

        case "F":
            if (planetsCcw.Distinct().Count() == 0)
            {
                targetPlanet = 1;
            }
            else
            {
                targetPlanet = Array.IndexOf(planetsCcw, planetsCcw.First(x => x == planetsCcw[targetPlanet]));
            }
            break;

        case "G":
            targetPlanet = Array.IndexOf(planetsCcw, planetsCcw.First(x => x == planetsCcw[targetPlanet]));
            break;

        case "H":
            targetDigit = (targetDigit + bomb.GetSerialNumberNumbers().Sum()) % 10;
            break;

        case "I":
            if (planetSurfaces[targetPlanet] == planetSurfaces.Max())
            {
                targetPlanet = Array.IndexOf(planetSurfaces, planetSurfaces.Min());
            }
            else
            {
                targetPlanet = Array.IndexOf(planetSurfaces, planetSurfaces.Where(x => x > planetSurfaces[targetPlanet]).Min());
            }
            break;

        case "J":
            targetDigit = (targetDigit + bomb.GetModuleNames().Count()) % 10;
            break;

        case "K":
            targetPlanet--;
            if (targetPlanet == -1)
            {
                targetPlanet = 2;
            }
            break;

        case "L":
            targetDigit = (targetDigit + bomb.GetSerialNumberNumbers().First()) % 10;
            break;

        case "M":
            var differencesMin = new int[3];
            for (int i = 0; i < 3; i++)
            {
                differencesMin[i] = planetSurfaces[targetPlanet] - planetSurfaces[i];
                if (differencesMin[i] < 0)
                {
                    differencesMin[i] *= -1;
                }
            }
            var differencesMinList = differencesMin.ToList();
            differencesMinList.Remove(differencesMinList[targetPlanet]);
            targetPlanet = Array.IndexOf(differencesMin, differencesMinList.Min());
            break;

        case "N":
            targetDigit = (targetDigit + bomb.GetSerialNumberNumbers().ToArray()[1]) % 10;
            break;

        case "O":
            if (targetPlanet == Array.IndexOf(planetSpeeds, planetSpeeds.Min()))
            {
                targetPlanet = Array.IndexOf(planetSpeeds, planetSpeeds.Max());
            }
            else
            {
                targetPlanet = Array.IndexOf(planetSpeeds, planetSpeeds.Where(x => x < planetSpeeds[targetPlanet]).Max());
            }
            break;

        case "P":
            targetPlanet = targetPlanet == 0 ? 2 : 0;
            break;

        case "Q":
            targetDigit = (targetDigit + bomb.GetPortCount()) % 10;
            break;

        case "R":
            targetDigit = (targetDigit + 5) % 10;
            break;

        case "S":
            if (targetPlanet == Array.IndexOf(planetSpeeds, planetSpeeds.Max()))
            {
                targetPlanet = Array.IndexOf(planetSpeeds, planetSpeeds.Min());
            }
            else
            {
                targetPlanet = Array.IndexOf(planetSpeeds, planetSpeeds.Where(x => x > planetSpeeds[targetPlanet]).Min());
            }
            break;

        case "T":
            targetDigit = (targetDigit + bomb.GetSerialNumberNumbers().Last()) % 10;
            break;

        case "U":
            targetPlanet = (targetPlanet + 1) % 3;
            break;

        case "V":
            targetDigit = (targetDigit + bomb.GetBatteryCount()) % 10;
            break;

        case "W":
            var indicators = bomb.GetIndicators().SelectMany(x => x.ToUpperInvariant().ToCharArray());
            var count      = 0;
            foreach (Char c in indicators)
            {
                if (!"AEIOU".Contains(c))
                {
                    count++;
                }
            }
            targetDigit = (targetDigit + count) % 10;
            break;

        default:
            if (planetSurfaces[targetPlanet] == planetSurfaces.Min())
            {
                targetPlanet = Array.IndexOf(planetSurfaces, planetSurfaces.Max());
            }
            else
            {
                targetPlanet = Array.IndexOf(planetSurfaces, planetSurfaces.Where(x => x < planetSurfaces[targetPlanet]).Min());
            }
            break;
        }
        if (targetPlanet != prevPlanet)
        {
            Debug.LogFormat("[Exoplanets #{0}] The target planet is now the {1} planet.", moduleId, positionNames[targetPlanet]);
        }
        if (targetDigit != prevDigit)
        {
            Debug.LogFormat("[Exoplanets #{0}] The target digit is now {1}.", moduleId, targetDigit);
        }
        if (j != 2)
        {
            tableRing--;
            if (tableRing == -1)
            {
                tableRing = 2;
            }
            Debug.LogFormat("[Exoplanets #{0}] Moving inward...", moduleId);
        }
    }

    void PressPlanet(KMSelectable button)
    {
        var ix            = Array.IndexOf(planetButtons, button);
        var submittedTime = ((int)bomb.GetTime()) % 10;
        var oridinals     = new string[] { "1st", "2nd", "3rd" };

        Debug.LogFormat("[Exoplanets #{0}] You pressed the {1} planet.", moduleId, oridinals[ix]);
        var planetCorrect = targetPlanet == ix;
        var timeCorrect   = targetDigit == submittedTime;

        if (planetCorrect && timeCorrect)
        {
            module.HandlePass();
            moduleSolved = true;
            if (ambianceRef != null)
            {
                ambianceRef.StopSound();
                ambianceRef = null;
            }
            Debug.LogFormat("[Exoplanets #{0}] That was correct. Module solved!", moduleId);
            audio.PlaySoundAtTransform("explosion", transform);
            StartCoroutine(SolveAnimation());
        }
        else
        {
            if (!planetCorrect && !timeCorrect)
            {
                Debug.LogFormat("[Exoplanets #{0}] Neither the planet nor the time were correct.", moduleId);
            }
            else if (!planetCorrect && timeCorrect)
            {
                Debug.LogFormat("[Exoplanets #{0}] The planet wasn’t correct, but the time was.", moduleId);
            }
            else
            {
                Debug.LogFormat("[Exoplanets #{0}] The planet was correct, but the time wasn’t.", moduleId);
            }
            module.HandleStrike();
            Debug.LogFormat("[Exoplanets #{0}] Strike!", moduleId);
        }
    }

    void PressStar()
    {
        if (isMoving && !moduleSolved)
        {
            return;
        }
        if (moduleSolved)
        {
            return;
        }
        else
        {
            foreach (Renderer planet in planets)
            {
                var ix = Array.IndexOf(planets, planet);
                if (!planetsHidden)
                {
                    savedPositions[ix] = planet.transform.localPosition;
                }
                StartCoroutine(MovePlanets(planet, ix));
            }
        }
    }

    IEnumerator MovePlanets(Renderer planet, int ix)
    {
        isMoving = true;
        var elapsed  = 0f;
        var duration = 1f;

        while (elapsed < duration)
        {
            if (!planetsHidden)
            {
                planet.transform.localPosition = new Vector3(Easing.InOutQuad(elapsed, savedPositions[ix].x, 0, duration), Easing.InOutQuad(elapsed, savedPositions[ix].y, .0314f, duration), Easing.InOutQuad(elapsed, savedPositions[ix].z, 0, duration));
            }
            else
            {
                planet.transform.localPosition = new Vector3(Easing.InOutQuad(elapsed, 0, savedPositions[ix].x, duration), Easing.InOutQuad(elapsed, .0314f, savedPositions[ix].y, duration), Easing.InOutQuad(elapsed, 0, savedPositions[ix].z, duration));
            }
            yield return(null);

            elapsed += Time.deltaTime;
        }
        isMoving      = false;
        planetsHidden = !planetsHidden;
    }

    IEnumerator Orbit(Transform pivot, int ix)
    {
        var startAngle = rnd.Range(0, 360);
        var elapsed    = 0f;
        var speed      = planetSpeeds[ix];

        if (planetsCcw[ix])
        {
            speed = -speed;
        }
        while (true)
        {
            pivot.localEulerAngles = new Vector3(0, elapsed / speed * 360 + startAngle, 0);
            yield return(null);

            elapsed += Time.deltaTime;
        }
    }

    IEnumerator Spinning(Renderer planet, int ix)
    {
        var startAngle = rnd.Range(0, 360);
        var pX = planet.transform.localEulerAngles.x;
        var pZ = planet.transform.localEulerAngles.z;
        var elapsed = 0f;
        var speed = new float[] { 4f, 6f, 7f, 8f }.PickRandom();

        if (!planetsCcw[ix])
        {
            speed = -speed;
        }
        while (true)
        {
            planet.transform.localEulerAngles = new Vector3(pX, elapsed / speed * 360 + startAngle, pZ);
            yield return(null);

            elapsed += Time.deltaTime;
        }
    }

    IEnumerator StarMovement()
    {
        var starScrollSpeed = .02f;

        if (starCcw)
        {
            starScrollSpeed = -starScrollSpeed;
        }
        while (true)
        {
            var offsetStar = Time.time * starScrollSpeed;
            star.material.mainTextureOffset = new Vector2(offsetStar, 0f);
            yield return(null);
        }
    }

    IEnumerator BackgroundMoveMent()
    {
        var horizontalScrollSpeed = .001f;
        var verticalScrollSpeed   = .001f;

        while (true)
        {
            var offsetY = Time.time * horizontalScrollSpeed;
            var offsetZ = Time.time * verticalScrollSpeed;
            background.material.mainTextureOffset = new Vector2(offsetY, offsetZ);
            yield return(null);
        }
    }

    IEnumerator SolveAnimation()
    {
        var elapsed  = 0f;
        var duration = 6f;

        for (int i = 0; i < 3; i++)
        {
            savedPositions[i] = planets[i].transform.localPosition;
            StopCoroutine(orbits[i]);
            StopCoroutine(tilts[i]);
        }
        StopCoroutine(starSpinning);
        while (elapsed < duration)
        {
            var fade = Mathf.Lerp(1f, 0f, elapsed / duration);
            foreach (Renderer planet in planets)
            {
                planet.material.color = new Color(fade, fade, fade);
            }
            yield return(null);

            elapsed += Time.deltaTime;
        }
        for (int i = 0; i < 3; i++)
        {
            planets[i].gameObject.SetActive(false);
            dummyPlanets[i].transform.SetParent(pivots[i], false);
            dummyPlanets[i].gameObject.SetActive(true);
            dummyPlanets[i].transform.localPosition = savedPositions[i];
        }
        elapsed  = 0f;
        duration = 3f;
        while (elapsed < duration)
        {
            var fade = Mathf.Lerp(1f, 0f, elapsed / duration);
            star.material.color = new Color(fade, fade, fade);
            yield return(null);

            elapsed += Time.deltaTime;
        }
        star.gameObject.SetActive(false);
        dummyStar.gameObject.SetActive(true);
        elapsed  = 0f;
        duration = 3.5f;
        while (elapsed < duration)
        {
            var fade = Mathf.Lerp(1f, 0f, elapsed / duration);
            dummyStar.material.color = new Color(0f, 0f, 0f, fade);
            foreach (Renderer planet in dummyPlanets)
            {
                planet.material.color = new Color(0f, 0f, 0f, fade);
            }
            yield return(null);

            elapsed += Time.deltaTime;
        }
        dummyStar.gameObject.SetActive(false);
        foreach (Renderer planet in dummyPlanets)
        {
            planet.gameObject.SetActive(false);
        }
        yield return(new WaitForSeconds(.75f));

        background.material.color = solveColor;
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform);
    }

    IEnumerator DisableDummies()
    {
        yield return(null);

        ambianceRef = audio.PlaySoundAtTransformWithRef("ambiance", star.transform);
        dummyStar.gameObject.SetActive(false);
        foreach (Renderer planet in dummyPlanets)
        {
            planet.gameObject.SetActive(false);
        }
    }

    void HandleDetonation()
    {
        StopAllCoroutines();
        if (ambianceRef != null)
        {
            ambianceRef.StopSound();
            ambianceRef = null;
        }
    }
示例#26
0
    bool Move(int y, int x)
    {
        bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);

        if (moduleStage == 2)
        {
            currentMazeX += x;
            currentMazeY += y;

            //adding 8 before performing modulo because C# cannot correctly modulo negatives
            currentMazeX = (currentMazeX + 8) % 8;
            currentMazeY = (currentMazeY + 8) % 8;

            currentValue += maze[currentMazeY][currentMazeX];

            if (movedOnce)
            {
                if (currentValue == goalValue)
                {
                    Debug.LogFormat("[Mazematics #{0}] Moved to: {1}{2} (cell is equal to {3})", _moduleId, logCoordinates[currentMazeX], (startMazeY + 1), maze[currentMazeY][currentMazeX]);
                    Debug.LogFormat("[Mazematics #{0}] Current value changed from {1} --> {2}", _moduleId, currentValue - maze[currentMazeY][currentMazeX], currentValue);
                    Debug.LogFormat("[Mazematics #{0}] SOLVED!", _moduleId);

                    bombAudio.PlaySoundAtTransform("SolveSynth", transform);
                    moduleStage = 3;
                    GetComponent <KMBombModule>().HandlePass();
                }
                else if (currentValue < 0 || currentValue > 49)
                {
                    Debug.LogFormat("[Mazematics #{0}] STRIKE! Out of bounds - maze will not move", _moduleId);
                    Debug.LogFormat("[Mazematics #{0}] Attempted to move to: {1}{2} (cell is equal to {3})", _moduleId, logCoordinates[currentMazeX], (startMazeY + 1), maze[currentMazeY][currentMazeX]);
                    Debug.LogFormat("[Mazematics #{0}] Current value would have changed from {1} --> {2}", _moduleId, currentValue - maze[currentMazeY][currentMazeX], currentValue);

                    currentValue -= maze[currentMazeY][currentMazeX];
                    currentMazeX -= x;
                    currentMazeY -= y;

                    currentMazeX = (currentMazeX + 8) % 8;
                    currentMazeY = (currentMazeY + 8) % 8;

                    Debug.LogFormat("[Mazematics #{0}] Current value must be within 0-49. Maze not moved, coordinate is still {1}{2}, current value is still {3}", _moduleId, logCoordinates[currentMazeX], (startMazeY + 1), currentValue);

                    GetComponent <KMBombModule>().HandleStrike();
                }
                else if (bannedValues.Contains(currentValue) == true)
                {
                    Debug.LogFormat("[Mazematics #{0}] STRIKE! Restricted value - maze will still move", _moduleId);
                    Debug.LogFormat("[Mazematics #{0}] Moved to: {1}{2} (cell is equal to {3})", _moduleId, logCoordinates[currentMazeX], (startMazeY + 1), maze[currentMazeY][currentMazeX]);
                    Debug.LogFormat("[Mazematics #{0}] Current value changed from {1} --> {2}", _moduleId, currentValue - maze[currentMazeY][currentMazeX], currentValue);

                    GetComponent <KMBombModule>().HandleStrike();
                }
                else
                {
                    Debug.LogFormat("[Mazematics #{0}] Moved to: {1}{2} (cell is equal to {3})", _moduleId, logCoordinates[currentMazeX], (startMazeY + 1), maze[currentMazeY][currentMazeX]);
                    Debug.LogFormat("[Mazematics #{0}] Current value changed from {1} --> {2}", _moduleId, currentValue - maze[currentMazeY][currentMazeX], currentValue);
                }
            }
            else
            {
                Debug.LogFormat("[Mazematics #{0}] Starting maze coordinate: {1}{2} (cell is equal to {3})", _moduleId, logCoordinates[startMazeX], (startMazeY + 1), maze[startMazeY][startMazeX]);
                Debug.LogFormat("[Mazematics #{0}] Current value changed from {1} --> {2}", _moduleId, startValue, currentValue - maze[currentMazeY][currentMazeX]);

                Debug.LogFormat("[Mazematics #{0}] Moved to: {1}{2} (cell is equal to {3})", _moduleId, logCoordinates[currentMazeX], (startMazeY + 1), maze[currentMazeY][currentMazeX]);
                Debug.LogFormat("[Mazematics #{0}] Current value changed from {1} --> {2}", _moduleId, currentValue - maze[currentMazeY][currentMazeX], currentValue);
            }

            movedOnce = true;
        }
        else
        {
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.SelectionTick, transform);
        }

        return(false);
    }
示例#27
0
 void PressButton(KMSelectable pressed)
 {
     if (moduleSolved != true)
     {
         if (colormode != true && striking != true)
         {
             if (pressed != buttons[4])
             {
                 if (firstpress == false)
                 {
                     firstpress = true;
                     timer      = StartCoroutine(timerThing());
                 }
                 else if (currentstates[Array.IndexOf(buttons, pressed)] != true)
                 {
                     time = 0;
                 }
             }
             if (pressed == buttons[0] && currentstates[0] != true)
             {
                 pressed.AddInteractionPunch(0.25f);
                 audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, pressed.transform);
                 StartCoroutine(buttonDown(0));
             }
             else if (pressed == buttons[1] && currentstates[1] != true)
             {
                 pressed.AddInteractionPunch(0.25f);
                 audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, pressed.transform);
                 StartCoroutine(buttonDown(1));
             }
             else if (pressed == buttons[2] && currentstates[2] != true)
             {
                 pressed.AddInteractionPunch(0.25f);
                 audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, pressed.transform);
                 StartCoroutine(buttonDown(2));
             }
             else if (pressed == buttons[3] && currentstates[3] != true)
             {
                 pressed.AddInteractionPunch(0.25f);
                 audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, pressed.transform);
                 StartCoroutine(buttonDown(3));
             }
             else if (pressed == buttons[4] && firstpress == true)
             {
                 pressed.AddInteractionPunch(0.25f);
                 audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, pressed.transform);
                 StopCoroutine(timer);
                 Debug.LogFormat("[Kooky Keypad #{0}] Submitted the following buttons...", moduleId);
                 Debug.LogFormat("[Kooky Keypad #{0}] Top Left: {1} | Top Right: {2} | Bottom Left: {3} | Bottom Right: {4}", moduleId, currentstates[0], currentstates[1], currentstates[2], currentstates[3]);
                 if (checkBoolsFinal())
                 {
                     Debug.LogFormat("[Kooky Keypad #{0}] The submitted buttons were correct! Module Disarmed!", moduleId);
                     leds[0].material = mats[12];
                     leds[1].material = mats[12];
                     leds[2].material = mats[12];
                     leds[3].material = mats[12];
                     moduleSolved     = true;
                     GetComponent <KMBombModule>().HandlePass();
                 }
                 else
                 {
                     Debug.LogFormat("[Kooky Keypad #{0}] The submitted buttons were incorrect! Strike! Module Resetting...", moduleId);
                     StartCoroutine(strike());
                     GetComponent <KMBombModule>().HandleStrike();
                 }
             }
         }
     }
 }
    void KeyPress(KMSelectable key)
    {
        if (moduleSolved)
        {
            return;
        }

        //Makes the bomb move when you press it
        key.AddInteractionPunch();

        //Makes a sound when you press the button.
        audio.PlaySoundAtTransform("keyStroke", transform);

        //As the value of each number on the keypad is equivalent to their position in the array, I can get the button's position and use that to work out it's value.
        int number = Array.IndexOf(keypad, key);

        //If CLR is pressed
        if (number == 12)
        {
            //Clear the screen
            answer.text = "";
            decpoint    = false;
        }
        //If OK is pressed
        else if (number == 11)
        {
            //If they answered correctly
            if (answer.text == solution.ToString())
            {
                audio.PlaySoundAtTransform("ding", transform);
                Debug.LogFormat("[Reverse Polish Notation #{0}] You submitted {1}, when the answer was {2}. Correct.", moduleId, answer.text, solution.ToString());
                answer.text = "";
                decpoint    = false;
                //Increases the stage by one, which then causes the subrouting to generate a new stage
                stage += 1;
            }
            //If they answered incorrectly
            else
            {
                //Gives a strike
                GetComponent <KMBombModule>().HandleStrike();
                audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.Strike, transform);
                Debug.LogFormat("[Reverse Polish Notation #{0}] You submitted {1}, when the answer was {2}. Incorrect.", moduleId, answer.text, solution.ToString());
                answer.text = "";
                decpoint    = false;
            }
        }
        //If . was pressed
        else if (number == 10)
        {
            //This if statement stops anyone putting 2 . in their answer
            if (!decpoint)
            {
                answer.text += ".";
                decpoint     = true;
            }
        }
        else
        {
            //Upper limit for the text size to stop text going into other modules
            //(Looking at you Xatra)
            if (answer.text.Length < 10)
            {
                //Adds the number to the end of the sting
                answer.text += number.ToString();
            }
        }
    }
示例#29
0
    private void Start()
    {
        moduleId = moduleIdCounter++;

        NextModule.OnInteract += delegate
        {
            if (moduleSolved || strikeActive)
            {
                return(false);
            }
            NextModule.AddInteractionPunch();
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, NextModule.transform);
            if (FailswitchPressed)
            {
                FailswitchPressed = false;
                StartCoroutine(FailSwitchAborted());
                return(false);
            }
            if (!nextStage)
            {
                StartCoroutine(StrikeHandler());
                return(false);
            }

            if (failsolve)
            {
                StartCoroutine(UnlockMystery());
                return(false);
            }

            Debug.LogFormat(@"[Mystery Module #{0}] Advancing to the next stage after solving {1}", moduleId, keyModules[0].ModuleDisplayName);
            keyModules.RemoveAt(0);
            nextStage = false;
            SetLED(255, 0, 0);
            SetKey();
            return(false);
        };

        Failswitch.OnInteract += delegate
        {
            if (moduleSolved || strikeActive)
            {
                return(false);
            }
            Failswitch.AddInteractionPunch();
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Failswitch.transform);
            if (FailswitchPressed)
            {
                StartCoroutine(UnlockMystery());
                Debug.LogFormat(@"[Mystery Module #{0}] 'Failswitch' was pressed - Remaining time was cut by a quarter", moduleId);
                if (failsolve)
                {
                    setScreen("Why would you do that!?", 255, 0, 0);
                }
                TimeRemaining.FromModule(Module, Bomb.GetTime() * 0.75f);
                return(false);
            }
            FailswitchPressed = true;
            Debug.LogFormat(@"[Mystery Module #{0}] Defuser was asked if he really wants to press the Fail Switch", moduleId);
            setScreen("Are you sure?", 255, 0, 0);
            return(false);
        };

        StartCoroutine(Setup());
    }
示例#30
0
文件: boxing.cs 项目: eXish/Boxing
    void Awake()
    {
        moduleId = moduleIdCounter++;
        boxingGlove.OnInteract   += delegate() { PressBoxingGlove(); return(false); };
        hireButton.OnInteract    += delegate() { Hire(); return(false); };
        abstainButton.OnInteract += delegate() { Abstain(); return(false); };
        foreach (KMSelectable arrowButton in arrowButtons)
        {
            arrowButton.OnInteract += delegate() { PressArrowButton(arrowButton); return(false); }
        }
        ;
        GetComponent <KMBombModule>().OnActivate += OnActivate;
    }

    void Start()
    {
        var dupliates = possibleSubstituteNames.Where(s => !possibleSubstituteNames.Distinct().Contains(s)).ToArray();

        foreach (string duplicate in dupliates)
        {
            Debug.LogFormat("[Boxing #{0}] {1} is a duplicate.", moduleId, duplicate);
        }
        contestantStrengths = Enumerable.Range(0, 5).ToList().Shuffle().ToArray();
        contestantIndices   = Enumerable.Range(0, 25).ToList().Shuffle().Take(5).ToArray();
        blueContestant      = rnd.Range(0, 5);
        string[] ordinals = new string[5] {
            "1st", "2nd", "3rd", "4th", "5th"
        };
        int         count         = 0;
        List <Char> allCharacters = new List <Char>();
        var         tempString    = "";

        for (int i = 0; i < 5; i++)
        {
            lastNameIndices[i]           = Array.IndexOf(possibleLastNames, possibleLastNames.PickRandom());
            substituteIndices[i]         = Array.IndexOf(possibleSubstituteNames, possibleSubstituteNames.PickRandom());
            substituteLastNameIndices[i] = Array.IndexOf(possibleLastNames, possibleLastNames.PickRandom());
            tempString += possibleNames[contestantIndices[i]];
            tempString += possibleLastNames[lastNameIndices[i]];
            tempString += possibleSubstituteNames[substituteIndices[i]];
            tempString += possibleLastNames[substituteLastNameIndices[i]];
        }
        tempString = tempString.ToUpperInvariant();
        for (int i = 0; i < 5; i++)
        {
            var value1         = contestantStrengths[contestantIndices[i] / 5];
            var value2         = contestantStrengths[contestantIndices[i] % 5];
            var contestantChar = alphabet[5 * value1 + value2];
            allCharacters.Add(contestantChar);
            var addCount = tempString.Count(c => c == contestantChar);
            count += addCount;
            Debug.LogFormat("[Boxing #{0}] The {1} contestant is {2} {3}, with punch strength {4}, and his substitute is {5} {6}. His base 5 pair forms the letter {7}, so {8} is added to the total.", moduleId, ordinals[i], possibleNames[contestantIndices[i]], possibleLastNames[lastNameIndices[i]], contestantStrengths[i], possibleSubstituteNames[substituteIndices[i]], possibleLastNames[substituteLastNameIndices[i]], contestantChar, addCount);
        }
        count += Array.IndexOf(alphabet, allCharacters[blueContestant]);
        Debug.LogFormat("[Boxing #{0}] {1} has the blue name, so {2} is added.", moduleId, possibleNames[contestantIndices[blueContestant]], Array.IndexOf(alphabet, allCharacters[blueContestant]));
        int unmodifiedCount = count;

        count %= 6;
        Debug.LogFormat("[Boxing #{0}] The count is {1}, modulo 6 is {2}.", moduleId, unmodifiedCount, count % 6);
        if (count == 5)
        {
            solution = 10;
            Debug.LogFormat("[Boxing #{0}] Every contestant is on steroids. Abstain from participating.", moduleId);
        }
        else
        {
            if (count == 0)
            {
                solution = Array.IndexOf(contestantStrengths, 4);
            }
            else
            {
                int subtracted = 5 - count;
                solution = Array.IndexOf(contestantStrengths, subtracted);
            }
            Debug.LogFormat("[Boxing #{0}] The strongest contestant not on steroids is {1}.", moduleId, possibleNames[contestantIndices[solution]]);
        }
        screenTexts[0].text = "";
        screenTexts[1].text = "";
        screenTexts[2].text = "";
        screenTexts[3].text = "";

        /**screenTexts[0].text = possibleNames[contestantIndices[0]];
         *      screenTexts[1].text = possibleLastNames[lastNameIndices[0]];
         *      screenTexts[2].text = possibleSubstituteNames[substituteIndices[0]];
         *      screenTexts[3].text = possibleLastNames[substituteLastNameIndices[0]];
         *      foreach (TextMesh screenText in screenTexts)
         *              screenText.color = blueContestant == 0 ? textColors[1] : textColors[0];*/
    }

    void OnActivate()
    {
        string[] oldMessages = new string[4] {
            screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
        };
        string[] newMessages = new string[4] {
            possibleNames[contestantIndices[chosenContestant]], possibleLastNames[lastNameIndices[chosenContestant]], possibleSubstituteNames[substituteIndices[chosenContestant]], possibleLastNames[substituteLastNameIndices[chosenContestant]]
        };
        for (int i = 0; i < 4; i++)
        {
            StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
        }
    }

    void PressBoxingGlove()
    {
        if (moduleSolved || animating.Contains(true))
        {
            return;
        }
        boxingGlove.AddInteractionPunch(strengths[contestantStrengths[chosenContestant]]);
        audio.PlaySoundAtTransform("punch" + rnd.Range(0, 6).ToString(), boxingGlove.transform);
    }

    void PressArrowButton(KMSelectable button)
    {
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, button.transform);
        button.AddInteractionPunch(.5f);
        if (moduleSolved || animating.Contains(true))
        {
            return;
        }
        int[] offsets = new int[2] {
            -1, 1
        };
        int ix = Array.IndexOf(arrowButtons, button);

        if (!(chosenContestant == 0 && ix == 0) && !(chosenContestant == 4 && ix == 1))
        {
            chosenContestant += offsets[ix];
            string[] oldMessages = new string[4] {
                screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
            };
            string[] newMessages = new string[4] {
                possibleNames[contestantIndices[chosenContestant]], possibleLastNames[lastNameIndices[chosenContestant]], possibleSubstituteNames[substituteIndices[chosenContestant]], possibleLastNames[substituteLastNameIndices[chosenContestant]]
            };
            for (int i = 0; i < 4; i++)
            {
                StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
            }
        }
        else
        {
            audio.PlaySoundAtTransform("error", button.transform);
        }
    }

    void Hire()
    {
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, hireButton.transform);
        hireButton.AddInteractionPunch(.75f);
        if (moduleSolved || animating.Contains(true))
        {
            return;
        }
        if (chosenContestant == solution)
        {
            module.HandlePass();
            Debug.LogFormat("[Boxing #{0}] You submitted {1}. That is correct. Module solved!", moduleId, possibleNames[contestantIndices[chosenContestant]]);
            moduleSolved = true;
            string[] oldMessages = new string[4] {
                screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
            };
            string[] newMessages = new string[4] {
                "Ready", "for", "the", "match!"
            };
            for (int i = 0; i < 4; i++)
            {
                StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
            }
            audio.PlaySoundAtTransform("bell", hireButton.transform);
        }
        else
        {
            module.HandleStrike();
            Debug.LogFormat("[Boxing #{0}] You submitted {1}. That is incorrect. Strike!", moduleId, possibleNames[contestantIndices[chosenContestant]]);
            audio.PlaySoundAtTransform("strike", hireButton.transform);
        }
    }

    void Abstain()
    {
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, abstainButton.transform);
        abstainButton.AddInteractionPunch(.75f);
        if (moduleSolved || animating.Contains(true))
        {
            return;
        }
        if (solution == 10)
        {
            module.HandlePass();
            Debug.LogFormat("[Boxing #{0}] You abstained from participating. That is correct. Module solved!", moduleId);
            audio.PlaySoundAtTransform("abstain", abstainButton.transform);
            moduleSolved = true;
            string[] oldMessages = new string[4] {
                screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
            };
            string[] newMessages = new string[4] {
                "No", "contest", "this", "time..."
            };
            for (int i = 0; i < 4; i++)
            {
                StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
            }
        }
        else
        {
            module.HandleStrike();
            Debug.LogFormat("[Boxing #{0}] You abstained from participating. That is incorrect. Strike!", moduleId);
            audio.PlaySoundAtTransform("strike", abstainButton.transform);
        }
    }

    IEnumerator CycleText(TextMesh display, string oldMessage, string newMessage)
    {
        animating[Array.IndexOf(screenTexts, display)] = true;
        string currentMessage = oldMessage;
        int    messageLength  = currentMessage.Length;

        for (int i = 0; i < messageLength; i++)
        {
            currentMessage = currentMessage.Remove(currentMessage.Length - 1);
            display.text   = currentMessage;
            audio.PlaySoundAtTransform("beep", display.transform);
            yield return(new WaitForSeconds(.05f));
        }
        currentMessage = "";
        if (!moduleSolved)
        {
            display.color = chosenContestant == blueContestant ? textColors[1] : textColors[0];
        }
        else
        {
            display.color = solveColor;
        }
        for (int i = 0; i < newMessage.Length; i++)
        {
            currentMessage = currentMessage + newMessage[i];
            display.text   = currentMessage;
            audio.PlaySoundAtTransform("beep", display.transform);
            yield return(new WaitForSeconds(.05f));
        }
        animating[Array.IndexOf(screenTexts, display)] = false;
    }