void startPlacement(BuyObject buyObject) { if (placingObject != null) { Destroy(placingObject); OnPlacementInteract?.Invoke(true, true); } else { OnPlacementInteract?.Invoke(true); } placingObject = Instantiate(buyObject.GetBuyObjectScriptable().prefab); placingObject.transform.rotation = Quaternion.Euler(0, 130, 0); if (placingObject.GetComponent <BuyObjectBehaviour>() == null) { placingObject.AddComponent <BuyObjectBehaviour>(); } placingObject.GetComponent <BuyObjectBehaviour>().Initialize(buyObject.BuyValue, buyObject.SatisfactionGain); currentBuyObject = buyObject; meshBounds = placingObject.GetComponent <Collider>().bounds; ignoredPlanes = getIgnorableTransforms(placingObject); PointAndClickMovement.setMovementStatus(false); MainCanvas.mainCanvas.freezeOverride = true; SetPlacing(true); if (placingObject.GetComponent <WorldInteractive>() != null) { placingObject.GetComponent <WorldInteractive>().beingMoved = true; } }
void placePlacement(bool buying) { RaycastHit hit; Vector3 mousePos = Input.mousePosition; if (Input.GetMouseButtonDown(1)) { if (Physics.SphereCast(Camera.main.ScreenPointToRay(mousePos), 1, out hit, Mathf.Infinity, placementLayer)) { if (placingObject.GetComponent <WorldInteractive>() != null) { placingObject.GetComponent <WorldInteractive>().beingMoved = false; } OnPlacementInteract?.Invoke(false); placingObject.layer = 12; if (buying) { callForPurchase(); Debug.Log("HÄr"); } placingObject = null; SetPlacing(false); SetMoving(false); PointAndClickMovement.setMovementStatus(true); MainCanvas.mainCanvas.freezeOverride = false; resetPlaneLayers(); } } }
void startMovement() { SetMoving(true); placingObject = null; PointAndClickMovement.setMovementStatus(false); MainCanvas.mainCanvas.freezeOverride = true; if (placingObject.GetComponent <WorldInteractive>() != null) { placingObject.GetComponent <WorldInteractive>().beingMoved = true; } }
void resetInteraction() { SetPlacing(false); SetMoving(false); PointAndClickMovement.setMovementStatus(true); MainCanvas.mainCanvas.freezeOverride = false; ignoredPlanes.Clear(); if (placingObject != null) { Destroy(placingObject); currentBuyObject = null; } OnPlacementInteract?.Invoke(false); }