void Stockify() { if (Game.currentScene == Scene.Play) { Pathfinding.ChangeArea(GetModuleRect(), true); } DestroyModule(); PurchaseMenu.AddStock(this); }
void PlaceModule() { bool allowPlacement = CanPlaceAtPos(placePos).Length == 0; isRotting = false; // Figure out if there is a module on mouse position, and figure out what type. Ray ray = new Ray(placePos + Vector3.forward * camDepth, Vector3.forward * -camDepth * 2f); RaycastHit hit; if (Physics.Raycast(ray, out hit, -camDepth * 2f, turretLayer)) { // Handle module placement on another module placePos = hit.transform.position + (placePos - hit.collider.transform.position); allowPlacement = CanPlaceAtPos(placePos).Length == 0; } // I'll go and fix the wall blocking bug now. I'm gonna go for the first solution described in my Reddit reply for now. if (allowPlacement) { if (Game.currentScene == Scene.Play) { ConstructionFlashShrink.Create(Vector3.one * pModule.moduleClass * 16f, placePos - Vector3.back * (camDepth + 5)); } Game.PlaySFXAudio(placementAudio); GameObject m = (GameObject)Instantiate(purchaseModule, placePos, placementParent.GetChild(0).rotation); m.BroadcastMessage("ResetMaterial"); rangeIndicator.NullifyParent(); if (Game.currentScene == Scene.Play) { if (purchaseMenu.stockModules.ContainsKey(purchaseModule)) { purchaseMenu.stockModules[purchaseModule]--; if (purchaseMenu.stockModules[purchaseModule] < 1) { purchaseMenu.stockModules.Remove(purchaseModule); } PurchaseMenu.UpdateButtons(); } else { Game.credits -= currentCost; } } m.transform.SetParent(hit.transform); } if (!Input.GetButton("LShift")) { CancelPurchase(); } }
public void Initialize() { cur = this; stockModules = new Dictionary <GameObject, int> (); CollectAllPurchaseables(); if (Game.currentScene == Scene.AssemblyBuilder) { LoadStandardButtons(); } }
public virtual void Purchase() { if (PlayerInput.TryUseCredits(cost)) { GameObject newObject = Instantiate(obj); IPlaceable placeable = newObject.GetComponent <IPlaceable> (); PurchaseMenu.PickUp(placeable); } UpdateInteractable(); }
public static void AddStock(Module module) { PurchaseMenu menu = PurchaseMenu.cur; GameObject obj = menu.GetModulePrefab(module.moduleName); if (menu.stockModules.ContainsKey(obj)) { menu.stockModules[obj]++; } else { menu.stockModules.Add(obj, 1); } UpdateButtons(); }
// Use this for initialization private void Awake() { menu = this; }
public void OpenPurchaseMenu() { PurchaseMenu.Open(); }