Beispiel #1
0
        private bool EatPlant()
        {
            // Get the first plant with the most amount of Energy
            var plant = _context.GetSimObjects <Plant>(XPos, YPos).OrderByDescending(p => p.Energy).FirstOrDefault() ?? null;

            if (plant == null)
            {
                return(false);
            }

            Energy++;
            plant.GetEaten();

            return(true);
        }
Beispiel #2
0
 public void GetSimObjectsTest()
 {
     Assert.AreEqual(_context.GetSimObjects <Plant>().Count(), 2);
     Assert.AreEqual(_context.GetSimObjects <Creature>().Count(), 3);
     Assert.AreEqual(_context.GetSimObjects <Obstacle>().Count(), 2);
 }