Beispiel #1
0
        public PetForm()
        {
            InitializeComponent();

            if (SelectForm.loadCat)
            {
                cat = new Cat();
                pet = cat;
            }
            if (SelectForm.loadDog)
            {
                dog = new Dog();
                pet = dog;
                petPetButton.Text   = "Pet Dog";
                petPlayButton.Text  = "Play with Dog";
                petWaterButton.Text = "Give Dog Water";
                feedPetButton.Text  = "Feed Dog";
            }
            if (SelectForm.loadBird)
            {
                petPetButton.Text   = "Pet Bird";
                petPlayButton.Text  = "Play with Bird";
                petWaterButton.Text = "Give Bird Water";
                feedPetButton.Text  = "Feed Bird";
                bird = new Bird();
                pet  = bird;
            }
            if (SelectForm.loadCapy)
            {
                petPetButton.Text   = "Pet CapyBara";
                petPlayButton.Text  = "Play with CapyBara";
                petWaterButton.Text = "Give CapyBara Water";
                feedPetButton.Text  = "Feed CapyBara";
                capy = new CapyBara();
                pet  = capy;
            }
            if (SelectForm.loadFile)
            {
                loadPet();
            }

            petPictureBox.Image    = pet.currentImage;
            boredomMeter.Maximum   = pet.Max_Boredom;
            hungerMeter.Maximum    = pet.Max_Hunger;
            thirstMeter.Maximum    = pet.Max_Thirst;
            affectionMeter.Maximum = pet.Max_Affection;
            waterAmountBar.Maximum = pet.Max_Water;
            foodAmountBar.Maximum  = pet.Max_Food;
            energyBar.Maximum      = pet.Max_Energy;

            pet.InitializeFrames();
            AttachPetEvents();
            mainLoopTimer.Interval = 17;                   //runs every 60th of a second
            mainLoopTimer.Tick    += mainLoopTimer_Tick_1; //run MainLoopTimer_Tick method every 60th of a second
            mainLoopTimer.Start();                         //start the main loop
            sleepingLabel.Visible = false;
            InitializeProgressBars();
            InitializeFileFilters();
        }
Beispiel #2
0
 public PlayState(AbstractPet pet)
 {
     this.pet = pet;
 }
Beispiel #3
0
 public PettingState(AbstractPet pet)
 {
     this.pet = pet;
 }
 public DrinkState(AbstractPet pet)
 {
     this.pet = pet;
 }
Beispiel #5
0
 public LeaveState(AbstractPet pet)
 {
     this.pet = pet;
 }
Beispiel #6
0
 public AwakeState(AbstractPet pet)
 {
     this.pet = pet;
 }
Beispiel #7
0
 public EatState(AbstractPet pet)
 {
     this.pet = pet;
 }
Beispiel #8
0
 //----------------------LOAD AND SAVE----------------------------------------------------------------------
 public void loadPet()
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         string       name         = openFileDialog1.FileName;
         BinaryReader binaryReader = new BinaryReader(File.Open(name, FileMode.Open));
         if (Path.GetExtension(name) == ".dog")
         {
             dog = new Dog();
             pet = dog;
             petPetButton.Text   = "Pet Dog";
             petPlayButton.Text  = "Play with Dog";
             petWaterButton.Text = "Give Dog Water";
             feedPetButton.Text  = "Feed Dog";
         }
         if (Path.GetExtension(name) == ".cat")
         {
             cat = new Cat();
             pet = cat;
             petPetButton.Text   = "Pet Cat";
             petPlayButton.Text  = "Play with Cat";
             petWaterButton.Text = "Give Cat Water";
             feedPetButton.Text  = "Feed Cat";
         }
         if (Path.GetExtension(name) == ".cap")
         {
             capy = new CapyBara();
             pet  = capy;
             petPetButton.Text   = "Pet Capybara";
             petPlayButton.Text  = "Play with Capybara";
             petWaterButton.Text = "Give Capybara Water";
             feedPetButton.Text  = "Feed Capybara";
         }
         if (Path.GetExtension(name) == ".brd")
         {
             bird = new Bird();
             pet  = bird;
             petPetButton.Text   = "Pet Bird";
             petPlayButton.Text  = "Play with Bird";
             petWaterButton.Text = "Give Bird Water";
             feedPetButton.Text  = "Feed Bird";
         }
         InitializeProgressBars();
         pet.InitializeFrames();
         boredomMeter.Maximum   = pet.Max_Boredom;
         hungerMeter.Maximum    = pet.Max_Hunger;
         thirstMeter.Maximum    = pet.Max_Thirst;
         affectionMeter.Maximum = pet.Max_Affection;
         waterAmountBar.Maximum = pet.Max_Water;
         foodAmountBar.Maximum  = pet.Max_Food;
         energyBar.Maximum      = pet.Max_Energy;
         AttachPetEvents();
         petPictureBox.Image = pet.currentImage;
         pet.CurrentFood     = binaryReader.ReadInt32();
         pet.PetAffection    = binaryReader.ReadInt32();
         pet.PetThirst       = binaryReader.ReadInt32();
         pet.CurrentWater    = binaryReader.ReadInt32();
         pet.PetHunger       = binaryReader.ReadInt32();
         pet.CurrentEnergy   = binaryReader.ReadInt32();
         pet.PetBoredom      = binaryReader.ReadInt32();
         pet.SetState(pet.GetAwakeState());
         this.TopMost = true;
         binaryReader.Dispose();
     }
 }
 public SleepState(AbstractPet pet)
 {
     this.pet = pet;
 }