Advertisement
Purianite

Creature.cs

Mar 11th, 2012
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Critter
  7. {
  8.     class Creature
  9.     {
  10.         //Stats
  11.         public int Hunger;
  12.         public int Boredom;
  13.         public string Name;
  14.         public string[] Phrases = new string[6];
  15.         public string[] Tricks = new string[3];
  16.         Random random = new Random();
  17.  
  18.         public Creature()
  19.         {
  20.             //Stats
  21.             Hunger = 5;
  22.             Boredom = 5;
  23.             Name = "Pannya";
  24.             Phrases[0] = "You're the worst caretaker ever.";
  25.             Phrases[1] = "I'm feeling horrible right now.";
  26.             Phrases[2] = "I'm feeling bad right now.";
  27.             Phrases[3] = "I'm feeling okay right now.";
  28.             Phrases[4] = "I'm feeling good right now.";
  29.             Phrases[5] = "I'm feeling excellent right now.";
  30.             Tricks[0] = "Your Pannya rolled around.";
  31.             Tricks[1] = "Your Pannya stood on her tail.";
  32.             Tricks[2] = "Your Pannya did a backflip.";
  33.         }
  34.  
  35.         //Action
  36.         private void passTime()
  37.         {
  38.             Hunger++;
  39.             Boredom++;
  40.             Hunger = Math.Min(Hunger, 10);
  41.             Boredom = Math.Min(Boredom, 10);
  42.         }
  43.  
  44.         public int getMood()
  45.         {
  46.             return (int)Math.Round(0.25 * ((10-Hunger) + (10-Boredom)));
  47.         }
  48.  
  49.         public void Eat()
  50.         {
  51.             Hunger -= 3;
  52.             Hunger = Math.Max(Hunger, -1);
  53.             passTime();
  54.         }
  55.  
  56.         public void Play()
  57.         {
  58.             Boredom -= 3;
  59.             Boredom = Math.Max(Boredom, -1);
  60.             passTime();
  61.         }
  62.  
  63.         public string Talk()
  64.         {
  65.             return Phrases[getMood()];
  66.         }
  67.  
  68.         public string PerformTrick()
  69.         {
  70.             passTime();
  71.             return Tricks[random.Next(3)];
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement