Beispiel #1
0
    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;
        }
    }
Beispiel #2
0
    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();
            }
        }
    }
Beispiel #3
0
 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);
 }
Beispiel #4
0
 void clickOnPlacement()
 {
     if (Input.GetMouseButtonDown(0) && placingObject == null)
     {
         RaycastHit hit;
         Vector3    mousePos = Input.mousePosition;
         if (Physics.Raycast(Camera.main.ScreenPointToRay(mousePos), out hit, Mathf.Infinity, furnitureLayer))
         {
             placingObject       = hit.transform.gameObject;
             meshBounds          = placingObject.GetComponent <Collider>().bounds;
             placingObject.layer = 0;
             ignoredPlanes       = getIgnorableTransforms(placingObject);
             OnPlacementInteract.Invoke(true);
         }
         if (placingObject.GetComponent <WorldInteractive>() != null)
         {
             placingObject.GetComponent <WorldInteractive>().beingMoved = true;
         }
     }
 }