internal void SetModel(IOutline model) { if (model != null) { SetTitle(model.Title); Model = model; } }
private void RemoveBox(CollisionBox box) { IOutline associatedOutline = Outlines.Find(o => o is CollisionBoxOutline boxOutline && boxOutline.Box == box); Boxes.Remove(box); if (associatedOutline != null) { Outlines.Remove(associatedOutline); Owner.Events.InvokeEvent(new RemoveOverlay(associatedOutline)); } }
private void RemoveSprite(Sprite sprite) { IOutline associatedOutline = Outlines.Find(o => o is SpriteOutline spriteOutline && spriteOutline.Sprite == sprite); Sprites.Remove(sprite); if (associatedOutline != null) { Outlines.Remove(associatedOutline); Owner.Events.InvokeEvent(new RemoveOverlay(associatedOutline)); } }
public static void RenderOutline(LittleSharpRenderEngine engine, Graphics graphics, System.Drawing.Drawing2D.GraphicsPath path, IOutline line) { Pen pen; if (line.Pattern != null) { //TODO: Fix this return; } else { //TODO: Dash style pen = new Pen(line.ForegroundColor, line.Width); } if (line.Pattern == null) graphics.DrawPath(pen, path); }
public bool Update(IOutline item) { EnsureArgumentNotNull(item); if (item is Book) { return(m_db.Update((Book)item)); } else if (item is Catalog) { return(m_db.Update((Catalog)item)); } else if (item is Fragment) { return(m_db.Update((Fragment)item)); } else { throw new NotSupportedException("不支持的类型:" + item.GetType()); } }
public void RaycastToSearch(float dist, out NPCController npc, out IOutline oulineObj) { npc = null; oulineObj = null; Ray ray = new Ray(raySpawner.position, raySpawner.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, dist, 1 << 12)) { IOutline _outline = hit.collider.GetComponentInParent <IOutline>(); if (_outline != null) { oulineObj = _outline; } NPCController _npc = hit.collider.GetComponentInChildren <NPCController>(); if (_npc != null) { npc = _npc; } } }
public void SetControlledObject(object item) { try { if (item != null && item is IOutline) { m_Item = (IOutline)item; FillControls(); if (item is IChangeNotify) { ((IChangeNotify)item).ItemChanged += External_ItemChanged; } this.Enabled = true; } else { ClearControls(); this.Enabled = false; } } catch (System.Exception) { } }
public ItemDetailViewModel(IOutline model = null) { SetModel(model); }
private void Update() { if (SceneManager.GetActiveScene().name != "NewMenu") { float disToTarget = Vector3.Distance(transform.position, MissionManager.Instance.GetCurrentTarget().position); EventDispatcher.Outer.DispatchEvent("UpdateMission", disToTarget); } //搜索交互物体 NPCController npc; IOutline outlineObj; m_pRaycaster.RaycastToSearch(3f, out npc, out outlineObj); if (previousOutlineObj != null && previousOutlineObj.GetTransform() != null && previousOutlineObj != outlineObj) { previousOutlineObj.DisableOutlineColor(); } if (outlineObj != null) { previousOutlineObj = outlineObj; outlineObj.EnableOutlineColor(); } if (Input.GetKeyDown(KeyCode.E)) { if (npc != null) { List <int> dialogues = CharacterModel.Instance.GetCharacterDialogues(npc.GetInteractableID()); int nextDialogue = 0; for (int i = 0; i < dialogues.Count; i++) { if (PlayerModel.Instance.CheckDialogueIsPast(dialogues[i])) { continue; } int conditionID = DialogueModel.Instance.GetConditionID(dialogues[i]); if (conditionID == 0) { nextDialogue = dialogues[i]; break; } else { if (PlayerModel.Instance.CheckDialogueIsPast(conditionID)) { nextDialogue = dialogues[i]; break; } } } if (nextDialogue != 0) { UIManager.Instance.Push <UIScreenDialogue>(UIDepthConst.MiddleDepth, false, nextDialogue); PlayerModel.Instance.SaveDialogueData(nextDialogue); } else { //Can't talk UIManager.Instance.Push <UIMessageInGame>(UIDepthConst.TopDepth, false, "Nothinig to Talk...", 1.5f); } } } }
public override void Input() { if (!ModalActive) { return; } IInputMap inputMap = Woofer.Controller.InputManager.ActiveInputMap; if (inputMap.Pulse.Consume()) { Mode++; if ((MultipleAllowed && Mode > 3) || (!MultipleAllowed && Mode > 1)) { Mode = 0; } SelectionLocked = false; } if (Mode == Edit) { if (!SelectionLocked) { UpdateSelected(); if (SelectedBox != null && inputMap.Jump.Consume()) { SelectionLocked = true; } } if (SelectionLocked) { if (!CursorSystem.Dragging) { DraggingSide = -1; } FaceOutline.Bounds = new Rectangle(FaceOutline.Bounds?.X ?? 0, FaceOutline.Bounds?.Y ?? 0, 0, 0); Rectangle selectedBounds = SelectedBox.ToRectangle() + Pivot; if (CursorSystem.StartedDragging) { PreResizeBounds = selectedBounds; } int highlightedSide = UpdateSelectedFace(); if (highlightedSide != -1 && DraggingSide == -1 && CursorSystem.Dragging) { DraggingSide = highlightedSide; } if (CursorSystem.Dragging && DraggingSide == -1 && selectedBounds.Contains(CursorSystem.CursorPos)) { DraggingSide = 4; } if (CursorSystem.Dragging && DraggingSide != -1 && PreResizeBounds != Rectangle.Empty) { if (DraggingSide == 3) //Left { double prevRight = SelectedBox.Right; SelectedBox.X = (CursorSystem.CursorPos.X - Pivot.X); SelectedBox.Width = prevRight - SelectedBox.X; if (SelectedBox.Width < 0) { double min = Math.Min(SelectedBox.Left, SelectedBox.Right); double max = Math.Max(SelectedBox.Left, SelectedBox.Right); SelectedBox.X = min; SelectedBox.Width = max - min; DraggingSide = 1; } } else if (DraggingSide == 1) //Right { SelectedBox.Width = (CursorSystem.CursorPos.X - SelectedBox.X) - Pivot.X; if (SelectedBox.Width < 0) { double min = Math.Min(SelectedBox.Left, SelectedBox.Right); double max = Math.Max(SelectedBox.Left, SelectedBox.Right); SelectedBox.X = min; SelectedBox.Width = max - min; DraggingSide = 3; } } else if (DraggingSide == 2) //Bottom { double prevTop = SelectedBox.Top; SelectedBox.Y = (CursorSystem.CursorPos.Y - Pivot.Y); SelectedBox.Height = prevTop - SelectedBox.Y; if (SelectedBox.Height < 0) { double min = Math.Min(SelectedBox.Bottom, SelectedBox.Top); double max = Math.Max(SelectedBox.Bottom, SelectedBox.Top); SelectedBox.Y = min; SelectedBox.Height = max - min; DraggingSide = 0; } } else if (DraggingSide == 0) //Top { SelectedBox.Height = (CursorSystem.CursorPos.Y - SelectedBox.Y) - Pivot.Y; if (SelectedBox.Height < 0) { double min = Math.Min(SelectedBox.Bottom, SelectedBox.Top); double max = Math.Max(SelectedBox.Bottom, SelectedBox.Top); SelectedBox.Y = min; SelectedBox.Height = max - min; DraggingSide = 2; } } else if (DraggingSide == 4) //Middle { SelectedBox.X = PreResizeBounds.X + (CursorSystem.CursorPos.X - CursorSystem.SelectionStart.X) - Pivot.X; SelectedBox.Y = PreResizeBounds.Y + (CursorSystem.CursorPos.Y - CursorSystem.SelectionStart.Y) - Pivot.Y; } } } } else if (Mode == Create) { if (CursorSystem.StartedDragging) { CollisionBox newBox = new CollisionBox(CursorSystem.SelectionRectangle - Pivot); Boxes.Add(newBox); IOutline newOutline = new CollisionBoxOutline(Pivot, newBox, Color.Orange); Outlines.Add(newOutline); Owner.Events.InvokeEvent(new BeginOverlay(newOutline)); Creating = true; } if (CursorSystem.Dragging && Creating) { CollisionBox newBox = Boxes.Last(); newBox.X = CursorSystem.SelectionRectangle.X - Pivot.X; newBox.Y = CursorSystem.SelectionRectangle.Y - Pivot.Y; newBox.Width = CursorSystem.SelectionRectangle.Width; newBox.Height = CursorSystem.SelectionRectangle.Height; } if (CursorSystem.StoppedDragging && Creating) { CollisionBox newBox = Boxes.Last(); if (newBox.Area == 0) { RemoveBox(newBox); } Creating = false; } } else if (Mode == Delete) { UpdateSelected(); if (SelectedBox != null) { IOutline associatedOutline = null; foreach (IOutline outline in Outlines) { if (outline is CollisionBoxOutline boxOutline) { if (boxOutline.Box == SelectedBox) { boxOutline.Color = Color.Red; boxOutline.Thickness = 4; associatedOutline = outline; } } } if (inputMap.Jump.Consume()) { RemoveBox(SelectedBox); } } } else if (Mode == TweakFaces) { if (!SelectionLocked) { UpdateSelected(); if (SelectedBox != null && inputMap.Jump.Consume()) { SelectionLocked = true; } } if (SelectionLocked) { FaceOutline.Bounds = new Rectangle(FaceOutline.Bounds?.X ?? 0, FaceOutline.Bounds?.Y ?? 0, 0, 0); int highlightedFace = UpdateSelectedFace(); if (highlightedFace != -1 && inputMap.Jump.Consume()) { Owner.Events.InvokeEvent(new CollisionFaceSelectEvent(SelectedBox, highlightedFace)); Owner.Events.InvokeEvent(new ForceModalChangeEvent("collision_face_view", null)); CursorSystem.ModalActive = false; ModalActive = false; } } } }
public override void Input() { if (!ModalActive) { return; } IInputMap inputMap = Woofer.Controller.InputManager.ActiveInputMap; if (inputMap.Pulse.Consume()) { Mode++; if ((MultipleAllowed && Mode > 4) || (!MultipleAllowed && Mode > 1)) { Mode = 0; } SelectionLocked = false; } if (Mode == Edit) { if (!SelectionLocked) { UpdateSelected(); if (SelectedSprite != null && inputMap.Jump.Consume()) { SelectionLocked = true; } } if (SelectionLocked) { if (!CursorSystem.Dragging) { DraggingSide = -1; } FaceOutline.Bounds = new Rectangle(FaceOutline.Bounds?.X ?? 0, FaceOutline.Bounds?.Y ?? 0, 0, 0); Rectangle selectedBounds = SelectedSprite.Destination + Origin; if (CursorSystem.StartedDragging) { PreResizeBounds = selectedBounds; } int highlightedSide = UpdateSelectedFace(); if (highlightedSide != -1 && DraggingSide == -1 && CursorSystem.Dragging) { DraggingSide = highlightedSide; } if (CursorSystem.Dragging && DraggingSide == -1 && selectedBounds.Contains(CursorSystem.CursorPos)) { DraggingSide = 4; } if (CursorSystem.Dragging && DraggingSide != -1 && PreResizeBounds != null) { if (DraggingSide == 3) //Left { double prevRight = SelectedSprite.Destination.Right; SelectedSprite.Destination.X = (CursorSystem.CursorPos.X - Origin.X); SelectedSprite.Destination.Width = prevRight - SelectedSprite.Destination.X; if (SelectedSprite.Destination.Width < 0) { double min = Math.Min(SelectedSprite.Destination.Left, SelectedSprite.Destination.Right); double max = Math.Max(SelectedSprite.Destination.Left, SelectedSprite.Destination.Right); SelectedSprite.Destination.X = min; SelectedSprite.Destination.Width = max - min; DraggingSide = 1; } } else if (DraggingSide == 1) //Right { SelectedSprite.Destination.Width = (CursorSystem.CursorPos.X - SelectedSprite.Destination.X) - Origin.X; if (SelectedSprite.Destination.Width < 0) { double min = Math.Min(SelectedSprite.Destination.Left, SelectedSprite.Destination.Right); double max = Math.Max(SelectedSprite.Destination.Left, SelectedSprite.Destination.Right); SelectedSprite.Destination.X = min; SelectedSprite.Destination.Width = max - min; DraggingSide = 3; } } else if (DraggingSide == 2) //Bottom { double prevTop = SelectedSprite.Destination.Top; SelectedSprite.Destination.Y = (CursorSystem.CursorPos.Y - Origin.Y); SelectedSprite.Destination.Height = prevTop - SelectedSprite.Destination.Y; if (SelectedSprite.Destination.Height < 0) { double min = Math.Min(SelectedSprite.Destination.Bottom, SelectedSprite.Destination.Top); double max = Math.Max(SelectedSprite.Destination.Bottom, SelectedSprite.Destination.Top); SelectedSprite.Destination.Y = min; SelectedSprite.Destination.Height = max - min; DraggingSide = 0; } } else if (DraggingSide == 0) //Top { SelectedSprite.Destination.Height = (CursorSystem.CursorPos.Y - SelectedSprite.Destination.Y) - Origin.Y; if (SelectedSprite.Destination.Height < 0) { double min = Math.Min(SelectedSprite.Destination.Bottom, SelectedSprite.Destination.Top); double max = Math.Max(SelectedSprite.Destination.Bottom, SelectedSprite.Destination.Top); SelectedSprite.Destination.Y = min; SelectedSprite.Destination.Height = max - min; DraggingSide = 2; } } else if (DraggingSide == 4) //Middle { SelectedSprite.Destination.X = PreResizeBounds.X + (CursorSystem.CursorPos.X - CursorSystem.SelectionStart.X) - Origin.X; SelectedSprite.Destination.Y = PreResizeBounds.Y + (CursorSystem.CursorPos.Y - CursorSystem.SelectionStart.Y) - Origin.Y; } } } } else if (Mode == Create) { if (CursorSystem.StartedDragging) { Sprite newSprite = new Sprite("null", CursorSystem.SelectionRectangle - Origin, Rectangle.Empty); AddSprite(newSprite); Creating = true; } if (CursorSystem.Dragging && Creating) { Sprite newSprite = Sprites.Last(); newSprite.Destination.X = CursorSystem.SelectionRectangle.X - Origin.X; newSprite.Destination.Y = CursorSystem.SelectionRectangle.Y - Origin.Y; newSprite.Destination.Width = CursorSystem.SelectionRectangle.Width; newSprite.Destination.Height = CursorSystem.SelectionRectangle.Height; } if (CursorSystem.StoppedDragging && Creating) { Sprite newSprite = Sprites.Last(); if (newSprite.Destination.Area == 0) { RemoveSprite(newSprite); } Creating = false; } } else if (Mode == Delete) { UpdateSelected(); if (SelectedSprite != null) { IOutline associatedOutline = null; foreach (IOutline outline in Outlines) { if (outline is SpriteOutline spriteOutline) { if (spriteOutline.Sprite == SelectedSprite) { spriteOutline.Color = Color.Red; spriteOutline.Thickness = 4; associatedOutline = outline; } } } if (inputMap.Jump.Consume()) { RemoveSprite(SelectedSprite); } } } else if (Mode == TweakUV) { if (!SelectionLocked) { UpdateSelected(); if (SelectedSprite != null && inputMap.Jump.Consume()) { //SelectionLocked = true; Owner.Events.InvokeEvent(new StartSpriteSourceEditEvent(SelectedSprite)); Owner.Events.InvokeEvent(new ForceModalChangeEvent("sprite_source_view", null)); CursorSystem.ModalActive = false; ModalActive = false; Console.WriteLine("Start editing UV of sprite"); } } } else if (Mode == Clone) { UpdateSelected(); if (SelectedSprite != null) { IOutline associatedOutline = null; foreach (IOutline outline in Outlines) { if (outline is SpriteOutline spriteOutline) { if (spriteOutline.Sprite == SelectedSprite) { spriteOutline.Color = Color.MediumAquamarine; spriteOutline.Thickness = 4; associatedOutline = outline; } } } if (inputMap.Jump.Consume()) { Sprite clone = new Sprite { Texture = SelectedSprite.Texture, Destination = new Rectangle(SelectedSprite.Destination) + new Vector2D(4, 4), Source = SelectedSprite.Source, DrawMode = SelectedSprite.DrawMode, Modifiers = SelectedSprite.Modifiers, Opacity = SelectedSprite.Opacity }; AddSprite(clone); } } } }
public Line(IOutline outline) : this(new IOutline[]{outline}) { }
public Line(IOutline outline) : this(new IOutline[] { outline }) { }
public static void RenderOutline(LittleSharpRenderEngine engine, Graphics graphics, System.Drawing.Drawing2D.GraphicsPath path, IOutline line) { Pen pen; if (line.Pattern != null) { //TODO: Fix this return; } else { //TODO: Dash style pen = new Pen(line.ForegroundColor, line.Width); } if (line.Pattern == null) { graphics.DrawPath(pen, path); } }