Exemplo n.º 1
0
        public override void work(int dt)
        {
            if (!isWorking)
            {
                isWorking = true;
            }

            base.work(dt);

            if (Util.GetRandomNumberF() < Config.ChanceToCraftProduct)
            {
                try
                {
                    products.Product p = new products.Product();
                    body.Bag.Add(p);
                    body.AddExp(Config.ExpForCraft * (1 + body.CurrentLevel / 10));
                }
                catch (Exception ex)
                {
                }
            }

            if (body.Energy < 30)
            {
                if (true)
                {
                }
                StateMachine.PopState();
                isWorking = false;

                if (body.Bag.Count > Config.ThingsLimitForSelling)
                {
                    StateMachine.PushState("goToMarket");
                    StateMachine.EnqueueState("sell");
                    return;
                }

                if (body.Bag.FoodCount < 3 && body.Money > Config.MoneyLimitForBuying)
                {
                    StateMachine.PushState("goToMarket");
                    StateMachine.EnqueueState("buyFood");
                    return;
                }

                if (body.Happiness < Config.LowerBoundHappyToDrink)
                {
                    StateMachine.PushState("goToTavern");
                }
                else
                {
                    StateMachine.PushState("goHome");
                }
            }
            else if (body.Happiness < 20)
            {
                isWorking = false;
                StateMachine.PopState();
                StateMachine.PushState("goToTavern");
            }
        }
Exemplo n.º 2
0
        public override void work(int dt)
        {
            if (!isWorking)
            {
                isWorking = true;
            }

            base.work(dt);

            if (Util.GetRandomNumberF() < Config.ChanceToCraftProduct)
            {
                try
                {
                    products.Product p = new products.Product();
                    body.Bag.Add(p);
                    body.AddExp(Config.ExpForCraft * (1 + body.CurrentLevel / 10));
                }
                catch (Exception ex)
                {
                }
            }

            if (body.Energy < 30)
            {
                if (true) { }
                StateMachine.PopState();
                isWorking = false;

                if (body.Bag.Count > Config.ThingsLimitForSelling)
                {
                    StateMachine.PushState("goToMarket");
                    StateMachine.EnqueueState("sell");
                    return;
                }

                if (body.Bag.FoodCount < 3 && body.Money > Config.MoneyLimitForBuying)
                {
                    StateMachine.PushState("goToMarket");
                    StateMachine.EnqueueState("buyFood");
                    return;
                }

                if (body.Happiness < Config.LowerBoundHappyToDrink)
                {
                    StateMachine.PushState("goToTavern");
                }
                else
                {
                    StateMachine.PushState("goHome");
                }
            }
            else if (body.Happiness < 20)
            {
                isWorking = false;
                StateMachine.PopState();
                StateMachine.PushState("goToTavern");
            }
        }