Ejemplo n.º 1
0
        private void PrepareQueue()
        {
            Random             rand   = new Random();
            List <ChampionCfg> config = new List <ChampionCfg>(64);

            for (int i = 0; i < 32; i++)
            {
                ChampionCfg champ = m_allChamps[rand.Next() % m_allChamps.Count];
                if (config.Any(x => x.Index == champ.Index) || champ.ImageFile == null)
                {
                    i--;
                    continue;
                }

                config.Add(champ);
                config.Add(champ);
            }

            SuspendLayout();

            foreach (SelectButton btn in m_buttons)
            {
                int idx = rand.Next() % config.Count;
                btn.ChampionName    = config[idx].ChampionName;
                btn.ChampionIndex   = config[idx].Index;
                btn.ChampionPicture = config[idx].ImageFile;

                btn.Reset();

                config.RemoveAt(idx);
                btn.Visible = true;
            }

            ResumeLayout(true);
        }
Ejemplo n.º 2
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            DoubleBuffered = true;

            SelectButton.CardImage = Resources.banner;
            for (int i = 0; i < m_allChamps.Count; i++)
            {
                string pureName = m_allChamps[i].ChampionName.RemoveSpecialCharacters();
                Image  image    = (Bitmap)Resources.ResourceManager.GetObject(pureName.ToLower());
                if (image == null && File.Exists($"{Environment.CurrentDirectory}\\images\\champions\\{pureName}.jpg"))
                {
                    image = Image.FromFile($"{Environment.CurrentDirectory}\\images\\champions\\{pureName}.jpg");
                }
                m_allChamps[i] = new ChampionCfg
                {
                    ChampionName = m_allChamps[i].ChampionName,
                    ImageFile    = image,
                    Index        = i
                };
            }

            GenerateButtons();
            PrepareQueue();
        }