コード例 #1
0
        private void ChangeTool(object toolParam)
        {
            switch (toolParam.ToString())
            {
            case "Hand":
                ToolCursor    = new StandardToolCursor("hand.cur");
                _toolBehavior = new LayoutToolBehavior();
                ActiveIcon    = "cursor";
                break;

            case "VSplit":
                ToolCursor    = new StandardToolCursor("vsplit.cur");
                _toolBehavior = new CleaveScreenVerticalToolBehavior();
                ActiveIcon    = "cleave";
                break;

            case "Start":
                ToolCursor    = new SpriteCursor(_playerSprite, 8, 1);
                _toolBehavior = new StartPointToolBehavior(8, 1);
                ActiveIcon    = "start";
                break;

            case "Continue":
                ToolCursor    = new SpriteCursor(_playerSprite);
                _toolBehavior = new ContinuePointToolBehavior();
                ActiveIcon    = "continue";
                break;
            }

            if (ToolChanged != null)
            {
                ToolChanged(this, new ToolChangedEventArgs(_toolBehavior));
            }
        }
コード例 #2
0
        private ToolOutcome Apply(IActionQueue actionQueue, IToolBehavior toolBehavior, IToolBrush toolBrush, IEnumerable <Vector> inputPositions)
        {
            IEnumerable <Vector> toolPositions = toolBrush.ComputePositions(inputPositions);
            var action = toolBehavior.CreateActions(toolPositions);

            void ValidatedAction(World gs)
            {
                if (Validate(gs, toolBehavior, toolPositions))
                {
                    action(gs);
                }
                else
                {
                    throw new InvalidOperationException("Action is not valid");
                }
            }

            // TODO: don't use exception to control the flow. Need google for this.
            try
            {
                actionQueue.ExecuteSynchronously(ValidatedAction);
                return(ToolOutcome.Success);
            }
            catch (InvalidOperationException)
            {
                return(ToolOutcome.Failure);
            }
        }
コード例 #3
0
        internal ToolHandler(IToolBehavior <ToolDataT> tool, WeakReference <MixedRealityExtensionApp> appRef, IActor attachedActor)
            : base(tool, appRef, attachedActor)
        {
            RegisterActionHandler(tool.Holding, nameof(tool.Holding));
            RegisterActionHandler(tool.Using, nameof(tool.Using));

            _toolBehavior = tool;
            _toolBehavior.Using.ActionStateChanging += OnUsingStateChanging;

            ToolData = new ToolDataT();
        }
コード例 #4
0
        private void TestFromLocation()
        {
            ToolCursor    = new SpriteCursor(_playerSprite);
            _toolBehavior = new TestLocationToolBehavior();
            ActiveIcon    = null;

            if (ToolChanged != null)
            {
                ToolChanged(this, new ToolChangedEventArgs(_toolBehavior));
            }
        }
コード例 #5
0
        private void UpdateTool(object toolParam = null)
        {
            switch (toolParam.ToString())
            {
            case "Hand":
                _toolCursor   = new StandardToolCursor("hand.cur");
                _toolBehavior = null;
                ActiveIcon    = "cursor";
                break;

            case "Entity":
                _toolCursor   = new SpriteCursor(SelectedEntity.DefaultSprite, SnapHorizontal ? HorizSnapAmount : 1, SnapVertical ? VertSnapAmount : 1);
                _toolBehavior = new EntityToolBehavior(SelectedEntity.Entity, SnapHorizontal ? HorizSnapAmount : 1, SnapVertical ? VertSnapAmount : 1);
                ActiveIcon    = "";
                break;
            }

            if (ToolChanged != null)
            {
                ToolChanged(this, new ToolChangedEventArgs(_toolBehavior));
            }
        }
コード例 #6
0
        private ToolPreviewOutcome Preview(IWorldView worldView, IToolBehavior toolBehavior, IToolBrush toolBrush, IEnumerable <Vector> inputPositions)
        {
            IEnumerable <Vector> toolPositions = toolBrush.ComputePositions(inputPositions);

            return(toolBehavior.Preview(worldView, toolPositions));
        }
コード例 #7
0
 private static bool Validate(IWorldView worldView, IToolBehavior toolBehavior, IEnumerable <Vector> toolPositions)
 {
     return(toolBehavior.Preview(worldView, toolPositions).IsPossible());
 }
コード例 #8
0
        private void ChangeTool(object toolParam)
        {
            switch (toolParam.ToString())
            {
                case "Hand":
                    ToolCursor = new StandardToolCursor("hand.cur");
                    _toolBehavior = new LayoutToolBehavior();
                    ActiveIcon = "cursor";
                    break;

                case "VSplit":
                    ToolCursor = new StandardToolCursor("vsplit.cur");
                    _toolBehavior = new CleaveScreenVerticalToolBehavior();
                    ActiveIcon = "cleave";
                    break;

                case "Start":
                    ToolCursor = new ResourceCursor("start_full.png");
                    _toolBehavior = new StartPointToolBehavior();
                    ActiveIcon = "start";
                    break;

                case "Continue":
                    ToolCursor = new ResourceCursor("continue_full.png");
                    _toolBehavior = new ContinuePointToolBehavior();
                    ActiveIcon = "continue";
                    break;
            }

            if (ToolChanged != null)
            {
                ToolChanged(this, new ToolChangedEventArgs(_toolBehavior));
            }
        }
コード例 #9
0
 public ToolChangedEventArgs(IToolBehavior tool)
 {
     Tool = tool;
 }
コード例 #10
0
ファイル: IToolProvider.cs プロジェクト: laazer/cs_megaman
 public ToolChangedEventArgs(IToolBehavior tool)
 {
     Tool = tool;
 }
コード例 #11
0
        private void UpdateTool(object toolParam = null)
        {
            switch (toolParam.ToString())
            {
                case "Hand":
                    _toolCursor = new StandardToolCursor("hand.cur");
                    _toolBehavior = null;
                    ActiveIcon = "cursor";
                    break;

                case "Entity":
                    _toolCursor = new SpriteCursor(SelectedEntity.DefaultSprite, SnapHorizontal ? HorizSnapAmount : 1, SnapVertical ? VertSnapAmount : 1);
                    _toolBehavior = new EntityToolBehavior(SelectedEntity.Entity, SnapHorizontal ? HorizSnapAmount : 1, SnapVertical ? VertSnapAmount : 1);
                    ActiveIcon = "";
                    break;
            }

            if (ToolChanged != null)
            {
                ToolChanged(this, new ToolChangedEventArgs(_toolBehavior));
            }
        }
コード例 #12
0
        private void TestFromLocation()
        {
            ToolCursor = new SpriteCursor(_playerSprite);
            _toolBehavior = new TestLocationToolBehavior();
            ActiveIcon = null;

            if (ToolChanged != null)
            {
                ToolChanged(this, new ToolChangedEventArgs(_toolBehavior));
            }
        }