public Carrier(string firstname, string lastname, Town hometown, LumberMill workplace) : base(firstname, lastname, hometown) { CurrentTask = CarrierTask.None; IsBig = false; ObjectSprite = new TileEngine.Sprite(11, Position.X, Position.Y, 32, 32); Workplace = workplace; Start(); }
public static bool AddBuilding(Tile givenTile, string buildingType, Character builder) { Building newBuilding; switch (buildingType) { case "Farm": newBuilding = new Farm(); break; case "LumberMill": newBuilding = new LumberMill(); break; case "City": newBuilding = new City(); break; case "Road": newBuilding = new Road(); break; default: newBuilding = null; throw new KeyNotFoundException("The building type: " + buildingType + " does not exist and an attempt was made to create it"); } if (newBuilding != null && builder.RulesDomain(givenTile.GetDomain())) { givenTile.AddBuilding(newBuilding); // DomainDictionary.GetDomain(givenTile.GetDomain()).AddBuilding(givenTile.GetPosition()); return(true); } else { Debug.Log("You can't build " + newBuilding + " at " + givenTile.GetDomain()); return(false); } }
public void AddBuilding(Tile givenTile, Character givenCharacter, string buildingType) { Building newBuilding; switch (buildingType) { case "Farm": newBuilding = new Farm(); break; case "LumberMill": newBuilding = new LumberMill(); break; case "City": newBuilding = new City(); break; case "Road": newBuilding = new Road(); break; default: newBuilding = null; Debug.Log("Building doesn't exist"); break; } if (newBuilding != null && givenCharacter.RulesDomain(givenTile.GetDomain())) { givenTile.AddBuilding(newBuilding); throw new System.NotImplementedException(); //DomainDictionary.GetDomain(givenTile.GetDomain()).AddBuilding(givenTile.GetPosition()); } else { Debug.Log("You can't build " + newBuilding + " at " + givenTile.GetDomain()); } }
protected override void MakeDecision(EnvironmentEvent latestEvent) { CurrentState = WoodcutterState.Thinking; switch (CurrentTask) { case (WoodcutterTask.None): { // TODO other behaviors // if hungry, go eat // if thirsty, go drink // else, go cut wood Tree tree = FindUnusedTree(); if (tree != null) { CurrentTask = WoodcutterTask.GoingToTree; CurrentState = WoodcutterState.Walking; GoTo(tree.Position); } break; } case (WoodcutterTask.GoingToTree): { Tree tree = FindUnusedTree(); if (tree != null) { if (Position.IsNextTo(tree.Position)) { if (tree.Consort(this)) { CurrentState = WoodcutterState.Cutting; CurrentTask = WoodcutterTask.PickUpWood; SetFacingDirection(tree.Position); } else { Warn(EnvironmentEvent.Auto); } } else // keep going to tree { CurrentState = WoodcutterState.Walking; GoTo(tree.Position); } } break; } case (WoodcutterTask.PickUpWood): { if (latestEvent == EnvironmentEvent.TreeCutted) { Tree tree = FindMyTree(); if (tree != null) { tree.Deconsort(); TileMap.Tiles[tree.Position.X, tree.Position.Y].RemoveObject(tree); WoodCount++; CurrentTask = WoodcutterTask.GoingToLumberMill; CurrentState = WoodcutterState.Walking; Warn(EnvironmentEvent.WoodPickedUp); } } break; } case (WoodcutterTask.GoingToLumberMill): { LumberMill lumbermill = Pathfinding.FindClosest <LumberMill>(Position); if (lumbermill != null) { if (Position.IsNextTo(lumbermill.Position)) { WoodCount -= lumbermill.StoreWood(WoodCount); CurrentTask = WoodcutterTask.None; Warn(EnvironmentEvent.WoodStored); } else { CurrentTask = WoodcutterTask.GoingToLumberMill; CurrentState = WoodcutterState.Walking; GoTo(lumbermill.Position); } } break; } default: { break; } } }
private void GenerateBuildings(bool random) { if (random) { Random rand = new Random(); int nbLM = 1;// rand.Next(1, 3); for (int i = 0; i < nbLM; i++) { LumberMill lm = new LumberMill(this); TileMap.PlaceGameObjectRandomly(lm); TileMap.PlaceGameObjectRandomly(new Carrier(this, lm)); } int nbHouse = rand.Next(0, 3); for (int i = 0; i < nbHouse; i++) { TileMap.PlaceGameObjectRandomly(new House(this)); } //int nbBuildSite = rand.Next(1, 2); //for (int i = 0; i < nbBuildSite; i++) //{ // TileMap.PlaceGameObjectRandomly(new ConstructionSite(this)); //} } else { TileMap.Tiles[18, 10].AddObject(new LumberMill(this, false)); TileMap.Tiles[15, 10].AddObject(new House(this, false)); TileMap.Tiles[21, 10].AddObject(new House(this, false)); TileMap.Tiles[16, 14].AddObject(new House(this, false)); TileMap.Tiles[22, 14].AddObject(new House(this, false)); TileMap.Tiles[29, 10].AddObject(new House(this, true)); TileMap.Tiles[31, 14].AddObject(new House(this, true)); TileMap.Tiles[24, 19].AddObject(new House(this, true)); //TileMap.Tiles[29, 10].AddObject(new ConstructionSite(this)); // TODO refactor to Rock object TileMap.Tiles[23, 10].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); TileMap.Tiles[24, 10].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); TileMap.Tiles[26, 10].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); TileMap.Tiles[27, 10].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); TileMap.Tiles[12, 9].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); TileMap.Tiles[12, 10].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); TileMap.Tiles[12, 11].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); TileMap.Tiles[12, 12].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); TileMap.Tiles[12, 13].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); TileMap.Tiles[13, 14].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); TileMap.Tiles[22, 18].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); TileMap.Tiles[21, 19].AddObject(new GameObject() { ObjectSprite = new Sprite(6), IsSolid = true }); } }
public Carrier(Town hometown, LumberMill workplace) : this(NameGenerator.GetFirstname(), NameGenerator.GetLastname(), hometown, workplace) { }