private static void OnLeftToolbarGUI()
        {
            if (GUILayout.Button(new GUIContent("序列化模块占位"), ToolbarStyles.toolbarbutton))
            {
                MechaComponent.SerializeMechaComponentOccupiedPositions();
            }

            GUILayout.FlexibleSpace();
        }
    static IEnumerator Co_Render()
    {
        ClientLevelManager.Instance.CurrentClientLevel.gameObject.SetActive(false);
        ClientBattleManager.Instance.MechaContainerRoot.gameObject.SetActive(false);
        Camera     camera          = CameraManager.Instance.MainCamera;
        Quaternion oriRot          = camera.transform.rotation;
        Quaternion topDownViewRot  = Quaternion.Euler(90, 0, 0);
        float      ori_FieldOfView = camera.fieldOfView;

        camera.fieldOfView    = 6f;
        CameraFollow.NeedLerp = false;

        foreach (KeyValuePair <string, MechaComponentConfig> kv in ConfigManager.MechaComponentConfigDict)
        {
            string             filename     = Application.dataPath + "/../../Arts/MechaComponentScreenShots/" + kv.Key + ".png";
            MechaComponentInfo mci          = new MechaComponentInfo(kv.Value, Quality.Common);
            GridRect           boundingRect = mci.IInventoryItemContentInfo_OriginalOccupiedGridPositions.GetBoundingRectFromListGridPos();
            if (boundingRect.size.x != boundingRect.size.z)
            {
                camera.transform.rotation = topDownViewRot;
            }
            else
            {
                camera.transform.rotation = oriRot;
            }

            if (boundingRect.size.x == 1 && boundingRect.size.z == 1)
            {
                camera.fieldOfView = 6f;
            }
            else
            {
                camera.fieldOfView = 10f;
            }

            yield return(new WaitForSeconds(0.1f));

            MechaComponent mc = MechaComponent.BaseInitialize_Editor(mci, null);
            mc.transform.rotation = Quaternion.Euler(0, mc.ScreenShotAngle, 0);
            CaptureScreenShot.CaptureTransparentScreenShot(camera, 800, 800, filename);
            DestroyImmediate(mc.gameObject);
            yield return(new WaitForSeconds(0.1f));
        }

        camera.transform.rotation = oriRot;
        camera.fieldOfView        = ori_FieldOfView;
        CameraFollow.NeedLerp     = true;
        ClientLevelManager.Instance.CurrentClientLevel.gameObject.SetActive(true);
        ClientBattleManager.Instance.MechaContainerRoot.gameObject.SetActive(true);
    }
Beispiel #3
0
    private static bool ProcessMechaComponentPrefab(MechaComponent component)
    {
        component.transform.position = Vector3.zero;
        component.transform.rotation = Quaternion.identity;
        MechaComponentGridRoot root = component.MechaComponentGridRoot;

        root.RefreshConfig();
        GridPos center = root.GetOccupiedPositions().GetBoundingRectFromListGridPos().center;

        foreach (MechaComponentGrid grid in root.mechaComponentGrids)
        {
            grid.transform.Translate(new Vector3(-center.x * ConfigManager.GridSize, 0, -center.z * ConfigManager.GridSize));
        }

        foreach (MechaComponentModel model in component.GetComponentsInChildren <MechaComponentModel>())
        {
            model.transform.Translate(new Vector3(-center.x * ConfigManager.GridSize, 0, -center.z * ConfigManager.GridSize));
        }

        return(center.x != 0 || center.z != 0);
    }
    public void Init()
    {
        DragProcessor <BackpackItem> dragProcessor_BackpackItem = new DragProcessor <BackpackItem>();

        dragProcessor_BackpackItem.Init(
            UIManager.Instance.UICamera,
            LayerManager.Instance.LayerMask_BackpackItemGrid,
            (out Vector2 mouseScreenPos) =>
        {
            if (ControlManager.Instance.BuildingInputActionEnabled)
            {
                mouseScreenPos = ControlManager.Instance.Building_MousePosition;
                return(true);
            }
            else
            {
                mouseScreenPos = Vector2.zero;
                return(false);
            }
        },
            ScreenMousePositionToWorld_BackpackDragArea,
            delegate(BackpackItem bi, Collider collider, DragProcessor dragProcessor) { },
            delegate(BackpackItem bi, Collider collider, DragProcessor dragProcessor) { }
            );

        DragProcessor <MechaComponentDropSprite> dragProcessor_MechaComponentDropSprite = new DragProcessor <MechaComponentDropSprite>();

        dragProcessor_MechaComponentDropSprite.Init(
            CameraManager.Instance.MainCamera,
            LayerManager.Instance.LayerMask_ItemDropped,
            (out Vector2 mouseScreenPos) =>
        {
            if (ControlManager.Instance.BuildingInputActionEnabled)
            {
                mouseScreenPos = ControlManager.Instance.Building_MousePosition;
                return(true);
            }
            else
            {
                mouseScreenPos = Vector2.zero;
                return(false);
            }
        },
            ScreenMousePositionToWorld_MechaEditorInventory,
            delegate(MechaComponentDropSprite mcds, Collider collider, DragProcessor dragProcessor)
        {
            Ray ray = CameraManager.Instance.MainCamera.ScreenPointToRay(ControlManager.Instance.Building_MousePosition);
            MechaComponentInfo mci = mcds.MechaComponentInfo.Clone();
            ClientBattleManager.Instance.PlayerMecha.MechaInfo.AddMechaComponentInfo(mci, GridPosR.Zero);
            MechaComponent mc = ClientBattleManager.Instance.PlayerMecha.MechaComponentDict[mci.GUID];
            GridPos gp        = GridUtils.GetGridPosByMousePos(ClientBattleManager.Instance.PlayerMecha.transform, ray, Vector3.up, ConfigManager.GridSize);
            mci.InventoryItem.SetGridPosition(gp);
            DragManager.Instance.CurrentDrag = mc.GetComponent <Draggable>();
            DragManager.Instance.CurrentDrag.SetOnDrag(true, collider, dragProcessor);
            mcds.PoolRecycle();
        },
            delegate(MechaComponentDropSprite mcds, Collider collider, DragProcessor dragProcessor) { }
            );

        DragManager.Instance.Init(
            () => ControlManager.Instance.Building_MouseLeft.Down,
            () => ControlManager.Instance.Building_MouseLeft.Up,
            Debug.LogError,
            LayerManager.Instance.LayerMask_DragAreas);
        DragProcessor <MechaComponent> dragProcessor_MechaComponent = new DragProcessor <MechaComponent>();

        dragProcessor_MechaComponent.Init(
            CameraManager.Instance.MainCamera,
            LayerManager.Instance.LayerMask_ComponentHitBox_Player,
            (out Vector2 mouseScreenPos) =>
        {
            if (ControlManager.Instance.BuildingInputActionEnabled)
            {
                mouseScreenPos = ControlManager.Instance.Building_MousePosition;
                return(true);
            }
            else
            {
                mouseScreenPos = Vector2.zero;
                return(false);
            }
        }
            ,
            ScreenMousePositionToWorld_MechaEditorInventory,
            delegate(MechaComponent mc, Collider collider, DragProcessor dragProcessor) { },
            delegate(MechaComponent mc, Collider collider, DragProcessor dragProcessor) { }
            );
    }