// Use this for initialization void Start() { BeerTree bT = MapGenerator(StartGame.getLevel()); GenerateSprites(bT); GeneratePipes(bT); beerTree = bT; //levelCameraSize = new int[4]{ 2, 3, 4, 5 }; SetMainCamera(1f, 2f); }
void GenerateSprites(BeerTree bt) { SwitchNode startNode = bt.start; GenerateSprite(startNode); }
void GeneratePipes(BeerTree bt) { SwitchNode startNode = bt.start; GeneratePipes(startNode); }
BeerTree MapGenerator(int numberOfSwitches) { SwitchNode parentSwitch = new SwitchNode(new Vector2(0.0f, 0.0f), "SWITCH_ROOT", new Switch(), true); BeerTree bT = new BeerTree(parentSwitch); int numOfSwitches = numberOfSwitches; float y = 0.0f; int idSwitchCounter = 1; int numOfHouses = 0; int idHouseCounter = 1; for (int i = 0; i < numOfSwitches; i++) { y = y - 3; SwitchNode newSwitch = new SwitchNode(new Vector2(0.0f, y), "SWITCH_" + idSwitchCounter++, new Switch(), false); if (i == numOfSwitches - 1) { lastSwitchYcoordinate = y; } numOfHouses = RandomUtils.GetRandomNumber(1, 4); if (i == 0) { bT.AddSwitch(newSwitch, "SWITCH_ROOT"); } else { bT.AddSwitch(newSwitch, parentSwitch.nodeId); } parentSwitch = newSwitch; switch (numOfHouses) { case 1: { HouseNode leftHouse = new HouseNode(new House(), new Vector2(-5.0f, newSwitch.coordinates.y), "HOUSE_" + idHouseCounter++); bT.AddHouse(leftHouse, newSwitch.nodeId); break; } case 2: { HouseNode rightHouse = new HouseNode(new House(), new Vector2(5.0f, newSwitch.coordinates.y), "HOUSE_" + idHouseCounter++); bT.AddHouse(rightHouse, newSwitch.nodeId); break; } default: { HouseNode leftHouse = new HouseNode(new House(), new Vector2(-5.0f, newSwitch.coordinates.y), "HOUSE_" + idHouseCounter++); bT.AddHouse(leftHouse, newSwitch.nodeId); HouseNode rightHouse = new HouseNode(new House(), new Vector2(5.0f, newSwitch.coordinates.y), "HOUSE_" + idHouseCounter++); bT.AddHouse(rightHouse, newSwitch.nodeId); break; } } } return(bT); }
// Use this for initialization void Start() { beerTree = LevelLoader.getInstance().GetBeerTree(); direction = new Vector2(0.0f, -1.0f); lastVisitedSwitchNode = beerTree.getRootNode(); }