Beispiel #1
0
        private void MouseMoveOccured(object sender, MouseEventArgs e)
        {
            var position = e.GetPosition(this);
            var hitNode = Scene.GetNodeAtScreenCoordinate(Viewport, (int)position.X, (int)position.Y);
            if( null != hitNode )
            {
                if( null == _previousNode ||
                    !hitNode.Equals(_previousNode))
                {
                    CallActionOnSilverlightNode(hitNode,n=>n.RaiseMouseEnter(e));
                }
            } else if( null != _previousNode )
            {
                CallActionOnSilverlightNode(_previousNode,n=>n.RaiseMouseLeave(e));
            }

            _previousNode= hitNode;
        }
        private void ViewBox_MouseDown(object sender, MouseEventArgs e)
        {
            if(e.Button == MouseButtons.Right)
            {
                float[] pos = Ground.GetIntersectPosThis(e.X, e.Y);
                switch(SelectedObjectType)
                {
                    case 0 :
                        SelectedNode = Core.WCreature.Create();
                        break;
                    case 1 :
                        SelectedNode = Core.WLightOrb.Create();
                        break;
                    case 2 :
                        SelectedNode = Core.WTree1.Create();
                        break;
                    case 3:
                        SelectedNode = Core.WTree2.Create();
                        break;
                    case 4:
                        SelectedNode = Core.WTree3.Create();
                        break;
                    case 5:
                        SelectedNode = Core.WBush.Create();
                        break;
                    case 6 :
                        //Ground.AddHeight(e.X, e.Y, 0.2f);
                        return;
                    case 7 :
                        //Ground.AddHeight(e.X, e.Y, -0.2f);
                        return;
                }

                SelectedNode.SetPosition(pos[0], pos[1], pos[2]);
                Scene.AddChild(SelectedNode);
                ChangeSeletedNode();
                 
                
//                 float[] pos = Ground.PICKGROUND(e.X, e.Y, 0.2f);
// 
//                 //SelectedNode = Core.WCreature.Create();
//                 SelectedNode = Core.WLightOrb.Create();
//                 SelectedNode.SetPosition(pos[0], pos[1], pos[2]);
// 
//                 Scene.AddChild(SelectedNode);
// 
//                 ChangeSeletedNode();
                
            }
            else if (e.Button == MouseButtons.Left)
            {
                SelectedNode = Scene.Pick(e.X, e.Y);

                if(SelectedNode != null)
                    ChangeSeletedNode();
            }
        }