Exemplo n.º 1
0
    private void CheckDisplayUpdate()
    {
        //See if the mouse is over any point
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out hit))
        {
            Vector2Int i             = momDisplay.displayCenter;
            Transform  centerDisplay = momDisplay.displays[i.x][i.y].transform;

            Transform t = hit.collider.transform;

            //Only place the new object in the centre display
            if (!t.IsChildOf(centerDisplay))
            {
                return;
            }

            //Check that the square in the game space is free
            LevelMoment moment = momDisplay.GetFocusedMoment();

            Vector3Int j = new Vector3Int(Mathf.RoundToInt(t.localPosition.x),
                                          Mathf.RoundToInt(t.localPosition.y + 1),
                                          Mathf.RoundToInt(t.localPosition.z));

            if (!moment.IsFree(j))
            {
                return;
            }


            displayTrans.position    = t.position + Vector3.up;
            displayTrans.eulerAngles = t.eulerAngles;

            DisplayData data = centerDisplay.GetComponentInChildren <DisplayData>();

            displayTrans.parent = data.centeringTransform;
            tempObj.SetActive(true);
        }
        else
        {
            tempObj.SetActive(false);
        }
    }
Exemplo n.º 2
0
    private void CheckDisplayUpdate()
    {
        //See if the mouse is over any point
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out hit))
        {
            Vector2Int i             = momDisplay.displayCenter;
            Transform  centerDisplay = momDisplay.displays[i.x][i.y].transform;

            Transform t = hit.collider.transform;

            //Only place the new object in the centre display
            if (!t.IsChildOf(centerDisplay))
            {
                return;
            }

            //Check that the square in the game space is free
            LevelMoment moment = momDisplay.GetFocusedMoment();

            Vector3Int j = new Vector3Int(Mathf.RoundToInt(t.localPosition.x),
                                          Mathf.RoundToInt(t.localPosition.y),
                                          Mathf.RoundToInt(t.localPosition.z));


            key = moment.level[j.x, j.y, j.z];

            if (IsRemoveable(key))
            {
                overI = j;

                Highlight(t);
            }
            else
            {
                UnHighlight();
            }
        }
        else
        {
            UnHighlight();
        }
    }