示例#1
0
 public Animal(string nm, Point start_location, World w, gametime clock)
     : base(start_location, w, clock)
 {
     rest_data = new RestData(this,w,clock);
     name = nm;
     safety = 100;
 }
示例#2
0
 // ---------------------------------------------------------------
 // Main Functions
 // ---------------------------------------------------------------
 // Adam is a test person. This spawns him and adds him to the world'
 static Person spawnAdam(World locale,gametime world_clock)
 {
     // the test person. Our Adam.
     Person adam = new Person("Adam", new Point(100, 100), locale, world_clock);
     Console.WriteLine("Adam spawned at: " + adam.world_clock.current_time);
     // give him some food
     Item mana = new Item("mana", 1000);
     adam.inventory.Add(mana);
     return adam;
 }
示例#3
0
        // defines the object in the game and runs the game loop
        static void Main(string[] args)
        {
            bool game_on = true;

            // generate the world
            World locale = new World(100, 100);
            gametime world_clock = new gametime();
            Console.WriteLine("new clock: " + world_clock.current_time);

            // populate teh world with our test person
            Person adam=spawnAdam(locale,world_clock);

            // add him to the world
            locale.inhabitants.Add(adam);

            // the game loop
            while (game_on)
            {
                world_clock.tick(locale.inhabitants);
            }
        }
示例#4
0
        private Animal owner; // a reference to the owner of this data

        #endregion Fields

        #region Constructors

        // establishing the initial rest data
        public RestData(Animal o, World w, gametime clock)
        {
            owner = o;
            max_rest=48;
            rest_drain = 1;
            over_rested_level=0.9;
            well_rested_level=0.7;
            rested_level=0.6;
            fatigued_level=0.5;
            sleepy_level=0.4;
            tired_level=0.3;
            restfulness = (int)(max_rest * (rested_level + ((well_rested_level - rested_level) / 2)));

            sleep_time = 0;
            rest_rate = 4;
            nocturnal = false;
            locale = w;
            world_clock = clock;
            calcRestState();
            //Console.WriteLine(owner+" rest data received time: " + world_clock.current_time);
        }
示例#5
0
        // search a given area in the World and find the closest lot with the building type on it
        // returns the lot.
        // * this might be turned into a template later on for different kinds of area searches
        public Lot typeRadialSearch(World locale, Point center, int radius, string type)
        {
            Point p=new Point(); // the search pointer
            for (p.X = center.X; (p.X < center.X + radius); ++p.X)
            {
                for (p.Y = center.Y; p.Y < center.Y + radius; ++p.Y)
                {
                    // skip checking places out of bounds
                    if (
                        p.X<0 ||
                        p.X> locale.world_size.X-1 ||
                        p.Y<0 ||
                        p.Y>locale.world_size.Y-1
                        )
                        continue;

                    // convert the 2d search into a 1d index lookup
                    int index = (p.Y * locale.world_size.X) + p.X;
                    if (locale.lot_list[index].building.type == type)
                        return locale.lot_list[index];
                }
            }

            // failed search, return the null lot:
            return new Lot();
        }
示例#6
0
 public Person(string nm, Point start_location, World w, gametime clock)
     : base(nm, start_location, w, clock)
 {
     //rest_data = new RestData(this, w, clock);
     inventory = new List<Item>();
     Console.WriteLine("Initiating a person: " + world_clock.current_time);
 }
示例#7
0
        // When a life form is created, we can chose its starting nutrition
        // and usualy, they start alive.
        public LifeForm(Point start_location, World w,gametime clock)
        {
            id = Program.generateID(); // need to develop a global system to determine IDs and reference objects by their IDs

            state = "alive";
            hungry = false;
            hunger_level = 0.5;
            max_sation = 96;
            burn_speed = 1;
            nutrition = 75;
            location = start_location;
            locale = w;
            action_queue=new Queue<Actionable>();
            inventory= new List<Item>();
            world_clock = clock;

            // debug feedback
            //Console.WriteLine("Lifeform created at coordinates "+location);
            //Console.Write("Nutrition: " + nutrition +"\n");
        }
示例#8
0
        public string type; // the type of demand made

        #endregion Fields

        #region Constructors

        public Demand(World w, string t, Rectangle a, string p)
        {
            type = t;
            origin = p;
            area = Rectangle.Intersect(a,new Rectangle(0, 0, w.world_size.X, w.world_size.Y));
            if (area.IsEmpty)
            {
                //Console.WriteLine("rectangle out of bounds error.");
            }
        }