示例#1
0
 public void AssignTool(
     ToolKind tool
     )
 {
     Debug.Log("selected tool: " + selectedTool + " new tool: " + tool);
     if (selectedTool != ToolKind.none)
     {
         ctx.ctrl.AssignSelected(selectedTool, false);
     }
     selectedTool = tool;
     ctx.ctrl.AssignSelected(selectedTool, true);
 }
示例#2
0
    IEnumerator PickTool(VillageBody village, PickTool pickTool)
    {
        CurrentCommand = pickTool;
        IsSneaking     = false;
        yield return(WaitWithProgress(1f));

        SetToolActive(Tool, false);
        Tool      = pickTool.Tool;
        ToolLevel = village.ToolLevel(Tool);
        SetToolActive(Tool, true);
        CurrentCommand = null;
    }
示例#3
0
 public int ToolLevel(ToolKind tool)
 {
     switch(tool)
     {
         case ToolKind.None:
             return 0;
         case ToolKind.Axe:
             return AxesLevel;
         case ToolKind.Sword:
             return SwordsLevel;
         case ToolKind.Pole:
             return FishingPolesLevel;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
示例#4
0
        public void SwitchTool(ToolKind kind)
        {
            switch (kind)
            {
            case ToolKind.笔工具:
                this.chkPen_Click(this.chkPen, null);
                return;

            case ToolKind.消しゴム工具:
                this.chkPen_Click(this.chkErase, null);
                return;

            case ToolKind.文字工具:
                this.chkPen_Click(this.chkText, null);
                return;
            }
        }
示例#5
0
        static ToolInfo ToToolInfo(ToolKind kind)
        {
            switch (kind)
            {
            case ToolKind.StateInspector:
                return(new ToolInfo {
                    Kind = kind, Name = "StateInspector", Tooltip = null
                });

            case ToolKind.MessageProperties:
                return(new ToolInfo {
                    Kind = kind, Name = "Message properties", Tooltip = null
                });

            default:
                return(new ToolInfo {
                    Kind = kind, Name = "?", Tooltip = "?"
                });
            }
        }
示例#6
0
        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            //if (!Keyboard.IsKeyDown(Key.LeftCtrl))
            //{
            //    foreach (var particle in model.Particles)
            //        particle.Fixed = false;
            //}
            switch (toolKind)
            {
            case ToolKind.MoveSelectedParticles:
                foreach (var particle in model.Particles)
                {
                    var drawData = particle.Tag as DrawData;
                    if (drawData.Selected && !drawData.Pinned)
                    {
                        particle.Fixed = false;
                    }
                }
                break;

            case ToolKind.ScrollView:
                break;

            case ToolKind.SelectRectangle:
                var r = new Rect(mouseDownPosition, e.GetPosition(this));
                foreach (var particle in model.Particles)
                {
                    if (r.Contains(transform.ToScreen(particle.Position)))
                    {
                        (particle.Tag as DrawData).Selected = true;
                    }
                }
                selectionAdorner.Destroy();
                selectionAdorner = null;
                break;
            }
            InvalidateVisual();
            toolKind = ToolKind.None;
            ReleaseMouseCapture();
        }
示例#7
0
    void SetToolActive(ToolKind tool, bool active)
    {
        switch (tool)
        {
        case ToolKind.Axe:
            transform.Find("Axe").gameObject.SetActive(active);
            break;

        case ToolKind.Sword:
            transform.Find("Sword").gameObject.SetActive(active);
            break;

        case ToolKind.Pole:
            transform.Find("Pole").gameObject.SetActive(active);
            break;

        case ToolKind.None:
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
示例#8
0
        public void AssignSelected(
            ToolKind kind,
            bool selected
            )
        {
            switch (kind)
            {
            case ToolKind.paint:
                paintSelectedBg.SetActive(selected);
                break;

            case ToolKind.fill:
                fillSelectedBg.SetActive(selected);
                break;

            case ToolKind.erase:
                eraseSelectedBg.SetActive(selected);
                break;

            case ToolKind.pick:
                pickSelectedBg.SetActive(selected);
                break;
            }
        }
示例#9
0
 protected override void OnMouseDown(MouseButtonEventArgs e)
 {
     switch (e.ChangedButton)
     {
     case MouseButton.Left:
         Point p = e.GetPosition(this);
         mouseDownPosition = p;
         var hitParticle = ParticleAtPoint(p);
         if (Keyboard.IsKeyDown(Key.LeftCtrl))
         {
             if (hitParticle == null)
             {
                 var newParticle = new Particle(model.Dimension);
                 newParticle.Position  = transform.ToWorld(mouseDownPosition);
                 newParticle.FillColor = getRandomColor();
                 model.AddParticle(newParticle);
                 InvalidateVisual();
             }
             else
             {
                 model.RemoveParticle(hitParticle);
                 InvalidateVisual();
             }
         }
         else if (Keyboard.IsKeyDown(Key.LeftShift))
         {
             if (hitParticle != null)
             {
                 toolKind = ToolKind.None;
                 var drawData = hitParticle.Tag as DrawData;
                 drawData.Selected = !drawData.Selected;
                 InvalidateVisual();
             }
             else
             {
                 toolKind              = ToolKind.SelectRectangle;
                 selectionAdorner      = SelectionAdorner.Create(this);
                 selectionAdorner.From = mouseDownPosition;
                 selectionAdorner.To   = mouseDownPosition;
             }
         }
         else
         {
             if (hitParticle != null)
             {
                 toolKind = ToolKind.MoveSelectedParticles;
                 var drawData = hitParticle.Tag as DrawData;
                 if (drawData.Selected)
                 {
                     foreach (var particle in model.Particles)
                     {
                         DrawData dd = particle.Tag as DrawData;
                         if (dd.Selected)
                         {
                             particle.Fixed = true;
                         }
                     }
                 }
                 else
                 {
                     foreach (var particle in model.Particles)
                     {
                         (particle.Tag as DrawData).Selected = false;
                     }
                     (hitParticle.Tag as DrawData).Selected = true;
                     hitParticle.Fixed = true;
                 }
                 InvalidateVisual();
             }
             else
             {
                 toolKind = ToolKind.ScrollView;
             }
         }
         if (toolKind != ToolKind.None)
         {
             CaptureMouse();
         }
         break;
     }
 }
示例#10
0
 private void EnterPaintMode()
 {
     tool               = ToolKind.Paint;
     canvas.Cursor      = Cursors.Pen;
     canvas.EditingMode = InkCanvasEditingMode.Ink;
 }
示例#11
0
 private void EnterSelectMode()
 {
     tool               = ToolKind.Select;
     canvas.Cursor      = Cursors.Arrow;
     canvas.EditingMode = InkCanvasEditingMode.None;
 }