Esempio n. 1
0
        public void IdolLeaves(int IdolIdx)
        {
            Idols[] reformedGroup = new Idols[this.Size - 1];
            int     j             = 0;

            for (int i = 0; i < this.Size; i++)
            {
                if (i != IdolIdx)
                {
                    reformedGroup[j] = this.AllIdols[i];
                    j++;
                }
            }

            this.Size    -= 1;
            this.AllIdols = null;
            this.AllIdols = new Idols[this.Size];
            this.AllIdols = reformedGroup;
        }
Esempio n. 2
0
        private void IdolsPickForm_Load(object sender, EventArgs e)
        {
            f3.CallingForm  = this;
            this.LoadedGame = false;

            PictureBox[] boxes = { pictureBox1,  pictureBox2,  pictureBox3,  pictureBox4,
                                   pictureBox5,  pictureBox6,  pictureBox7,  pictureBox8,
                                   pictureBox9,  pictureBox10, pictureBox11, pictureBox12,
                                   pictureBox13, pictureBox14 };

            textBox1.Text           = CallingForm.Group.Name;
            conceptBox.SelectedItem = CallingForm.Group.Concept;
            listBox1.SelectedIndex  = 0;

            int idolCount = Program.GetTableCount("Idols");

            Idols idolGet;

            int id = 0, age = 0;

            string gender      = "",
                   idolgroup   = "",
                   idolname    = "",
                   specialname = "";

            decimal height = 0,
                    weight = 0;

            var client = new HttpClient();

            try
            {
                Random     rnd       = new Random();
                List <int> IdolIds   = new List <int>();
                int        newNumber = 0;

                for (int i = 0; i < CallingForm.Group.Size; i++)
                {
                    newNumber = rnd.Next(1, idolCount + 1);
                    while (IdolIds.Contains(newNumber))
                    {
                        newNumber = rnd.Next(1, idolCount + 1);
                    }
                    IdolIds.Add(newNumber);

                    //Debug.WriteLine("New Number/Idol Id Is:" + newNumber);

                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var response = client.GetAsync(Program.apiPath + "/idols/" + newNumber).Result;

                    if (!response.IsSuccessStatusCode)
                    {
                        MessageBox.Show("Connection Error: " + response.StatusCode);
                        Environment.Exit(0);
                    }

                    dynamic context = JObject.Parse(response.Content.ReadAsStringAsync().Result);

                    id          = context.Items[0].Id.N;
                    age         = context.Items[0].Age.N;
                    gender      = context.Items[0].Gender.S;
                    height      = context.Items[0].Height.N;
                    weight      = context.Items[0].Weight.N;
                    idolgroup   = context.Items[0].IdolGroup.S;
                    idolname    = context.Items[0].IdolName.S;
                    specialname = context.Items[0].SpecialName.S;

                    idolGet = new Idols(id, age, gender, height, weight, idolgroup, idolname, specialname);

                    CallingForm.Group.AllIdols[i] = idolGet;

                    CallingForm.Group.AllIdols[i].Age += CallingForm.Group.currentDate.Year - 2020;

                    //Debug.WriteLine("Idol is:" + CallingForm.Group.AllIdols[i].IdolName);

                    string dest      = "";
                    string dest2     = "";
                    string imageName = idolGet.IdolName.Replace(" ", "_") + "!" + idolGet.IdolGroup.Replace(" ", "_");
                    dest  = Path.Combine(Program.resourcesPath, imageName + ".jpg");
                    dest2 = Path.Combine(Program.resourcesPath, imageName + ".jpeg");

                    if (File.Exists(dest))
                    {
                        boxes[i].Load(dest);
                    }
                    else if (File.Exists(dest2))
                    {
                        boxes[i].Load(dest2);
                    }
                    else if (File.Exists(Path.Combine(Program.resourcesPath, "noimage.jpg")))
                    {
                        boxes[i].Load(Path.Combine(Program.resourcesPath, "noimage.jpg"));
                    }

                    if (i == CallingForm.Group.Size - 1)
                    {
                        CallingForm.Group.AllIdols[i].Leader = true;
                    }
                }
            }
            catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); }

            pictureboxFalse();
            pictureBox1.Visible = true;
            label2.Text         = CallingForm.Group.AllIdols[0].PrintInfo();
        }