public bool tryNewTier() { var visibleButterflies = from b in butterflies where b.GetHidden() == false select b; var avaliableColors = from b in visibleButterflies select b.Color; if (mistakeCount >= visibleButterflies.Count()/4) { return false; } else if (avaliableColors.Count() <= 3 || tier >= 5) { return false; } else { mistakeCount = 0; Random rand = new Random(); var usedColors = from b in butterflies where b.GetHidden() == false select b.Color; solutionColor = (Butterfly.ButterflyColors)usedColors.ElementAt(rand.Next(usedColors.Count())); int numSolution = butterflies.Count(c => c.Color == solutionColor && c.GetHidden() == false); solutionCount = rand.Next(1, numSolution); foreach (Butterfly B in butterflies.Where(c => c.Color == solutionColor)) { B.SelectionTime = 25;//nearly instantaneous for correct guess } foreach (Butterfly B in butterflies.Where(c => c.Color != solutionColor)) { B.SelectionTime = 400;// incorrect guesses } tier++; textOffset = myGame.GraphicsDevice.Viewport.Height / 32 * 6; return true; } }
public void LoadContent(ContentManager content, Viewport view) { Array values = Enum.GetValues(typeof(Butterfly.ButterflyColors)); Random random = new Random(); Feedback = content.Load<Texture2D>("Textures\\Feedback"); for (int i = 0; i < positions.Length; i ++) { butterflies.Add(new Butterfly(positions[i], 0,view, myCam.ViewMatrix, myCam.ProjectionMatrix, (Butterfly.ButterflyColors)values.GetValue(random.Next(values.Length)))); butterflies[i].Selected += new Butterfly.ButterflySelectedEventHandler(ButterflySelected); butterflies[i].LoadContent(content); butterflies[i].Selectable = true; butterflies[i].setPosition(butterflies[i].getPosition() * 20); } Random rand = new Random(); var usedColors = from b in butterflies where b.GetHidden() == false select b.Color; solutionColor = (Butterfly.ButterflyColors)usedColors.ElementAt(random.Next(usedColors.Count())); int numSolution = butterflies.Count(c => c.Color == solutionColor && c.GetHidden() == false ); solutionCount = rand.Next(1, numSolution); foreach(Butterfly B in butterflies.Where(c => c.Color == solutionColor)) { B.SelectionTime = 25;//nearly instantaneous for correct guess } foreach (Butterfly B in butterflies.Where(c => c.Color != solutionColor)) { B.SelectionTime = 400;//a whole second for incorrect guesses } font = content.Load<SpriteFont>("SpriteFont1"); font2 = content.Load<SpriteFont>("SpriteFont2"); engine = new AudioEngine("Content\\Audio\\ButterflyAudio.xgs"); waveBank = new WaveBank(engine, "Content\\Audio\\Waves.xwb"); soundBank = new SoundBank(engine, "Content\\Audio\\Sounds.xsb"); background = content.Load<Texture2D>("Textures\\ButterflyGarden\\forestCrap"); textOffset = myGame.GraphicsDevice.Viewport.Height / 32 * 6; particleSystem = new DefaultTexturedQuadTextureCoordinatesParticleSystem(myGame); particleSystem.AutoInitialize(myGame.GraphicsDevice, content, myGame.Services.GetService(typeof(SpriteBatch)) as SpriteBatch); //particleSystem.SetTexture("Textures\\Feedback"); }