コード例 #1
0
        public void Initialize()
        {
            OnMapKeyGroup       = new ListKeyGroup(keyboard);
            OnMapKeyGroup.Brush = new SolidColorBrush(Color.Orange);

            OffMapKeyGroup       = new ListKeyGroup(keyboard);
            OffMapKeyGroup.Brush = new SolidColorBrush(Color.Blue);

            BoardState = new bool[4, 10];

            // add all of game map to key group
            for (int row = 0; row < 4; row++)
            {
                for (int col = 0; col < 10; col++)
                {
                    OnMapKeyGroup.AddKey(GameMap[row, col]);
                    BoardState[row, col] = true;
                }
            }

            ToggleKey(Random.Next(4), Random.Next(10));

            MolesKeyGroup       = new ListKeyGroup(keyboard);
            MolesKeyGroup.Brush = new SolidColorBrush(Color.Yellow);

            WinScreen = false;
        }
コード例 #2
0
        public void Initialize()
        {
            //clear the board
            keyboard.Brush = new SolidColorBrush(Color.Purple);
            keyboard.Update();

            RedKeyGroup       = new ListKeyGroup(keyboard);
            RedKeyGroup.Brush = new SolidColorBrush(Color.Red);

            BlueKeyGroup       = new ListKeyGroup(keyboard);
            BlueKeyGroup.Brush = new SolidColorBrush(Color.Blue);

            YellowKeyGroup       = new ListKeyGroup(keyboard);
            YellowKeyGroup.Brush = new SolidColorBrush(Color.Yellow);

            GreenKeyGroup       = new ListKeyGroup(keyboard);
            GreenKeyGroup.Brush = new SolidColorBrush(Color.Green);

            for (int num = 0; num < 10; num++)
            {
                RedKeyGroup.AddKey(RedKeys[num]);
                GreenKeyGroup.AddKey(GreenKeys[num]);
                BlueKeyGroup.AddKey(BlueKeys[num]);
                YellowKeyGroup.AddKey(YellowKeys[num]);
            }

            keyboard.Update();
            Level = 0;
        }
コード例 #3
0
        public void Initialize()
        {
            //clear the board
            keyboard.Brush = new SolidColorBrush(Color.DeepSkyBlue);
            keyboard.Update();

            ActiveHealthKeyGroup       = new ListKeyGroup(keyboard);
            ActiveHealthKeyGroup.Brush = new SolidColorBrush(Color.Red);

            InactiveHealthKeyGroup       = new ListKeyGroup(keyboard);
            InactiveHealthKeyGroup.Brush = new SolidColorBrush(Color.White);

            GameMapKeyGroup       = new ListKeyGroup(keyboard);
            GameMapKeyGroup.Brush = new SolidColorBrush(Color.ForestGreen);

            ScoreKeyGroup       = new ListKeyGroup(keyboard);
            ScoreKeyGroup.Brush = new SolidColorBrush(Color.Purple);

            SingleScoreKeyGroup       = new ListKeyGroup(keyboard);
            SingleScoreKeyGroup.Brush = new SolidColorBrush(Color.Purple);

            // add all of game map to key group
            for (int row = 0; row < 3; row++)
            {
                for (int col = 0; col < 10; col++)
                {
                    GameMapKeyGroup.AddKey(GameMap[row, col]);
                }
            }

            MolesKeyGroup       = new ListKeyGroup(keyboard);
            MolesKeyGroup.Brush = new SolidColorBrush(Color.Yellow);

            Moles = new List <Mole>();
            SpawnMole();

            Health         = 10;
            Score          = 0;
            LoseScreen     = false;
            MoleSpawnTimer = 25;
            NextMole       = 25;
        }
コード例 #4
0
        // Crazy long function to print a string
        private static void writeSentence(CorsairKeyboard keyboard, string message, Color color1, Color color2, int typingTime)
        {
            ListKeyGroup      keyGroup1   = new ListKeyGroup(keyboard);
            List <MessageKey> activeKeys1 = new List <MessageKey>();

            keyGroup1.Brush = new SolidColorBrush(color1);

            ListKeyGroup      keyGroup2   = new ListKeyGroup(keyboard);
            List <MessageKey> activeKeys2 = new List <MessageKey>();

            keyGroup2.Brush = new SolidColorBrush(color2);

            int messageIndex = 0;

            foreach (char c in message)
            {
                Char   upperChar = Char.ToUpper(c);
                string c1        = modifyChar(upperChar);

                CorsairKey newKey = keyboard[GetKeyboardID(c1)];
                // Change colors if repeating character
                // Check for space bar and characters. How to map charactes
                if (keyGroup1.ContainsKey(newKey))
                {
                    // Add this char to the secondary key group
                    activeKeys2.Add(new MessageKey(c1, messageIndex));
                    keyGroup2.AddKey(newKey);

                    // Remove Char from other keygroup list
                    activeKeys1.RemoveAll(s => s.key == c1);
                    keyGroup1.RemoveKey(newKey);
                }
                else
                {
                    // Add this char to the primary key group
                    activeKeys1.Add(new MessageKey(c1, messageIndex));
                    keyGroup1.AddKey(newKey);
                    if (keyGroup2.ContainsKey(newKey))
                    {
                        // Remove Key from other keygroup list
                        activeKeys2.RemoveAll(s => s.key == c1);
                        keyGroup2.RemoveKey(newKey);
                    }
                }


                if (activeKeys1.Count > 0 && messageIndex - activeKeys1[0].index > 3)
                {
                    // Remove this key!
                    keyGroup1.RemoveKey(keyboard[GetKeyboardID(activeKeys1[0].key)]);
                    activeKeys1.RemoveAt(0);
                }
                if (activeKeys2.Count > 0 && messageIndex - activeKeys2[0].index > 3)
                {
                    // Remove this key!
                    keyGroup2.RemoveKey(keyboard[GetKeyboardID(activeKeys2[0].key)]);
                    activeKeys2.RemoveAt(0);
                }


                messageIndex++;
                keyboard.Update();
                Wait(typingTime);
            }
            keyGroup1.Detach();
            keyGroup2.Detach();
        }