public LettersGameConfigPage(string itemId, KinectSensorChooser sensorChooser)
 {
     InitializeComponent();
     SensorChooser = sensorChooser;
     Config = new LettersGameConfig();
     DataContext = Config;
 }
Пример #2
0
 public MainWindow(LettersGameConfig config)
 {
     InitializeComponent();
     Loaded += OnLoaded;
     KeyDown += OnKeyDown;
     Config = config;
     Config.WindowHeight = Height;
     Config.WindowWidth = Width;
 }
Пример #3
0
        public Game(LettersGameConfig config)
        {
            _config = config;
            int numOfLetters = config.LettersCount;
            if (config.CurrentLevel == 1)
            {
                using (ResourceSet resourceSet = Resources.Letters.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true))
                {
                    var allLetters = new List<Letter>();
                    foreach (DictionaryEntry item in resourceSet)
                    {
                        allLetters.Add(new Letter((string)item.Value));
                    }
                    var rand = new Random();
                    SmallLetters = new List<Letter>();
                    BigLetters = new List<Letter>();
                    for (var i = 0; i < numOfLetters; i++)
                    {
                        var index = rand.Next(allLetters.Count);
                        var letter = allLetters[index];
                        SmallLetters.Add(letter);
                        BigLetters.Add(letter);
                        allLetters.RemoveAt(index);
                    }
                    Resources.Letters.ResourceManager.ReleaseAllResources();
                    LettersLeft = numOfLetters;
                }
            }
            if (config.CurrentLevel == 2)
            {
                using (ResourceSet resourceSet = Resources.Letters.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true))
                {
                    var allLetters = new List<Letter>();
                    foreach (DictionaryEntry item in resourceSet)
                    {
                        allLetters.Add(new Letter((string)item.Value));
                    }
                    var rand = new Random();
                    SmallLetters = new List<Letter>();
                    Trolleys = new List<Letter>();

                    for (var i = 0; i < config.TrolleysCount; i++)
                    {
                        var index = rand.Next(allLetters.Count);
                        var letter = allLetters[index];
                        SmallLetters.Add(letter);
                        Trolleys.Add(letter);
                        allLetters.Remove(letter);
                    }
                    numOfLetters -= config.TrolleysCount;

                    for (var i = 0; i < numOfLetters; i++)
                    {
                        var letter = allLetters[rand.Next(allLetters.Count)];
                        SmallLetters.Add(letter);
                        allLetters.Remove(letter);
                    }
                    SmallLetters.Sort();
                    Resources.Letters.ResourceManager.ReleaseAllResources();
                    LettersLeft = config.TrolleysCount;
                }
            }
            if (config.CurrentLevel == 3)
            {
                var allLetters = new List<Letter>();
                var imagesBoys = new List<ImageBrush>
                {
                    new ImageBrush(ConvertBitmapToBitmapSource(Resources.ImagesBoys.ch1)),
                    new ImageBrush(ConvertBitmapToBitmapSource(Resources.ImagesBoys.ch2)),
                    new ImageBrush(ConvertBitmapToBitmapSource(Resources.ImagesBoys.ch3)),
                    new ImageBrush(ConvertBitmapToBitmapSource(Resources.ImagesBoys.ch4))
                };
                var imagesGirls = new List<ImageBrush>
                {
                    new ImageBrush(ConvertBitmapToBitmapSource(Resources.ImagesGirls.dz1)),
                    new ImageBrush(ConvertBitmapToBitmapSource(Resources.ImagesGirls.dz2)),
                    new ImageBrush(ConvertBitmapToBitmapSource(Resources.ImagesGirls.dz3)),
                    new ImageBrush(ConvertBitmapToBitmapSource(Resources.ImagesGirls.dz4))
                };
                using (ResourceSet resourceSet = Resources.LettersAndNamesBoys.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true))
                {
                    var i = 0;
                    foreach (DictionaryEntry item in resourceSet)
                    {
                        allLetters.Add(new Letter((string) item.Key, (string) item.Value, imagesBoys[i%4]));
                        i++;
                    }
                    Resources.LettersAndNamesBoys.ResourceManager.ReleaseAllResources();
                }
                using (ResourceSet resourceSet = Resources.LettersAndNamesGirls.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true))
                {
                    var i = 0;
                    foreach (DictionaryEntry item in resourceSet)
                    {
                        allLetters.Add(new Letter((string) item.Key, (string) item.Value, imagesGirls[i%4]));
                        i++;
                    }
                    Resources.LettersAndNamesGirls.ResourceManager.ReleaseAllResources();
                }

                var rand = new Random();
                SmallLetters = new List<Letter>();
                BigLetters = new List<Letter>();
                for (var i = 0; i < numOfLetters; i++)
                {
                    var index = rand.Next(allLetters.Count);
                    var letter = allLetters[index];
                    SmallLetters.Add(letter);
                    BigLetters.Add(letter);
                    allLetters.RemoveAt(index);
                }
                LettersLeft = numOfLetters;
            }
            CorrectTrials = 0;
            Fails = 0;
            _startTime = DateTime.Now;
        }