private void AddFuelButton_Click(object sender, EventArgs e) { AddFuel?.Invoke(); NewFuelTextBox.Text = ""; }
public WorldModelDST(PreWorldState preWorldState) { this.Parent = null; this.Walter = preWorldState.Walter; this.Cycle = preWorldState.Cycle; this.CycleInfo = preWorldState.CycleInfo; //Getting Inventory from PreWorldState int size1 = preWorldState.Inventory.Count; this.PossessedItems = new List <Pair <string, int> >(size1); for (int i = 0; i < size1; i++) { Pair <string, int> tuple1 = new Pair <string, int>(preWorldState.Inventory[i].Item1, preWorldState.Inventory[i].Item3); this.PossessedItems.Add(tuple1); } //Getting Fuel items from PreWorldState this.Fuel = new List <Pair <string, int> >(preWorldState.Fuel.Count); foreach (var fuelItem in preWorldState.Fuel) { Pair <string, int> tuple1 = new Pair <string, int>(fuelItem.Item1, fuelItem.Item3); this.Fuel.Add(tuple1); } //Getting Fire Info this.Fire = preWorldState.Fire; //Getting Equipped items from PreWorldState int size2 = preWorldState.Equipped.Count; this.EquippedItems = new List <string>(size2); for (int i = 0; i < size2; i++) { this.EquippedItems.Add(preWorldState.Equipped[i].Item1); } //Getting WorldObjects from PreWorldState's Entities int size3 = preWorldState.Entities.Count; this.WorldObjects = new List <Pair <Pair <string, int>, Pair <int, int> > >(size3); for (int i = 0; i < size3; i++) { Pair <string, int> npair = new Pair <string, int>(preWorldState.Entities[i].Prefab, preWorldState.Entities[i].Quantity); Pair <Pair <string, int>, Pair <int, int> > tolist = new Pair <Pair <string, int>, Pair <int, int> >(npair, preWorldState.Entities[i].Position); this.WorldObjects.Add(tolist); } //Getting Available Actions this.AvailableActions = new List <ActionDST>(); ActionDST action = new Wander(); this.AvailableActions.Add(action); if (WorldHas("campfire") && preWorldState.Cycle >= Convert.ToSingle(13 - preWorldState.CycleInfo[2])) { action = new Stay("campfire"); this.AvailableActions.Add(action); } if (WorldHas("firepit") && preWorldState.Cycle >= Convert.ToSingle(13 - preWorldState.CycleInfo[2])) { action = new Stay("firepit"); this.AvailableActions.Add(action); } if (HasFuel() && WorldHas("campfire")) { action = new AddFuel("campfire"); this.AvailableActions.Add(action); } if (HasFuel() && WorldHas("firepit")) { action = new AddFuel("firepit"); this.AvailableActions.Add(action); } if (WorldHas("tree") && (Possesses("axe") || IsEquipped("axe"))) { action = new Grab("tree"); this.AvailableActions.Add(action); } if (WorldHas("log")) { action = new Grab("log"); this.AvailableActions.Add(action); } if (WorldHas("sapling")) { action = new Grab("sapling"); this.AvailableActions.Add(action); } if (WorldHas("twigs")) { action = new Grab("twigs"); this.AvailableActions.Add(action); } if (WorldHas("flint")) { action = new Grab("flint"); this.AvailableActions.Add(action); } if (WorldHas("cutgrass")) { action = new Grab("cutgrass"); this.AvailableActions.Add(action); } if (WorldHas("grass")) { action = new Grab("grass"); this.AvailableActions.Add(action); } if (WorldHas("boulder") && (Possesses("pickaxe") || IsEquipped("pickaxe"))) { action = new Grab("boulder"); this.AvailableActions.Add(action); } if (WorldHas("rocks")) { action = new Grab("rocks"); this.AvailableActions.Add(action); } if (WorldHas("berrybush")) { action = new Grab("berrybush"); this.AvailableActions.Add(action); } if (WorldHas("berries")) { action = new Grab("berries"); this.AvailableActions.Add(action); } if (WorldHas("carrot")) { action = new Grab("carrot"); this.AvailableActions.Add(action); } if (WorldHas("carrot_planted")) { action = new Grab("carrot_planted"); this.AvailableActions.Add(action); } if (WorldHas("axe")) { action = new Grab("axe"); this.AvailableActions.Add(action); } if (WorldHas("pickaxe")) { action = new Grab("pickaxe"); this.AvailableActions.Add(action); } if (WorldHas("torch")) { action = new Grab("torch"); this.AvailableActions.Add(action); } if (Possesses("log", 2) && Possesses("cutgrass", 3)) { action = new Build("campfire"); this.AvailableActions.Add(action); } if (Possesses("log", 2) && Possesses("rocks", 12)) { action = new Build("firepit"); this.AvailableActions.Add(action); } if (Possesses("cutgrass", 2) && Possesses("twigs", 2)) { action = new Build("torch"); this.AvailableActions.Add(action); } if (Possesses("twigs", 1) && Possesses("flint", 1)) { action = new Build("axe"); this.AvailableActions.Add(action); } if (Possesses("twigs", 2) && Possesses("flint", 2)) { action = new Build("pickaxe"); this.AvailableActions.Add(action); } if (Possesses("berries")) { action = new Eat("berries"); this.AvailableActions.Add(action); } if (Possesses("carrot")) { action = new Eat("carrot"); this.AvailableActions.Add(action); } if (Possesses("torch")) { action = new Equip("torch"); this.AvailableActions.Add(action); } if (IsEquipped("torch")) { action = new Unequip("torch"); this.AvailableActions.Add(action); } }