Ejemplo n.º 1
0
    /**
     *  Some actions need to use data from the world state to determine if they are able to run. These preconditions are called procedural preconditions.
     *  Need to check there is food available
     * **/
    public override bool checkProceduralPrecondition(GameObject agent)
    {
        // find the nearest chopping block that we can chop our wood at
        PieShopTwo[] blocks = (PieShopTwo[])UnityEngine.GameObject.FindObjectsOfType(typeof(PieShopTwo));


        targetChoppingBlock = blocks[0];
        target = targetChoppingBlock.gameObject;


        return(blocks[0] != null);
    }
Ejemplo n.º 2
0
    void Update()
    {
        PieShopTwo[] blocks = (PieShopTwo[])UnityEngine.GameObject.FindObjectsOfType(typeof(PieShopTwo));
        PieShopTwo   info   = blocks[0];

        if (info.open)
        {
            textFeild.text = "Open";
        }
        else
        {
            textFeild.text = "Closed";
        }
    }
Ejemplo n.º 3
0
    /**
     * Key-Value data that will feed the GOAP actions and system while planning.
     */
    public HashSet <KeyValuePair <string, object> > getWorldState()
    {
        HashSet <KeyValuePair <string, object> > worldData = new HashSet <KeyValuePair <string, object> >();

        worldData.Add(new KeyValuePair <string, object>("hasEnoughMoney", (bag.money >= 5)));
        worldData.Add(new KeyValuePair <string, object>("eat", (bag.eaten)));
        worldData.Add(new KeyValuePair <string, object>("hasPie", (bag.hasPie)));
        worldData.Add(new KeyValuePair <string, object>("hasMilk", (bag.hasMilk)));
        worldData.Add(new KeyValuePair <string, object>("storeMilk", (bag.storedMilk)));

        PieShopOne[] p1    = (PieShopOne[])UnityEngine.GameObject.FindObjectsOfType(typeof(PieShopOne));
        PieShopOne   info1 = p1[0];


        worldData.Add(new KeyValuePair <string, object>("pieShopOneOpen", (info1.open)));


        PieShopTwo[] p2    = (PieShopTwo[])UnityEngine.GameObject.FindObjectsOfType(typeof(PieShopTwo));
        PieShopTwo   info2 = p2[0];

        worldData.Add(new KeyValuePair <string, object>("pieShopTwoOpen", (info2.open)));


        ACow[] cows   = (ACow[])UnityEngine.GameObject.FindObjectsOfType(typeof(ACow));
        ACow   theCow = cows[0];


        Grass[] grasses = (Grass[])UnityEngine.GameObject.FindObjectsOfType(typeof(Grass));

        worldData.Add(new KeyValuePair <string, object>("grassAvailable", (grasses.Length > 0)));


        WaterTrough[] waters = (WaterTrough[])UnityEngine.GameObject.FindObjectsOfType(typeof(WaterTrough));
        WaterTrough   water  = waters[0];


        worldData.Add(new KeyValuePair <string, object>("waterAvailable", (water.level > 0)));


        worldData.Add(new KeyValuePair <string, object>("cowHasMilk", (theCow.stomach.hasMilk())));


        FreePie[] freePies = (FreePie[])UnityEngine.GameObject.FindObjectsOfType(typeof(FreePie));

        worldData.Add(new KeyValuePair <string, object>("freePieAvailable", (freePies.Length > 0)));


        return(worldData);
    }
Ejemplo n.º 4
0
 public override void reset()
 {
     bought = false;
     targetChoppingBlock = null;
     startTime           = 0;
 }