Exemplo n.º 1
0
        //Fazer Decompose

        public override void ApplyActionEffects(WorldModelDST worldModel)
        {
            worldModel.Cycle += this.Duration;

            if (worldModel.Cycle > Convert.ToSingle(15 - (worldModel.CycleInfo[2] + worldModel.CycleInfo[1])) && worldModel.Possesses("torch"))
            {
                ActionDST action = new Equip("torch");
                worldModel.AddAction(action);
            }

            if (this.Target == "berries")
            {
                worldModel.RemoveFromPossessedItems("berries", 1);
                worldModel.DecreaseHunger(9);

                if (!worldModel.Possesses("berries"))
                {
                    worldModel.RemoveAction("Eat_berries");
                }
            }
            else if (this.Target == "carrot")
            {
                worldModel.RemoveFromPossessedItems("carrot", 1);
                worldModel.DecreaseHunger(13);
                worldModel.IncreaseHP(1);

                if (!worldModel.Possesses("carrot"))
                {
                    worldModel.RemoveAction("Eat_carrot");
                }
            }
        }
Exemplo n.º 2
0
        //Fazer Decompose

        public override void ApplyActionEffects(WorldModelDST worldModel)
        {
            worldModel.Cycle += this.Duration;

            //<OPTIMIZATION - Dict instead of chained if's>
            if (FoodIndex.ContainsKey(this.Target))
            {
                worldModel.RemoveFromPossessedItems(this.Target, 1);

                int[] foodValues = FoodIndex[this.Target];
                int   HungerVal  = foodValues[0];

                if (HungerVal > 0)
                {
                    worldModel.DecreaseHunger(foodValues[0]);
                }
                else if (HungerVal < 0)
                {
                    worldModel.IncreaseHunger(Math.Abs(foodValues[0]));
                }

                if (foodValues.Length > 1)
                {
                    int HPVal = foodValues[1];
                    if (HPVal > 0)
                    {
                        worldModel.IncreaseHP(foodValues[1]);
                    }
                    else if (HPVal < 0)
                    {
                        worldModel.DecreaseHP(Math.Abs(foodValues[1]));
                    }
                }

                if (!worldModel.Possesses(this.Target))
                {
                    worldModel.RemoveAction("Eat_" + this.Target);
                }
            }
        }