Exemplo n.º 1
0
    private void OnSceneGUI()
    {
                #if UNITY_EDITOR
        selectedRoomInfo = target as RoomInfo;

        if (null == selectedRoomInfo)
        {
            return;
        }

        if (null == selectedRoomInfo.roomRectCollider)
        {
            Debug.Log("Null RoomRectCollider");
            selectedRoomInfo.roomRectCollider = selectedRoomInfo.GetComponent <Collider>();
            if (null == selectedRoomInfo.roomRectCollider)
            {
                selectedRoomInfo.roomRectCollider           = selectedRoomInfo.gameObject.AddComponent <BoxCollider> ();
                selectedRoomInfo.roomRectCollider.isTrigger = true;
            }
            return;
        }

        if (null == selectedRoomInfo.cameraRectCollider)
        {
            Debug.Log("Null CameraCollider");
            selectedRoomInfo.cameraRectCollider = selectedRoomInfo.GetComponentInChildren <Rect3D> ();
            if (null == selectedRoomInfo.cameraRectCollider || selectedRoomInfo.cameraRectCollider.rectName != cameraRectName)
            {
                GameObject newRect3D = new GameObject("CamRect3D");
                selectedRoomInfo.cameraRectCollider = newRect3D.AddComponent <Rect3D> ();
                newRect3D.transform.parent          = selectedRoomInfo.transform;
                newRect3D.transform.localPosition   = Vector3.zero;
            }
        }

        DrawRoomColliderRect(selectedRoomInfo);
        DrawRoomCameraRect(selectedRoomInfo);
                #endif
    }
Exemplo n.º 2
0
    private IEnumerator TransitionRoutine()
    {
        new GameFlowEvent(EGameFlowAction.StartTransition).Push();
        // Teleport the player to the nex room
        m_PlayerTransform.position = new Vector3(m_PlayerNode.position.x, m_PlayerTransform.position.y, m_PlayerTransform.position.z);
        m_PlayerMovement.Freeze();

        yield return(new WaitForSecondsRealtime(m_TransitionTime));

        m_CurrentMinX = m_EnterRoom.GetMinX();
        m_CurrentMaxX = m_EnterRoom.GetMaxX();
        m_CurrentMinY = m_EnterRoom.GetMinY();
        m_CurrentMaxY = m_EnterRoom.GetMaxY();
        m_EnterRoom.gameObject.SetActive(true);
        RoomEnemy enemies = m_EnterRoom.GetComponent <RoomEnemy>();

        if (enemies != null)
        {
            enemies.ResetEnemies();
        }
        m_ExitRoom.gameObject.SetActive(false);
        m_PlayerMovement.Unfreeze();
        new GameFlowEvent(EGameFlowAction.EndTransition).Push();
    }
Exemplo n.º 3
0
    public static void DrawRoomColliderRect(RoomInfo roomInfo)
    {
        var faces = DrawRectangularWithOutline(roomInfo.roomRectCollider.bounds.center,
                                               roomInfo.roomRectCollider.bounds.extents,
                                               CustomCameraButtonType.CameraRect,
                                               roomInfo.roomRectColor
                                               );

        Handles.color = Color.yellow;
        var colCenter = (roomInfo.roomRectCollider as BoxCollider).center;

        MakeButton(10, roomInfo.transform.position + colCenter, buttonSize * 2.5f, CustomCameraButtonType.RoomRect);

        if (selectedIndex == 10 && buttonType == CustomCameraButtonType.RoomRect)
        {
            EditorGUI.BeginChangeCheck();

            colCenter = Handles.DoPositionHandle(colCenter + roomInfo.transform.position, Quaternion.identity) - roomInfo.transform.position;

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(roomInfo, "Change Center");
                EditorUtility.SetDirty(roomInfo);
                (roomInfo.roomRectCollider as BoxCollider).center = colCenter;
            }
        }

        for (int i = 0; i < 6; i++)
        {
            var midPoint = Vector3.zero;
            for (int j = 0; j < 4; j++)
            {
                midPoint += faces [i] [j];
            }
            midPoint     /= 4f;
            Handles.color = Color.white;
            MakeButton(i, midPoint, buttonSize, CustomCameraButtonType.RoomRect);
            if (selectedIndex == i && buttonType == CustomCameraButtonType.RoomRect)
            {
                EditorGUI.BeginChangeCheck();
                midPoint = Handles.DoPositionHandle(midPoint, Quaternion.identity);

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(roomInfo, "Change Collider Rect");
                    EditorUtility.SetDirty(roomInfo);
                    if (i == 0 || i == 1)                      // Front or Back
                    {
                        var col    = roomInfo.GetComponent <BoxCollider> ();
                        var tmpVec = col.extents;
                        tmpVec.z    = Mathf.Abs(midPoint.z - (col.transform.position.z + col.center.z));
                        col.extents = tmpVec;
                    }
                    else if (i == 2 || i == 3)                       // right side or left side
                    {
                        var col    = roomInfo.GetComponent <BoxCollider> ();
                        var tmpVec = col.extents;
                        tmpVec.x    = Mathf.Abs(midPoint.x - (col.transform.position.x + col.center.x));
                        col.extents = tmpVec;
                    }
                    else if (i == 4 || i == 5)                       // top or down
                    {
                        var col    = roomInfo.GetComponent <BoxCollider> ();
                        var tmpVec = col.extents;
                        tmpVec.y    = Mathf.Abs(midPoint.y - (col.transform.position.y + col.center.y));
                        col.extents = tmpVec;
                    }
                }
            }
        }
    }