Пример #1
0
        public override void Update(GameTime gameTime)
        {
            this.Energy -= this.MetabolicRate;

            if (this.Energy <= 0)
            {
                this.Kill();
                return;
            }

            if (this.Energy >= GROWTH_THRESHHOLD)
            {
                this.Grow();
            }

            // Determine what state we're in based on needs met
            Needs needs = this.CalculateNeeds();

            this.ProcessMovement(gameTime);

            if (needs.IsSet(Needs.Eat))
            {
                this.DoEat?.Invoke(gameTime);

                return;
            }

            if (needs.IsSet(Needs.Shelter))
            {
                this.DoFindShelter?.Invoke(gameTime);

                return;
            }

            if (needs.IsSet(Needs.Produce))
            {
                this.DoReproduce?.Invoke(gameTime);

                return;
            }

            if (needs.IsSet(Needs.Desire))
            {
                this.DoDesire?.Invoke(gameTime);
            }
        }