Пример #1
0
    void Start()
    {
        if (terrainEditor == null)
        {
            terrainEditor = gameObject.AddComponent <TerrainEditor>();
        }

        if (editorMenu != null)
        {
            editorMenu.menuToggled.AddListener(ShutEditor);
        }

        terrainEditor.SetSettings(gameSettings);

        editorMenu.loadSaveEvent.AddListener(LoadMap);
        editorMenu.makeSaveEvent.AddListener(SaveMap);

        editingState = new EditingState();
        hoverState   = new HoverState();
        inMenuState  = new InMenuState();

        currentState = editingState;

        FillTileChooser();
        cameraControls.SetSize(gameSettings);
    }
Пример #2
0
        public override void Update(EditorWorldRaycastResult intersection, float deltaTime)
        {
            if (intersection.HitTerrain)
            {
                TerrainRaycastResult terrainIntersection = intersection.TerrainResult;

                if (!TerrainEditor.IsSelecting)
                {
                    lastNonSelectingNormal = terrainIntersection.IntersectionCubeSide.Value;
                }

                if (TerrainEditor.IsSelecting && Input.GetMouseButtonUp(MouseButton.Left))
                {
                    ApplyActionToSelection(TerrainEditor.SelectionBox,
                                           (chunk, blockPos) =>
                    {
                        Block block = Block.CUSTOM;
                        Color color = TerrainEditor.BlockColor;
                        block.R     = color.R;
                        block.G     = color.G;
                        block.B     = color.B;

                        TerrainEditor.SetBlock(chunk, block, blockPos);
                    });
                }
            }
        }
Пример #3
0
        public void validateSlopeMinAngle()
        {
            TerrainEditor ETerrainEditor = "ETerrainEditor";
            float         maxVal         = ETerrainEditor.getSlopeLimitMinAngle();

            ((GuiTextEditCtrl)((GuiControl)"PaintBrushSlopeControl").findObjectByInternalName("SlopeMinAngle", true)).setText(maxVal.AsString());
        }
Пример #4
0
        public void syncBrushInfo()
        {
            GuiControl    TerrainBrushSizeTextEditContainer     = "TerrainBrushSizeTextEditContainer";
            GuiControl    TerrainBrushPressureTextEditContainer = "TerrainBrushPressureTextEditContainer";
            GuiControl    TerrainBrushSoftnessTextEditContainer = "TerrainBrushSoftnessTextEditContainer";
            GuiControl    TerrainSetHeightTextEditContainer     = "TerrainSetHeightTextEditContainer";
            TerrainEditor ETerrainEditor = "ETerrainEditor";

            GuiTextEditCtrl tTerrainBrushSizeTextEditContainer =
                TerrainBrushSizeTextEditContainer.findObjectByInternalName("textEdit", true);

            GuiTextEditCtrl tTerrainBrushPressureTextEditContainer =
                TerrainBrushPressureTextEditContainer.findObjectByInternalName("textEdit", true);

            GuiTextEditCtrl tTerrainBrushSoftnessTextEditContainer =
                TerrainBrushSoftnessTextEditContainer.findObjectByInternalName("textEdit", true);

            GuiTextEditCtrl tTerrainSetHeightTextEditContainer =
                TerrainSetHeightTextEditContainer.findObjectByInternalName("textEdit", true);

            tTerrainBrushSizeTextEditContainer.text     = Util.getWord(ETerrainEditor.getBrushSize(), 0);
            tTerrainBrushPressureTextEditContainer.text = (ETerrainEditor.getBrushPressure() * 100).AsString();
            tTerrainBrushSoftnessTextEditContainer.text = (ETerrainEditor.getBrushSoftness() * 100).AsString();
            tTerrainSetHeightTextEditContainer.text     = (ETerrainEditor.setHeightVal.AsString());

            string brushType = ETerrainEditor.getBrushType();

            Util.eval("EWTerrainEditToolbar-->" + brushType + ".setStateOn(1);");
        }
Пример #5
0
        public static async Task AnalyseAsync(string path)
        {
            foreach (var file in Directory.GetFiles(path, "*.raw", SearchOption.AllDirectories))
            {
                var editor = await TerrainEditor.OpenAsync(file);

                foreach (var chunk in editor.Source.Chunks)
                {
                    {
                        var data = chunk.ShortMap.Data;

                        Console.WriteLine($"MAX = {data.Max()}\tMIN = {data.Min()}\tLEN = {data.Length}");
                    }

                    {
                        var data = chunk.UnknownByteArray1;

                        Console.WriteLine($"MAX = {data.Max()}\tMIN = {data.Min()}\tLEN = {data.Length}\n");
                    }

                    {
                        foreach (var array in chunk.UnknownShortArray)
                        {
                            var data = array;

                            Console.WriteLine($"MAX = {data.Max()}\tMIN = {data.Min()}\tLEN = {data.Length}");
                        }

                        Console.WriteLine();
                    }

                    Console.ReadKey();
                }
            }
        }
Пример #6
0
        public override void onDeactivated()
        {
            if (!isActive)
            {
                return;
            }

            EditorGui             EditorGui               = "EditorGui";
            TerrainPainter        TerrainPainter          = "TerrainPainter";
            GuiWindowCollapseCtrl TerrainPainterPreview   = "TerrainPainterPreview";
            GuiControl            EWTerrainPainterToolbar = "EWTerrainPainterToolbar";
            TerrainEditor         ETerrainEditor          = "ETerrainEditor";

            isActive = false;
            base.onDeactivated();

            EditorGui.writeTerrainEditorSettings();
            map.pop();

            //Copyright Winterleaf Entertainment L.L.C. 2013
            TerrainPainter.setVisible(false);
            TerrainPainterPreview.setVisible(false);
            //Copyright Winterleaf Entertainment L.L.C. 2013
            EWTerrainPainterToolbar.setVisible(false);
            ETerrainEditor.setVisible(false);
        }
Пример #7
0
    //刷新地形mesh
    void RefreshMesh(Event e)
    {
        //Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        Ray inputRay = HandleUtility.GUIPointToWorldRay(e.mousePosition);

        Debug.Log(inputRay.direction);
        RaycastHit hit;
        HexCell    centerCell = null;
        int        centerX    = 0;
        int        centerZ    = 0;

        m_refreshChunkList.Clear();
        if (Physics.Raycast(inputRay, out hit))
        {
            centerCell = HexGrid.instance.GetCell(hit.point);

            if (m_lockedChunk == null || centerCell.chunkParent != m_lockedChunk)
            {
                return;
            }
            TerrainEditor.redoStack.Clear();
            TerrainEditor.UndoAdd(centerCell, m_brush);
            m_refreshChunkList.Add(centerCell.chunkParent);
            centerX = centerCell.coordinates.X;
            centerZ = centerCell.coordinates.Z;
            Vector3 pos = hit.point;

            //整个Cell进行刷新
            if (m_brush.m_brushShapeType == TerrainBrush.BrushShapeType.CellBrush)
            {
                for (int l = 0, z = centerZ; z >= centerZ - m_brush.brushRange + 1; l++, z--)
                {
                    for (int x = centerX - m_brush.brushRange + 1 + l; x <= centerX + m_brush.brushRange - 1; x++)
                    {
                        EditCell(HexGrid.instance.GetCell(new HexCoordinates(x, z)), m_brush);
                    }
                }

                for (int l = 1, z = centerZ + 1; z <= centerZ + m_brush.brushRange - 1; l++, z++)
                {
                    for (int x = centerX - m_brush.brushRange + 1; x <= centerX + m_brush.brushRange - 1 - l; x++)
                    {
                        EditCell(HexGrid.instance.GetCell(new HexCoordinates(x, z)), m_brush);
                    }
                }
                for (int i = 0; i < m_refreshChunkList.Count; i++)
                {
                    m_refreshChunkList[i].Refresh();
                }
            }
            //刷新地形权重图
            else if (m_brush.m_brushShapeType == TerrainBrush.BrushShapeType.CircleBrush)
            {
                //m_brush.PaintPixel(pos.x, pos.z, HexGrid.instance.ChunkWidth, HexGrid.instance.ChunkHeight, UpdateMaterialWeight, null);
            }

            //将修改后的也压入undo栈中,为压入redo栈做准备
            TerrainEditor.UndoAdd(centerCell, m_brush);
        }
    }
Пример #8
0
        public override void onControlDropped(GuiControl control, string dropPoint)
        {
            TerrainEditor ETerrainEditor = "ETerrainEditor";

            string     srcBtn = control["dragSourceControl"];
            GuiControl dstBtn = this;
            GuiControl stack  = this.getParent();

            // Not dropped on a valid Button.
            // Really this shouldnt happen since we are in a callback on our specialized
            // EPainterIconBtn namespace.

            if (stack != dstBtn.getParent() || stack != "EPainterStack".getID())
            {
                console.print("Not dropped on valid control");
                return;
            }
            // Dropped on the original control, no order change.
            // Simulate a click on the control, instead of a drag/drop.
            if (srcBtn == dstBtn)
            {
                dstBtn.call("performClick");
                return;
            }

            int dstIndex = stack.getObjectIndex(dstBtn);

            ETerrainEditor.reorderMaterial(stack.getObjectIndex(srcBtn), dstIndex);

            // select the button/material we just reordered.

            stack.getObject((uint)dstIndex).call("performClick");
        }
Пример #9
0
    void Start()
    {
        _this = this;

        ifID.enabled   = false;
        ifName.enabled = false;

        ifID.text   = "TEST";
        ifName.text = "TEST";

        ifColorR.text = "TEST";
        ifColorG.text = "TEST";
        ifColorB.text = "TEST";
        ifColorA.text = "TEST";

        ifModMovement.text = "TEST";
        ifModVisual.text   = "TEST";

        UpdateDisplay();

        ifColorR.onValueChange.AddListener(new UnityEngine.Events.UnityAction <string>(ifColorR_OnChanged));
        ifColorG.onValueChange.AddListener(new UnityEngine.Events.UnityAction <string>(ifColorG_OnChanged));
        ifColorB.onValueChange.AddListener(new UnityEngine.Events.UnityAction <string>(ifColorB_OnChanged));
        ifColorA.onValueChange.AddListener(new UnityEngine.Events.UnityAction <string>(ifColorA_OnChanged));

        ifModMovement.onValueChange.AddListener(new UnityEngine.Events.UnityAction <string>(ifModMovement_OnChanged));
        ifModVisual.onValueChange.AddListener(new UnityEngine.Events.UnityAction <string>(ifModVisual_OnChanged));

        tEnabledAlpha.onValueChanged.AddListener(new UnityEngine.Events.UnityAction <bool>(tEnabledAlpha_OnChanged));
        tBlocking.onValueChanged.AddListener(new UnityEngine.Events.UnityAction <bool>(tBlocking_OnChanged));
    }
Пример #10
0
        public void deleteMat()
        {
            SimSet        TerrainMaterialSet            = "TerrainMaterialSet";
            SimGroup      TerrainMaterialDlgDeleteGroup = "TerrainMaterialDlgDeleteGroup";
            TerrainEditor ETerrainEditor = "ETerrainEditor";

            if (!this["activeMat"].isObject())
            {
                return;
            }

            // Cannot delete this material if it is the only one left on the Terrain
            if ((ETerrainEditor.getMaterialCount() == 1) && ETerrainEditor.getMaterialIndex(((SimObject)this["activeMat"]).internalName) != -1)
            {
                messageBox.MessageBoxOK("Error", "Cannot delete this Material, it is the only Material still in use by the active Terrain.");
                return;
            }
            TerrainMaterialSet.remove(this["activeMat"]);
            TerrainMaterialDlgDeleteGroup.add(this["activeMat"]);
            GuiTreeViewCtrl matLibTree = this.findObjectByInternalName("matLibTree", true);

            buildTree();
            //matLibTree.open("TerrainMaterialSet", false);
            //matLibTree.selectItem(1);
        }
Пример #11
0
 void Start()
 {
     moving    = GetComponent <moving>();
     player    = GetComponent <CharacterController>();
     RobotAnim = GetComponent <Animator>();
     driller   = GetComponentInChildren <TerrainEditor>();
 }
Пример #12
0
    private void OnWizardCreate()
    {
        TerrainEditor.ClearUndoRedoStack();

        if (TerrainEditor.TerrainParent.transform != null)
        {
            foreach (Transform child in TerrainEditor.TerrainParent.transform)
            {
                DestroyImmediate(child.gameObject);
            }
        }

        TerrainEditor.terrainName = mapName;
        HexGrid.instance.ChangeSize(chunkCountX, chunkCountZ);
        HexMetrics.instance.isEditorTexture = isUseTexture;
        HexGrid.instance.isLoadPrefab       = false;
        HexGrid.instance.NewMap(mapName, true, defaultTerrainTexs, chunkWidth, chunkHeight);

        if (TerrainEditor.TerrainParent != null)
        {
            for (int i = 0; i < HexGrid.instance.maps.Length; i++)
            {
                HexGrid.instance.maps[i].transform.SetParent(TerrainEditor.TerrainParent.transform);
            }

            if (isSaveAfterCreate)
            {
                TerrainEditor.SaveHexChunkAsset(mapName);
            }
        }
    }
Пример #13
0
    void OnGUI()
    {
        if (!te)
        {
            te = GameObject.Find("TerrainEditor").GetComponent <TerrainEditor>();

            if (!te)
            {
                return;
            }
        }

        GUILayout.Label("Terrain Editor", EditorStyles.boldLabel);

        if (te.selected >= 0)
        {
            // there is a polygon already selected, show its information and edit tools
            int      transformTool = 0;
            string[] content       = { "Translate", "Rotate", "Scale" };
            transformTool = GUI.SelectionGrid(new Rect(0, 0, 196, 32), transformTool, content, 3);
        }

        if (GUILayout.Button("EXPORT"))
        {
            Export();
        }
    }
Пример #14
0
    //刷新地形mesh
    void RefreshMesh(Event e)
    {
        //Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        Ray inputRay = HandleUtility.GUIPointToWorldRay(e.mousePosition);

        Debug.Log(inputRay.direction);
        RaycastHit hit;
        HexCell    centerCell = null;
        int        centerX    = 0;
        int        centerZ    = 0;

        m_refreshChunkList.Clear();
        m_refreshCellList.Clear();
        if (Physics.Raycast(inputRay, out hit))
        {
            centerCell = HexGrid.instance.GetCell(hit.point);
            TerrainEditor.redoStack.Clear();
            TerrainEditor.UndoAdd(centerCell, m_brush);
            m_refreshChunkList.Add(centerCell.chunkParent);
            m_refreshCellList.Add(centerCell);
            centerX = centerCell.coordinates.X;
            centerZ = centerCell.coordinates.Z;
            Vector3      pos      = hit.point;
            HexDirection clickDir = HexGrid.instance.GetPointDirection(new Vector2(pos.x - centerCell.transform.position.x, pos.z - centerCell.transform.position.z));
            for (int l = 0, z = centerZ; z >= centerZ - m_brush.brushRange + 1; l++, z--)
            {
                for (int x = centerX - m_brush.brushRange + 1 + l; x <= centerX + m_brush.brushRange - 1; x++)
                {
                    EditCell(clickDir, HexGrid.instance.GetCell(new HexCoordinates(x, z)), m_brush);
                }
            }

            for (int l = 1, z = centerZ + 1; z <= centerZ + m_brush.brushRange - 1; l++, z++)
            {
                for (int x = centerX - m_brush.brushRange + 1; x <= centerX + m_brush.brushRange - 1 - l; x++)
                {
                    EditCell(clickDir, HexGrid.instance.GetCell(new HexCoordinates(x, z)), m_brush);
                }
            }
            for (int i = 0; i < m_refreshChunkList.Count; i++)
            {
                if (m_brush.m_editorType == EditorType.WaterEditor)
                {
                    m_refreshChunkList[i].Refresh(MeshClass.waterMesh);
                    m_refreshChunkList[i].Refresh(MeshClass.waterEdgeMesh);
                }
                else
                {
                    m_refreshChunkList[i].Refresh();
                    m_refreshChunkList[i].sceneObjectMgr.Refresh();
                    // refreshChunkList[i].sceneObjectMgr.Refresh(refreshCellList);
                    //StartCoroutine(WaitMesh(m_refreshChunkList[i]));
                }
            }

            //将修改后的也压入undo栈中,为压入redo栈做准备
            TerrainEditor.UndoAdd(centerCell, m_brush);
        }
    }
Пример #15
0
    static void Init()
    {
        // Get existing open window or if none, make a new one:
        TerrainEditor window = (TerrainEditor)GetWindow(typeof(TerrainEditor));

        window.Show();
        window.EditorInit();
    }
        public override void onAction()
        {
            TerrainEditor ETerrainEditor = "ETerrainEditor";

            ETerrainEditor.softSelectFilter = ((GuiFilterCtrl)"TESoftSelectFilter").getValue();
            ETerrainEditor.resetSelWeights(true);
            ETerrainEditor.processAction("softSelect");
        }
Пример #17
0
 void Start()
 {
     controller    = GetComponent <CharacterController>();
     anim          = GetComponent <Animator>();
     layerMask     = LayerMask.GetMask("Ground");
     tEdit         = GetComponent <TerrainEditor> ();
     footstepSound = GetComponents <AudioSource> ();
 }
Пример #18
0
 // Start is called before the first frame update
 void Start()
 {
     layerMask = LayerMask.GetMask("Ground");
     ice       = GetComponentInChildren <ParticleSystem> ();
     emission  = ice.emission;
     editor    = GetComponent <TerrainEditor> ();
     iceAudio  = GetComponent <AudioSource>();
 }
 public override void PreRenderTickFunction(float fTimeDelta)
 {
     base.PreRenderTickFunction(fTimeDelta);
     if (CurrentMode != HeightmapEditMode_e.None)
     {
         TerrainEditor.BlitHeightmapBrush(CurrentMode);
         View.UpdateView(false);                 // trigger next update
     }
 }
Пример #20
0
        public override bool OnMouseUp(System.Windows.Forms.MouseEventArgs e, KeyModifier eKeyMod, int iOldX, int iOldY)
        {
            if (_bIsPainting)
            {
                TerrainEditor.FinishUpdatePainting();
            }

            return(base.OnMouseUp(e, eKeyMod, iOldX, iOldY));
        }
        public static void setTerrainEditorMaxSlope(float value)
        {
            TerrainEditor   ETerrainEditor = "ETerrainEditor";
            float           val            = ETerrainEditor.setSlopeLimitMaxAngle(value);
            GuiTextEditCtrl SlopeMaxAngle  =
                ((GuiControl)"PaintBrushSlopeControl").findObjectByInternalName("SlopeMaxAngle", true);

            SlopeMaxAngle.setValue(omni.Util.mFloatLength(val, 1));
        }
 public override void Undo()
 {
     _terrain.DeleteDecorationModelResource(_model);
     if (TerrainEditor.CurrentDecorationModel == _model)
     {
         TerrainEditor.CurrentDecorationModel = null;
     }
     TerrainEditor.TriggerOnDecorationModelListChanged();
 }
 public override void PreRenderTickFunction(float fTimeDelta)
 {
     base.PreRenderTickFunction(fTimeDelta);
     if (_bPaint)
     {
         TerrainEditor.BlitDetailTextureBrush(_bSubtract);
         View.UpdateView(false); // trigger next update
     }
 }
Пример #24
0
            public void reset( )
            {
                TerrainEditor ETerrainEditor = "ETerrainEditor";

                TerrainPainter TerrainPainter = "TerrainPainter";

                this.setText("Filter...");
                TerrainPainter.filter = "";
                TerrainPainter.updateLayers(ETerrainEditor.paintIndex.AsString());
            }
Пример #25
0
    // Use this for initialization
    void Start()
    {
        b     = FindObjectOfType <TerrainEditor>();
        board = FindObjectOfType <BoardRunner>();

        radius.onEndEdit.AddListener(delegate { setRadius(); });
        strength.onEndEdit.AddListener(delegate { setStrength(); });
        increment.onValueChanged.AddListener(delegate { setIncrement(); });
        enabler.onValueChanged.AddListener(delegate { enable(); });
    }
    // Use this for initialization
    void Start()
    {
        if (terrainEditor == null)
        {
            terrainEditor = FindObjectOfType <TerrainEditor>();
        }
        Button btn = GetComponent <Button>();

        btn.onClick.AddListener(setEditorMode);
    }
Пример #27
0
 void DoMove(int iOld, int iNew)
 {
     EditorManager.Progress.ShowProgressDialog("Resort detail textures");
     _terrain.DetailTextures.RemoveAt(iOld);
     _terrain.DetailTextures.Insert(iNew, _texture);
     _terrain.EngineTerrain.UpdateDetailTextureOrder(TerrainEditor.CurrentTerrain.DetailTextures, true, EditorManager.Progress);
     _terrain.Modified = true;
     TerrainEditor.TriggerOnDetailTextureListChanged(new DetailTextureListChangedArgs(DetailTextureListChangedArgs.Action.OrderChanged, null));
     EditorManager.Progress.HideProgressDialog();
 }
Пример #28
0
        public void onOK()
        {
            GuiFilterCtrl curve          = findObjectByInternalName("FilterCurveCtrl", true);
            TerrainEditor ETerrainEditor = "ETerrainEditor";

            ETerrainEditor.softSelectFilter = curve.getValue();
            ETerrainEditor.resetSelWeights(true);

            ((GuiCanvas)"Canvas").popDialog(this);
        }
Пример #29
0
 public override void Update(EditorWorldRaycastResult intersection, float deltaTime)
 {
     if (intersection.HitTerrain && TerrainEditor.IsSelecting && Input.GetMouseButtonUp(MouseButton.Left))
     {
         ApplyActionToSelection(TerrainEditor.SelectionBox,
                                (chunk, blockPos) =>
         {
             TerrainEditor.SetBlock(chunk, Block.AIR, blockPos);
         });
     }
 }
Пример #30
0
    protected override bool DrawWizardGUI()
    {
        mapName = TerrainEditor.GetLoadMapName();
        if (mapName.Count > 0 && selectIndex == -1)
        {
            selectIndex = 0;
        }
        int index = EditorGUILayout.Popup("地形列表", selectIndex, mapName.ToArray());

        selectIndex = index;
        return(selectIndex != -1);
    }