private void HandlePointerUp(object sender, PointerRoutedEventArgs e) { _pointerDown = false; if (_prevPoint == null) { return; } switch (ToolMode) { case EditMode.Object: case EditMode.Move: _selected = null; _offset = Vector3.Zero; break; case EditMode.Delete: { if (DeleteMode == ObjectType.Object) { var pos = _screen.Camera.Owner.Transform.LocalTranslation; pos.X += (float)_prevPoint.Position.X; pos.Y += (float)_prevPoint.Position.Y + 100; // +100 to offset camera position var toDelete = ClickDetector.GetClicked(pos.X, pos.Y); if (toDelete != null) { _screen.RemoveObject(toDelete); _screen.Objectives.CompleteObjective("deletetree"); } } } break; } _prevPoint = null; }
private void HandlePointerDown(object sender, PointerRoutedEventArgs e) { _prevPoint = e.GetCurrentPoint((UIElement)sender); _pointerDown = true; switch (ToolMode) { case EditMode.Object: var selected = ObjTypeList.SelectedItem; if (selected is string) { var pos = _screen.Camera.Owner.Transform.LocalTranslation; pos.Z = 0; pos.X += (float)_prevPoint.Position.X; pos.Y += (float)_prevPoint.Position.Y + 100; // +100 to offset camera position pos = _gameGrid.Snap(pos); _selected = _screen.AddObject(selected as string, null, pos.X, pos.Y, 0, null); if (((string)selected).ToLower() == "tree") { _screen.Objectives.CompleteObjective("placetree"); } } break; case EditMode.Move: { var pos = _screen.Camera.Owner.Transform.LocalTranslation; pos.X += (float)_prevPoint.Position.X; pos.Y += (float)_prevPoint.Position.Y + 100; // +100 to offset camera position _selected = ClickDetector.GetClicked(pos.X, pos.Y); if (_selected != null) { _offset = _selected.Transform.Translation - pos; _offset.Z = 0; } } break; case EditMode.Road: StampTile((float)_prevPoint.Position.X, (float)_prevPoint.Position.Y, (int)BrushSizeSlider.Value, 1); _screen.Objectives.CompleteObjective("placeroad"); break; case EditMode.Zone: StampTile((float)_prevPoint.Position.X, (float)_prevPoint.Position.Y, (int)ZoneBrushSizeSlider.Value, 2, 0); _screen.Objectives.CompleteObjective("placezone"); break; case EditMode.Delete: if (DeleteMode == ObjectType.Road) { if (StampTile((float)_prevPoint.Position.X, (float)_prevPoint.Position.Y, (int)DelBrushSizeSlider.Value, 0, 1) > 0) { _screen.Objectives.CompleteObjective("deleteroads"); } } else if (DeleteMode == ObjectType.Zone) { StampTile((float)_prevPoint.Position.X, (float)_prevPoint.Position.Y, (int)DelBrushSizeSlider.Value, 0, 2); } break; } }