Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            ClearPlacer();
        }
        if (m_objectToPlace)
        {
            m_objectToPlace.IsPlacing(true);

            //Get mouse point
            Vector3 placeLoc = GetPlaceLoc();

            //Show preview -- will show whether it can be placed in that spot or not
            ShowPreview(placeLoc);

            //Snap preview to snappable locations

            //Place object
            //TODO:  make sure placeLoc is in playable bounds
            if (Input.GetMouseButtonDown(0) && !MouseInput.IsPointerOverUIElement())
            {
                //Instantiate(m_objectToPlace).transform.position = placeLoc;
                m_objectToPlace.Place(placeLoc);
            }
        }
        else if (m_destroy)
        {
            GameObject toDestroy = GetObjectAtMouse();
            if (toDestroy && Input.GetMouseButtonDown(0))
            {
                Placeable placeObj = toDestroy.GetComponent <Placeable>();
                if (placeObj)
                {
                    placeObj.DestroyThis();
                }
            }
        }
    }