public void Buy(GameObject restFab) { //Add to activePlayer's buildings WorldTile newTile = Instantiate(restFab, tile.transform.position, Quaternion.identity).GetComponent <WorldTile>(); newTile.building = ScriptableObject.CreateInstance <BuildingRestaurant>(); BuildingRestaurant restaurantScript = (BuildingRestaurant)newTile.building; GameController.Instance().activePlayer.AddResteraunt(restaurantScript); newTile.building.tile = newTile; newTile.building.canvas = canvas; newTile.district = tile.district; Debug.Log("Transfer district to bought tile" + newTile.district); newTile.building.name = "Player " + GameController.Instance().GetPlayerNumber().ToString() + "'s Restaurant"; newTile.building.world = world; DistrictDisplay display = tile.gameObject.GetComponentInChildren <DistrictDisplay>(); newTile.gameObject.GetComponentInChildren <DistrictDisplay>().SetBorders(display.GetLayout(), display.GetColor()); world.allTiles.Add(newTile.gameObject); world.allTiles.Remove(tile.gameObject); tile.UnClick(); Destroy(tile.gameObject); //sound spendMoney.PlayOneShot(sfx_currency_spend_money); }
public WorldTile Buy(GameObject restFab, int playerNumber) { //Add to purchaser's buildings WorldTile newTile = Instantiate(restFab, tile.transform.position, Quaternion.identity).GetComponent <WorldTile>(); newTile.building = ScriptableObject.CreateInstance <BuildingRestaurant>(); BuildingRestaurant restaurantScript = (BuildingRestaurant)newTile.building; GameController.Instance().player[playerNumber].AddResteraunt(restaurantScript); newTile.building.tile = newTile; newTile.building.canvas = canvas; newTile.district = tile.district; newTile.building.name = "Player " + (playerNumber + 1).ToString() + "'s Restaurant"; newTile.building.world = world; DistrictDisplay display = tile.gameObject.GetComponentInChildren <DistrictDisplay>(); newTile.gameObject.GetComponentInChildren <DistrictDisplay>().SetBorders(display.GetLayout(), display.GetColor()); world.allTiles.Add(newTile.gameObject); world.allTiles.Remove(tile.gameObject); tile.UnClick(); //sound try { spendMoney.PlayOneShot(sfx_currency_spend_money); } catch { } //After this function, nothing here will run I think. Destroy(tile.gameObject); return(newTile); }
public void PopulateMenu(BuildingRestaurant rest) { foreach (RestaurantRecipe rr in rest.recipes) { CreateMenuButton(rr); Debug.Log("Created a menu button"); } }
public void PopulateMenu() { thisResturant = resturnatPopMenu.GetComponent <RestaurantUI>().building; foreach (RestaurantRecipe r in thisResturant.recipes) { PopulateMenuButtons(r); Debug.Log("Created a menu button"); } }
public void SetUp(RestaurantRecipe rr) { isSetup = true; thisRecipe = rr.recipe; thisRR = rr; thisRestruant = GameController.Instance().activePlayer.restaurantClicked; costSlider.value = rr.multiplier; UpdateText(); }
public void AddResteraunt(BuildingRestaurant restaurant) { ownedRestaurants.Add(restaurant); //Hey, for this line instead of finding it you should put a reference to it in the UIManager and get it from there. //Find is convenient but can be a bit slow and will break if someone renames the component //RestaurantLocalScrollView localButton = GameObject.Find("LocationScrollView").GetComponent<RestaurantLocalScrollView>(); // creates a reference of the resturant for the empire panel, so we can add chefs to them Debug.Log("Added Resteraunt to list that cost: " + ownedRestaurants[ownedRestaurants.Count - 1].price); }
public void ClearMenu(BuildingRestaurant rest) { foreach (Transform child in content) { Destroy(child.gameObject); Debug.Log("Destroyed child"); } foreach (GameObject button in rest.recipeButtons) { Destroy(button); Debug.Log("Destroyed stuff"); } }
public void SliderChange() { if (costSlider.value != thisRR.multiplier) { thisRestruant = GameController.Instance().activePlayer.restaurantClicked; Debug.Log("The slider value we just changes it to is " + costSlider.value); double sliderValue = (double)costSlider.value; thisRR.ChangeRecipeCost(sliderValue); UpdateText(); } else { Debug.Log("Cost slider and ResturantRecipe multiplier value the same"); } }
private void OnEnable() { thisRest = restaurantUI.building; try { for (int i = 0; i < thisRest.recipes.Count; i++) { if (i == 3) { break; } buttons[i].Setup(GameController.Instance().activePlayer.restaurantClicked.recipes[i]); } } catch { } }
public void CreateBuildingReferences() { Debug.Log("Checked Content Count of: " + gameController.activePlayer.savedRecipies.Count); for (int i = 0; i < gameController.activePlayer.savedRecipies.Count; i++) { GameObject newButton = Instantiate(buttonPrefab.gameObject); newButton.transform.parent = content; content.sizeDelta = new Vector2(content.rect.width, content.rect.height + 20); newButton.GetComponentInChildren <Text>().text = gameController.activePlayer.savedRecipies[i].name; newButton.transform.localScale = new Vector3(1, 1, 1); MenuAddButton buttonScript = newButton.GetComponentInChildren <MenuAddButton>(); BuildingRestaurant thisRestaurant = restaurantUI.GetComponent <RestaurantUI>().building; Debug.Log("UI null " + (restaurantUI == null).ToString()); Debug.Log("building null " + (thisRestaurant == null).ToString()); Debug.Log("recipe: " + gameController.activePlayer.savedRecipies[i] + " restaurant" + thisRestaurant); buttonScript.thisRecipe = gameController.activePlayer.savedRecipies[i]; //Must fill the reference to the building restaurant buttonScript.thisRestaurant = thisRestaurant; } }
public void SetUp(Recipe recipe, BuildingRestaurant building) { isSetup = true; Debug.Log("RecipeCost building = " + building.GetInstanceID()); thisRecipe = recipe; thisRestruant = building; Debug.Log("Recipe cost says that this resturANT has " + building.recipes.Count + " resturnat recipes"); for (int i = 0; i < building.recipes.Count; i++) { if (thisRecipe == building.recipes[i].recipe) { thisRR = building.recipes[i]; break; } } costSlider.value = 1; UpdateText(); Debug.Log("Restaurant from PlayerData " + GameController.Instance().activePlayer.restaurantClicked.GetInstanceID()); }
public void BuyChef(GameObject chefButton) { BuildingRestaurant selectedRestaurant = restaurantUI.building; Chef selectedChef = chefButton.GetComponent <Chef>(); if (selectedChef.GetChefCost() < GameController.Instance().activePlayer.GetMoney()) { if (selectedRestaurant.chefs.Count < 3) { selectedRestaurant.AddChef(selectedChef); // adds chef to BuildingRestaurant GameController.Instance().activePlayer.AddChef(selectedChef); // adds chef to activePlaeyr PlayerData chefScrollScript.AddAChefButton(selectedChef); // Gives the chef to the Empire Screen GameObject newButtonPrefab = Instantiate(chefInRestaurantPrefab); selectedRestaurant.chefButtons.Add(newButtonPrefab); // Adds chefButton to BuildingRestaurant newButtonPrefab.transform.SetParent(content); newButtonPrefab.transform.localScale = new Vector3(1f, 1f, 1f); Chef chefInRestButton = newButtonPrefab.GetComponent <Chef>(); // Hopefully copying over Chef info to the other chef chefInRestButton.SetName(selectedChef.GetName()); chefInRestButton.SetLevel(selectedChef.GetChefLevel()); chefInRestButton.SetType(selectedChef.GetChefType()); chefInRestButton.SetCost(selectedChef.GetChefCost()); chefInRestButton.SetXP(selectedChef.GetChefXP()); chefInRestButton.UpdateChefText(); Destroy(chefButton.GetComponent <Chef>()); chefButton.AddComponent <Chef>(); Chef newCreatedChef = chefButton.GetComponent <Chef>(); newCreatedChef.UpdateChefText(); // selectedChef.ResetChef(); } else { Debug.Log("There are too many chefs at the restaurant"); } } else { Debug.Log("You dont have enough money for this chef"); } }
public void Update() { if (!isFilled) { for (int i = 0; i < gameController.activePlayer.ownedRestaurants.Count; i++) { if (gameController.activePlayer.ownedRestaurants[i].onChefScreen) { continue; } else { gameController.activePlayer.ownedRestaurants[i].onChefScreen = true; thisRestaurant = gameController.activePlayer.ownedRestaurants[i]; restaurantName.text = gameController.activePlayer.ownedRestaurants[i].name; isFilled = true; // Only have 1 RestaurantLocal Button in the chef Manager, once it has been filled // Instantiate another one in the Scroll View break; } } UpdateText(); } }
public void FillBuildingRestaurant() { thisResturant = resturnatPopMenu.GetComponent <RestaurantUI>().building; }
void Completed(BuildingRestaurant r) { parentLookup[r] = completed; }
public bool HaveRestaurant(BuildingRestaurant restaurant) { return(ownedRestaurants.Contains(restaurant)); }
public void SetThisResturant(BuildingRestaurant restuant) { thisResturant = restuant; }