public void Update(float dt) { WE(); if (Keyboard.IsKeyDownOnce(Engine.Input.Key.F11)) { //API_WE.Round(true,25,13,true,ZuoBiaoType.Z,15,Point1); Select_mode(m_categories, names); // m_componentPlayer.View.ActiveCamera = FindCamera<DebugCamera>(); } if (F12.IsChecked) { if (speed != 0) { if (SettingsManager.MoveControlMode == MoveControlMode.Buttons) { MoveRoseWidget moveRoseWidget = m_componentPlayer.ComponentGui.MoveRoseWidget; if (moveRoseWidget == null || (double)moveRoseWidget.Direction.Z <= 0.0) { return; } Vector3 viewDirection = m_componentPlayer.ComponentBody.Velocity; m_componentPlayer.ComponentBody.Velocity = new Vector3(viewDirection.X * speed, viewDirection.Y * speed, viewDirection.Z * speed); } if (SettingsManager.MoveControlMode == MoveControlMode.Pad) { TouchInput?input = m_componentPlayer.ComponentGui.MoveWidget.TouchInput; if (!input.HasValue || input.Value.InputType != TouchInputType.Move && input.Value.InputType != TouchInputType.Hold || (double)ProcessInputValue(-input.Value.TotalMoveLimited.Y, 0.2f * m_componentPlayer.ComponentGui.MoveWidget.Radius, m_componentPlayer.ComponentGui.MoveWidget.Radius) <= 0.0) { return; } Vector3 viewDirection = cam.ViewDirection; m_componentPlayer.ComponentBody.Velocity = new Vector3(viewDirection.X * speed, viewDirection.Y * speed, viewDirection.Z * speed); } else { if (Keyboard.IsKeyDown(Key.W) || Keyboard.IsKeyDown(Key.A) || Keyboard.IsKeyDown(Key.S) || Keyboard.IsKeyDown(Key.D)) { Vector3 viewDirection = cam.ViewDirection; m_componentPlayer.ComponentBody.Velocity = new Vector3(viewDirection.X * speed, viewDirection.Y * speed, viewDirection.Z * speed); } } } } if (F12.IsClicked) { // DialogsManager.ShowDialog(m_componentPlayer.View.GameWidget, new FastRun(m_componentPlayer)); } if (F11.IsClicked) { Select_mode(m_categories, names); } if (Keyboard.IsKeyDownOnce(Engine.Input.Key.F12)) { if (m_componentPlayer.View.ActiveCamera.GetType() == typeof(FppCamera)) { m_componentPlayer.View.ActiveCamera = FindCamera <DebugCamera>(); } else { m_componentPlayer.View.ActiveCamera = m_componentPlayer.View.FindCamera <FppCamera>(); } // DialogsManager.ShowDialog(m_componentPlayer.View.GameWidget, new FastRun(m_componentPlayer)); } if ((Engine.Input.Keyboard.IsKeyDownOnce(Engine.Input.Key.F9)) || F9.IsClicked) // Копирование зоны в память { if (Point1 == null) { m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 1", false, false); } else if (Point2 == null) { m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 2", false, false); } else { int startX = Math.Min(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X); int endX = Math.Max(Point1.Value.CellFace.Point.X, Point2.Value.CellFace.Point.X); int startY = Math.Min(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y); int endY = Math.Max(Point1.Value.CellFace.Point.Y, Point2.Value.CellFace.Point.Y); int startZ = Math.Min(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z); int endZ = Math.Max(Point1.Value.CellFace.Point.Z, Point2.Value.CellFace.Point.Z); blockCount = 0; BlockList.Clear(); for (int x = 0; x <= endX - startX; x++) { for (int y = 0; y <= endY - startY; y++) { for (int z = 0; z <= endZ - startZ; z++) { BlockMem blmem = new BlockMem(); int X, Y, Z; if (Point1.Value.CellFace.Point.X > Point2.Value.CellFace.Point.X) { blmem.x = -x; X = Point1.Value.CellFace.Point.X - x; } else { blmem.x = x; X = Point1.Value.CellFace.Point.X + x; } if (Point1.Value.CellFace.Point.Y > Point2.Value.CellFace.Point.Y) { blmem.y = -y; Y = Point1.Value.CellFace.Point.Y - y; } else { blmem.y = y; Y = Point1.Value.CellFace.Point.Y + y; } if (Point1.Value.CellFace.Point.Z > Point2.Value.CellFace.Point.Z) { blmem.z = -z; Z = Point1.Value.CellFace.Point.Z - z; } else { blmem.z = z; Z = Point1.Value.CellFace.Point.Z + z; } blmem.id = m_subsystemTerrain.Terrain.GetCellValue(X, Y, Z); BlockList.Add(blmem); blockCount++; } } } } m_componentPlayer.ComponentGui.DisplaySmallMessage("Copied " + blockCount + " blocks", false, false); return; } if ((Engine.Input.Keyboard.IsKeyDownOnce(Engine.Input.Key.F10)) || F10.IsClicked) // Вставка зоны из памяти { if (Point3 == null) { m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 3", false, false); } else { for (var i = 0; i < blockCount; i++) { var xPos = Point3.Value.CellFace.X + BlockList[i].x; var yPos = Point3.Value.CellFace.Y + BlockList[i].y; var zPos = Point3.Value.CellFace.Z + BlockList[i].z; m_subsystemTerrain.ChangeCell(xPos, yPos, zPos, BlockList[i].id); } m_componentPlayer.ComponentGui.DisplaySmallMessage("Pasted " + blockCount + " blocks", false, false); } } }
public static void Coppy_zone(string path, Point3 Point1, Point3 Point2, SubsystemTerrain subsystemTerrain, ComponentPlayer player) { int startX = Math.Min(Point1.X, Point2.X); int endX = Math.Max(Point1.X, Point2.X); int startY = Math.Min(Point1.Y, Point2.Y); int endY = Math.Max(Point1.Y, Point2.Y); int startZ = Math.Min(Point1.Z, Point2.Z); int endZ = Math.Max(Point1.Z, Point2.Z); FileStream fileStream = new FileStream(path, FileMode.Create); EngineBinaryWriter engineBinaryWriter = new EngineBinaryWriter((Stream)fileStream, true); engineBinaryWriter.Write((byte)79); engineBinaryWriter.Write((byte)110); engineBinaryWriter.Write((byte)101); engineBinaryWriter.Write((byte)75); engineBinaryWriter.Write((byte)101); engineBinaryWriter.Write((byte)121); engineBinaryWriter.Write((byte)0); engineBinaryWriter.Write(0); blockCount = 0; BlockList.Clear(); for (int x = 0; x <= endX - startX; x++) { for (int y = 0; y <= endY - startY; y++) { for (int z = 0; z <= endZ - startZ; z++) { BlockMem blmem = new BlockMem(); int X, Y, Z; if (Point1.X > Point2.X) { blmem.x = -x; X = Point1.X - x; } else { blmem.x = x; X = Point1.X + x; } if (Point1.Y > Point2.Y) { blmem.y = -y; Y = Point1.Y - y; } else { blmem.y = y; Y = Point1.Y + y; } if (Point1.Z > Point2.Z) { blmem.z = -z; Z = Point1.Z - z; } else { blmem.z = z; Z = Point1.Z + z; } blmem.id = subsystemTerrain.Terrain.GetCellValueFast(X, Y, Z); engineBinaryWriter.Write(blmem.x); engineBinaryWriter.Write(blmem.y); engineBinaryWriter.Write(blmem.z); engineBinaryWriter.Write(blmem.id); ++blockCount; BlockList.Add(blmem); blockCount++; } } } player.ComponentGui.DisplaySmallMessage(string.Format("Sucsses {0} place blocks", blockCount), true, true); engineBinaryWriter.BaseStream.Position = 7L; engineBinaryWriter.Write(blockCount); engineBinaryWriter.Dispose(); fileStream.Dispose(); }