Exemplo n.º 1
0
    List <GoapAction> GetActions()
    {
        var listOfActions = new List <GoapAction>()
        {
            new GoapAction(PlayerActionKey.GetPizzaPlace)
            .AddPrecondition(x => x.hasPayedTaxes == true)
            .AddPrecondition(x => x.item == (int)InitialItem.DEBT_FREE)
            .AddPrecondition(x => x.money >= pizzaPlacePrice)
            .AddPrecondition(x => x.hasflour == true)
            .AddEffect(x =>
            {
                var wm           = new WorldModel();
                wm.isPizzaMaster = true;
                return(wm);
            })
            .AddCost(0),

            new GoapAction(PlayerActionKey.GoToGrandmaHouse)
            .AddPrecondition(x => x.item == (int)InitialItem.NOTHING)
            .AddEffect(x =>
            {
                var wm    = WorldModel.Clone(x);
                wm.money += grandmaLoan;
                return(wm);
            })
            .AddEffect(x =>
            {
                var wm    = WorldModel.Clone(x);
                var itemR = UnityEngine.Random.Range(0, 10);
                if (itemR > 5)
                {
                    wm.item = (int)InitialItem.KNIFE;
                }
                else
                {
                    wm.item = (int)InitialItem.SHOVEL;
                }

                return(wm);
            })
            .AddCost(grandmaCost),

            new GoapAction(PlayerActionKey.GetSeed)
            .AddPrecondition(x => x.money > seedPrice)
            .AddEffect(x =>
            {
                var wm = WorldModel.Clone(x);
                wm.seeds++;
                return(wm);
            })
            .AddEffect(x =>
            {
                var wm    = WorldModel.Clone(x);
                wm.money -= seedPrice;
                return(wm);
            })
            .AddCost(getSeedCost),

            new GoapAction(PlayerActionKey.PlantTomatoes)
            .AddPrecondition(x => x.item == (int)InitialItem.SHOVEL)
            .AddPrecondition(x => x.seeds > 0)
            .AddEffect(x =>
            {
                var wm = WorldModel.Clone(x);
                wm.seeds--;
                return(wm);
            })
            .AddEffect(x =>
            {
                var wm       = WorldModel.Clone(x);
                wm.tomatoes += 3;
                return(wm);
            })
            .AddCost(plantTomatoesCost),

            new GoapAction(PlayerActionKey.SellTomatoes)
            .AddPrecondition(x => x.tomatoes >= 3)
            .AddEffect(x =>
            {
                var wm    = WorldModel.Clone(x);
                wm.money += tomatoesSellPrice;
                return(wm);
            }).
            AddEffect(x =>
            {
                var wm       = WorldModel.Clone(x);
                wm.tomatoes -= 3;
                return(wm);
            })
            .AddCost(sellTomatoesCost),

            new GoapAction(PlayerActionKey.Steal)
            .AddPrecondition(x => x.item == (int)InitialItem.KNIFE)
            .AddEffect(x =>
            {
                var wm    = WorldModel.Clone(x);
                wm.money += stealBounty;
                return(wm);
            })
            .AddEffect(x =>
            {
                var wm = WorldModel.Clone(x);
                wm.stealCount++;
                return(wm);
            })
            .AddEffect(x =>
            {
                var wm      = WorldModel.Clone(x);
                wm.isAThief = true;
                return(wm);
            })
            .AddCost(stealCost),

            new GoapAction(PlayerActionKey.PayTaxes)
            .AddPrecondition(x => x.money >= taxesPrice)
            .AddPrecondition(x => x.item != (int)InitialItem.DEBT_FREE)
            .AddEffect(x =>
            {
                var wm    = WorldModel.Clone(x);
                wm.money -= taxesPrice;
                return(wm);
            })
            .AddEffect(x =>
            {
                var wm  = WorldModel.Clone(x);
                wm.item = (int)InitialItem.DEBT_FREE;
                return(wm);
            })
            .AddEffect(x =>
            {
                var wm           = WorldModel.Clone(x);
                wm.hasPayedTaxes = true;
                return(wm);
            })
            .AddCost(payTaxesCost),

            new GoapAction(PlayerActionKey.DealGob)
            .AddPrecondition(x => x.hasPayedTaxes == true)
            .AddEffect(x =>
            {
                var wm           = WorldModel.Clone(x);
                wm.hasPayedTaxes = true;
                return(wm);
            })
            .AddCost(gobAgreementCost),

            new GoapAction(PlayerActionKey.Work)
            .AddPrecondition(x => x.isAThief == false)
            .AddEffect(x =>
            {
                var wm    = WorldModel.Clone(x);
                wm.money += salary;
                return(wm);
            })
            .AddEffect(x =>
            {
                var wm = WorldModel.Clone(x);
                return(wm);
            })
            .AddCost(gobAgreementCost),

            new GoapAction(PlayerActionKey.WheatToFluor)
            .AddPrecondition(x => x.money >= wheatToFluorPrice)
            .AddPrecondition(x => x.item == (int)InitialItem.DEBT_FREE)
            .AddEffect(x =>
            {
                var wm    = WorldModel.Clone(x);
                wm.money -= wheatToFluorPrice;
                return(wm);
            })
            .AddEffect(x =>
            {
                var wm      = WorldModel.Clone(x);
                wm.hasflour = true;
                return(wm);
            })
            .AddCost(wheatToFluorCost)
        };

        return(listOfActions);
    }