Esempio n. 1
0
 private void uploadFarmDatabase()
 {
     for (int i = 0; i < user_animals.Count; i++)
     {
         animal ani = (animal)user_animals[i];
         dataBase.delAnimal(ani.Name);
         dataBase.addAnimal(ani.Name, ani.HungerValue, ani.Mood, ani.Species, ani.Level);
     }
 }
Esempio n. 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            dataBase = new DB();
            dataBase.DB_Load(sender, e);
            navbar_btn_homepage.PerformClick();

            // 抓下user資料
            ArrayList userdat = dataBase.getSystemData(null, null);

            if (userdat.Count == 11)
            {
                try
                {
                    grass       = Int32.Parse("" + userdat[2]);
                    meat        = Int32.Parse("" + userdat[3]);
                    money       = Int32.Parse("" + userdat[4]);
                    user_name   = (string)userdat[6];
                    height      = float.Parse("" + userdat[7]);
                    weight      = float.Parse("" + userdat[8]);
                    ranch_level = Int32.Parse("" + userdat[9]);
                    record_num  = Int32.Parse("" + userdat[10]);
                }
                catch {
                }
                //Console.WriteLine(grass + " ");
                //Console.WriteLine(meat + " ");
                //Console.WriteLine(money + " ");
                //Console.WriteLine(user_name + " ");
                //Console.WriteLine(height + " ");

                game_timer1.Start();
            }

            // 更新動物資料
            ArrayList _animals = dataBase.getAllAnimalName(null, null);

            Console.WriteLine(_animals.Count + "隻");
            PictureBox[] pb      = { animal_pb1, animal_pb2, animal_pb3 };
            PictureBox[] feedBox = { feedBox_pb1, feedBox_pb2, feedBox_pb3 };

            for (int i = 0; i < _animals.Count; i++)
            {
                int    _level       = dataBase.getAnimalLevel(_animals[i] + "");
                int    _hungervalue = dataBase.getAnimalHungerValue(_animals[i] + "");
                int    _mood        = dataBase.getAnimalMood(_animals[i] + "");
                string _speices     = dataBase.getAnimalSpecies(_animals[i] + "");
                string _feedHabits  = dataBase.getSpeciesFeedingHabit(_speices.Trim() + "");
                //MessageBox.Show(dataBase.getSpeciesFeedingHabit(_speices.Trim() + "") + ", " + dataBase.getSpeciesFeedingHabit("Lion"));
                animal item = new animal(_animals[i] + "", _speices, _level, _hungervalue, _mood, pb[i], feedBox[i], _feedHabits);
                user_animals.Add(item);
                feedBox[i].Tag = item;
            }

            create_animals();
        }
Esempio n. 3
0
        private void feedBox_pb1_Click(object sender, EventArgs e)
        {
            PictureBox panel = (PictureBox)sender;
            animal     ani   = (animal)panel.Tag;

            if (ani.HungerValue == 0)
            {
                MessageBox.Show(ani.Name + ":飽了!");
            }
            else if (meat <= 0)
            {
            }
            else if (feedMode == 1 && ani.feedingHabit == "Carnivorous")
            {
                // 餵食
                MessageBox.Show(ani.Name + ":好ㄘ~");
                ani.HungerValue = 0;
                meat--;
                //update
                update_farm();
            }
            else if (feedMode == 1 && ani.feedingHabit != "Carnivorous")
            {
                MessageBox.Show(ani.Name + ":覺得好難吃QQ");
                ani.Mood -= 20;
                meat--;

                //update
                update_farm();
            }
            else if (feedMode == 2 && ani.feedingHabit == "Herbivorous")
            {
                // 餵食
                MessageBox.Show(ani.Name + ":好ㄘ~");
                ani.HungerValue = 0;
                grass--;

                //update
                update_farm();
            }
            else if (feedMode == 2 && ani.feedingHabit != "Herbivorous")
            {
                // 餵食
                MessageBox.Show(ani.Name + ":覺得好難吃QQ");
                ani.Mood -= 20;
                grass--;

                //update
                update_farm();
            }
        }
Esempio n. 4
0
        private void update_farm()
        {
            PictureBox[] pb    = { animal_pb1, animal_pb2, animal_pb3 };
            Label[]      name  = { animal_name1, animal_name2, animal_name3 };
            Label[]      level = { animal_lv1, animal_lv2, animal_lv3 };
            flat_progressBar.flat_ProgressBar[] mood         = { animal_mood1, animal_mood2, animal_mood3 };
            flat_progressBar.flat_ProgressBar[] hunger_value = { animal_hungerValue1, animal_hungerValue2, animal_hungerValue3 };

            grass_num.Text = grass + " 份";
            meat_num.Text  = meat + " 份";

            for (int i = 0; i < user_animals.Count; i++)
            {
                animal _animal = (animal)user_animals[i];
                pb[i].Size = new Size(150, 142);

                name[i].Text          = _animal.Name;
                mood[i].Value         = _animal.Mood;
                hunger_value[i].Value = _animal.HungerValue;
                level[i].Text         = "LV" + _animal.Level;
            }
            //animal_timer1.Start();
        }
Esempio n. 5
0
        // 農場
        private void create_animals()
        {
            PictureBox[] pb      = { animal_pb1, animal_pb2, animal_pb3 };
            PictureBox[] feedBox = { feedBox_pb1, feedBox_pb2, feedBox_pb3 };
            Label[]      name    = { animal_name1, animal_name2, animal_name3 };
            Label[]      level   = { animal_lv1, animal_lv2, animal_lv3 };
            flat_progressBar.flat_ProgressBar[] mood         = { animal_mood1, animal_mood2, animal_mood3 };
            flat_progressBar.flat_ProgressBar[] hunger_value = { animal_hungerValue1, animal_hungerValue2, animal_hungerValue3 };
            Panel[]     pl          = { animal_status1, animal_status2, animal_status3 };
            ImageList[] animal_pics = { imageList1, imageList1 };



            Console.WriteLine(user_animals.Count + "隻");

            for (int i = 0; i < user_animals.Count; i++)
            {
                animal _animal = (animal)user_animals[i];
                pb[i].Image       = animal_pics[0].Images[0]; // 看物種給list
                pb[i].SizeMode    = PictureBoxSizeMode.Zoom;
                pb[i].Size        = new Size(150, 142);
                pb[i].Tag         = pl[i];
                pb[i].MouseEnter += new EventHandler(this.change);
                pb[i].MouseLeave += new EventHandler(this.dischange);

                name[i].Text          = _animal.Name;
                mood[i].Value         = _animal.Mood;
                hunger_value[i].Value = _animal.HungerValue;
                level[i].Text         = "LV" + _animal.Level;

                feedBox[i].Image    = imageList2.Images[0];
                feedBox[i].Size     = new Size(150, 77);
                feedBox[i].SizeMode = PictureBoxSizeMode.Zoom;
            }
            //animal_timer1.Start();
        }