示例#1
0
        public void Update()
        {
            var zoomDelta = Input.GetAxis("Mouse ScrollWheel");

            if (zoomDelta != 0f)
            {
                Game.Camera.AdjustZoom(zoomDelta);
            }

            if (Input.GetKeyDown(KeyCode.Q))
            {
                Game.Camera.AdjustRotation(1);
                //Game.Camera.AdjustRotation(rotationDelta);
            }
            if (Input.GetKeyDown(KeyCode.E))
            {
                Game.Camera.AdjustRotation(-1);
            }

            var xDelta = Input.GetAxis("Horizontal");
            var zDelta = Input.GetAxis("Vertical");

            if (xDelta != 0f || zDelta != 0f)
            {
                Game.Camera.AdjustPosition(xDelta, zDelta);
            }

            var sw      = Stopwatch.StartNew();
            var binding = Bindings.GetInputCommand();

            if (binding != null)
            {
                UnityEngine.Debug.Log(string.Format("Command for key is {0}", binding.DDACommand));
                DDA.doAction(binding.DDACommand);
            }
            sw.Stop();
            //UnityEngine.Debug.Log(string.Format("Found binding in {0}ms", sw.ElapsedMilliseconds));
        }
    public override void OnInspectorGUI()
    {
        var obj = (TestMap)target;

        serializedObject.Update();

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(tilesFolder);
        if (EditorGUI.EndChangeCheck())
        {
            obj.RebuildCache();
        }

        EditorGUILayout.PropertyField(scale);
        EditorGUILayout.PropertyField(chunkSize);
        EditorGUILayout.PropertyField(chunkRadius);
        EditorGUILayout.PropertyField(startingPoint, true);
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(enableGrid);
        if (EditorGUI.EndChangeCheck())
        {
            obj.enableGrid = enableGrid.boolValue;
            obj.UpdateGrid();
        }
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(removeEdges);
        if (EditorGUI.EndChangeCheck())
        {
            obj.removeEdges = removeEdges.boolValue;
            obj.RebuildCache();
        }
        EditorGUILayout.PropertyField(terrainMaterial);

        if (GUILayout.Button("Rebuild"))
        {
            obj.Rebuild();
        }
        if (GUILayout.Button("Rebuild All"))
        {
            obj.RebuildAll();
        }
        if (GUILayout.Button("go north"))
        {
            DDA.doAction("move_n");
            obj.Rebuild();
        }
        if (GUILayout.Button("go south"))
        {
            DDA.doAction("move_s");
            obj.Rebuild();
        }
        if (GUILayout.Button("go east"))
        {
            DDA.doAction("move_e");
            obj.Rebuild();
        }
        if (GUILayout.Button("go west"))
        {
            DDA.doAction("move_w");
            obj.Rebuild();
        }
        serializedObject.ApplyModifiedProperties();
    }