示例#1
0
        public static MoveStrategyContext FromSelection(ToolBehavior toolBehavior, SceneElement primarySelection, IList <SceneElement> selectedElements, IList <BaseFrameworkElement> draggedElements, Vector duplicationOffset, Point referencePoint)
        {
            MoveStrategyContext moveStrategyContext = new MoveStrategyContext();

            moveStrategyContext.ToolBehaviorContext = toolBehavior.ToolBehaviorContext;
            moveStrategyContext.Transaction         = (IToolBehaviorTransaction)toolBehavior;
            moveStrategyContext.MouseDevice         = toolBehavior.MouseDevice;
            moveStrategyContext.PrimarySelection    = primarySelection;
            moveStrategyContext.SelectedElements    = new ReadOnlyCollection <SceneElement>(selectedElements ?? (IList <SceneElement>) new List <SceneElement>());
            moveStrategyContext.DraggedElements     = new ReadOnlyCollection <BaseFrameworkElement>(draggedElements ?? (IList <BaseFrameworkElement>) new List <BaseFrameworkElement>());
            moveStrategyContext.DuplicationOffset   = duplicationOffset;
            moveStrategyContext.SnapshotDraggedElements(moveStrategyContext.ActiveView, referencePoint);
            return(moveStrategyContext);
        }
示例#2
0
 void checkToolCollision(Collider2D[] cols, bool[] flags, ToolBehavior behavior)
 {
     for (int i = 0; i < cols.Length; i++)
     {
         // if the player is colliding with the tool collider, change the flag and do the behavior
         if (playerCollider.bounds.Intersects(cols[i].bounds) && !flags[i])
         {
             //UnityEngine.Debug.Log("collided");
             flags[i] = true;
             behavior(cols, flags, cols[i]);
         }
         else if (playerCollider.bounds.Intersects(cols[i].bounds) && flags[i])
         {
             //UnityEngine.Debug.Log("currently colliding");
             // this isn't supposed to do anything, I just wanted the else to be different
         }
         else
         {
             flags[i] = false;
         }
     }
 }
示例#3
0
    /*
     * Useful player locations - IGNORE
     * X: -9.5 Y: 4.5      Top-left
     * X: 8.5 Y: 4.5      Top-right
     * X: -9.5 Y: -4.5      Bottom-right
     * X: 8.5 Y: -4.5      Top-left
     */

    // Start should run when frame launches
    void Start()
    {
        // get the start position of the duck for reloads
        startPosition = rb.position;
        // create array of directions going clockwise from right
        directions = new Vector2[4] {
            Vector2.right, Vector2.down, Vector2.left, Vector2.up
        };
        // get index of starting direction from editor
        currentDirection = Array.FindIndex(directions, d => d == startDirection);

        duckyCollider = ducky.GetComponent(typeof(Collider2D)) as Collider2D;

        // adding empty arrays if not configured in editor
        if (rotatorCCWs == null)
        {
            rotatorCCWs = new Collider2D[0];
        }
        if (rotatorCWs == null)
        {
            rotatorCWs = new Collider2D[0];
        }
        if (horizontalFlips == null)
        {
            horizontalFlips = new Collider2D[0];
        }
        if (verticalFlips == null)
        {
            verticalFlips = new Collider2D[0];
        }
        if (teleporterSet1 == null)
        {
            teleporterSet1 = new Collider2D[0];
        }
        if (teleporterSet2 == null)
        {
            teleporterSet2 = new Collider2D[0];
        }
        if (teleporterSet3 == null)
        {
            teleporterSet3 = new Collider2D[0];
        }

        // if (rbRotatorCCWs == null) {
        //     rbRotatorCCWs = new Rigidbody2D[0];
        // }
        // if (rbRotatorCWs == null) {
        //     rbRotatorCWs = new Rigidbody2D[0];
        // }
        // if (rbHorizontalFlips == null) {
        //     rbHorizontalFlips = new Rigidbody2D[0];
        // }
        // if (rbVerticalFlips == null) {
        //     rbVerticalFlips = new Rigidbody2D[0];
        // }
        // if (rbTeleporterSet1 == null) {
        //     rbTeleporterSet1 = new Rigidbody2D[0];
        // }
        // if (rbTeleporterSet2 == null) {
        //     rbTeleporterSet2 = new Rigidbody2D[0];
        // }
        // if (rbTeleporterSet3 == null) {
        //     rbTeleporterSet3 = new Rigidbody2D[0];
        // }

        // jagged array of tool collider flags
        // subarrays are for each type of tool
        colliderFlags = new bool[7][] {
            new bool[rotatorCCWs.Length],
            new bool[rotatorCWs.Length],
            new bool[horizontalFlips.Length],
            new bool[verticalFlips.Length],
            new bool[teleporterSet1.Length],
            new bool[teleporterSet2.Length],
            new bool[teleporterSet3.Length]
        };

        for (int type = 0; type < colliderFlags.Length; type++)
        {
            for (int tool = 0; tool < colliderFlags[type].Length; tool++)
            {
                colliderFlags[type][tool] = false;
            }
        }

        RotatorCCW     = new ToolBehavior(RotatorCCWBehavior);
        RotatorCW      = new ToolBehavior(RotatorCWBehavior);
        HorizontalFlip = new ToolBehavior(HorizontalFlipBehavior);
        VerticalFlip   = new ToolBehavior(VerticalFlipBehavior);
        Teleporter     = new ToolBehavior(TeleporterBehavior);
    }
示例#4
0
 public MotionlessAutoScroller(ToolBehavior behavior, Func <Point, Point, bool, bool> handleDragCallback)
 {
     this.Behavior           = behavior;
     this.handleDragCallback = handleDragCallback;
 }
示例#5
0
 public TextToolBehavior(ToolBehaviorContext toolContext, ToolBehavior createToolBehavior)
     : base(toolContext)
 {
     this.createToolBehavior = createToolBehavior;
 }