/// <summary> /// Metoda powoduje anulowanie stawiania lub sprzedania budynku /// </summary> public void CancelGhost() { GhostFollowingButtonScript ghostFollowScript = GhostFollowingButton.GetComponent <GhostFollowingButtonScript>(); ghostFollowScript.UnsetGhostObject(); GhostFollowingButton.SetActive(false); if (GhostObject == null) { return; } Building buildingScript = GhostObject.GetComponent <Building>(); if (buildingScript != null) { if (!buildingScript.IsPlacedForReal) { GameObject.Destroy(GhostObject); } else { GhostObject.transform.position = ghostOriginalPosition; } } Helper.GetGUIManager().EditMode_SetGhostPositionGroupVisible(false); GhostObject = null; }
/// <summary> /// Jeżeli ghost jest wybudowanym wczesniej budynkiem to go sprzedaje. ( po kliknięciu przycisku sell ) /// </summary> public void SellGhost() { GhostFollowingButtonScript ghostFollowScript = GhostFollowingButton.GetComponent <GhostFollowingButtonScript>(); ghostFollowScript.UnsetGhostObject(); GhostFollowingButton.SetActive(false); Building buildingScript = GhostObject.GetComponent <Building>(); if (buildingScript != null) { if (buildingScript.IsPlacedForReal) { GameStats.Instance.AddMoney(buildingScript.GetSellPrice()); } } Helper.GetGUIManager().EditMode_SetGhostPositionGroupVisible(false); Helper.GetGUIManager().GameStats_TotalPeopleCountUpdate(); GameObject.Destroy(GhostObject); GhostObject = null; }
/// <summary> /// Zamienia obiekt Ghost na budynek /// </summary> public void DropObject() { GhostScript ghost = GhostObject.GetComponent <GhostScript>(); if (ghost.canPlace) { // Place object ghost.isGhost = false; // Hide following button to place button GhostFollowingButtonScript ghostFollowScript = GhostFollowingButton.GetComponent <GhostFollowingButtonScript>(); ghostFollowScript.UnsetGhostObject(); GhostFollowingButton.SetActive(false); // Ustawianie budynku jako child grupy budynków GhostObject.transform.SetParent(Helper.GetBuildingsGroup().transform); // Informowanie budowli, że została wybudowana Building buildingScript = GhostObject.GetComponent <Building>(); if (buildingScript != null) { if (!buildingScript.IsPlacedForReal) { buildingScript.IsPlacedForReal = true; // Wydanie pieniędzy GameStats.Instance.SpendMoney(buildingScript.GetCost()); GameStats.Instance.AddExperience(buildingScript.BuildingBuyExperience); } } GhostObject = null; Helper.GetGUIManager().EditMode_SetGhostPositionGroupVisible(false); Helper.GetGUIManager().GameStats_TotalPeopleCountUpdate(); } }