Пример #1
0
        private void EatSomeGrass(World forest)
        {
            /*
             * foreach (Grass g in forest.Grassxs)
             * {
             *  if (g.Position.X == this.Position.X && g.Position.Y == this.Position.Y
             *       && g != null)
             *  {
             *      int amount = FOOD_CONSUMPTION * 2;
             *      if (g.Growth < amount)
             *      {
             *          amount = g.Growth;
             *      }
             *      g.Growth -= amount;
             *      food += amount;
             *  }
             *
             * }
             */
            // Grass grass = forest.GrassAt(Position).Select(o => o as Grass).First(o => o != null);
            Grass grass = forest.GrassAt2(Position);

            int amount = FOOD_CONSUMPTION * 2;

            if (grass.Growth < amount)
            {
                amount = grass.Growth;
            }
            grass.Growth -= amount;
            food         += amount;
        }
Пример #2
0
        private void EatSomeGrass(World forest)
        {
            Grass grass  = forest.ObjectsAt(Position).Select(o => o as Grass).First(o => o != null);
            int   amount = FOOD_CONSUMPTION * 2;

            if (grass.Growth < amount)
            {
                amount = grass.Growth;
            }
            grass.Growth -= amount;
            food         += amount;
        }
Пример #3
0
        private void EatSomeGrass(World forest)
        {
            Grass grass  = forest.PastoQuePiso(Position);
            int   amount = FOOD_CONSUMPTION * 2;

            if (grass.Growth < amount)
            {
                amount = grass.Growth;
            }
            grass.Growth -= amount;
            food         += amount;
        }
Пример #4
0
        private void EatSomeGrass(World forest)//Come Grass
        {
            Grass grass = forest.ObjectsAt(Position);
            //Grass grass = forest.ObjectsAt(Position).Select(o => o as Grass).First(o => o != null);//creo una copia de la grass que va a comer
            int amount = FOOD_CONSUMPTION * 2;//lo que llena la barra de comida

            if (grass.Growth < amount)
            {
                amount = grass.Growth;
            }
            grass.Growth -= amount;
            food         += amount;
        }
Пример #5
0
        private void EatSomeGrass(World forest)
        {
            //Grass grass = forest.ObjectsAt(Position).Select(o => o as Grass).First(o => o != null);
            Grass grass = new Grass();

            foreach (GameObject g in forest.GameObjects)
            {
                if (g.Position.X == this.Position.X && g.Position.Y == this.Position.Y && g is Grass && g != null)
                {
                    grass = (Grass)g;
                }
            }

            int amount = FOOD_CONSUMPTION * 2;

            if (grass.Growth < amount)
            {
                amount = grass.Growth;
            }
            grass.Growth -= amount;
            food         += amount;
        }