Ejemplo n.º 1
0
        void AddDirectionNode(TreeNode root, Controller cc, VirtualController.Axis axis, bool pos, string name)
        {
            var cap = new CapturedInput(axis, false);
            var n   = root.Nodes.Add(name);

            n.Tag = new SlotNodeTag {
                cc = cc, slot = cap
            };
            if (IncludeGestures)
            {
                AddGestureNodes(n, cc, cap);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Clears the player input for a particular color.
 /// </summary>
 /// <param name="playerColor">Player color to clear input of.</param>
 public void ClearRecordedInput(PlayerColor playerColor)
 {
     switch (playerColor)
     {
     case PlayerColor.Red:
         redInput = null;
         break;
     case PlayerColor.Green:
         greenInput = null;
         break;
     case PlayerColor.Blue:
         blueInput = null;
         break;
     }
 }
Ejemplo n.º 3
0
 public static void Map(PadTieForm form, VirtualController vc, CapturedInput slot, InputAction action)
 {
     if (slot.IsAxisGesture)
     {
         form.MapAxisGesture(vc,
                             slot.Axis,
                             slot.IsPositive ? AxisActions.Gestures.Positive : AxisActions.Gestures.Negative,
                             slot.ButtonGesture,
                             action);
     }
     else
     {
         var gesture = slot.ButtonGesture;
         form.MapButton(vc, slot.Button, gesture, action);
     }
 }
Ejemplo n.º 4
0
    private void ActUsingInput(CapturedInput theInput)
    {
        // Process horizontal movement
        float horizontalMovement = 0f;
        if (theInput.getLeft ())
            horizontalMovement = -moveSpeed;
        else if (theInput.getRight())
            horizontalMovement = moveSpeed;
        horizontalMovement *= moveSpeed;
        GetComponent<Rigidbody2D>().velocity = new Vector2(horizontalMovement,GetComponent<Rigidbody2D>().velocity.y);
        // Process jumping
        if (theInput.getJump() && groundCheck.IsGrounded())
            GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, jumpForce));

        // Add platform movement
        GetComponent<Rigidbody2D>().velocity += new Vector2(groundCheck.GetMovement().x, 0f);
    }
Ejemplo n.º 5
0
        void AddPad(Controller cc)
        {
            var padNode = options.Nodes.Add("Pad #" + cc.Index);

            padNode.Tag = cc;
            foreach (var btn in VirtualController.ButtonList)
            {
                var btnNode = padNode.Nodes.Add(Util.GetButtonDisplayName(btn));
                var btnSlot = new CapturedInput(btn);
                btnNode.Tag = new SlotNodeTag {
                    cc = cc, slot = btnSlot
                };
                if (IncludeGestures)
                {
                    AddGestureNodes(btnNode, cc, btnSlot);
                }
            }

            AddStickNodes(padNode, cc);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds the player input to this input frame. This replaces already existing input!
 /// </summary>
 /// <param name="playerColor">Player color to add</param>
 /// <param name="recordedInput">Recorded input to add</param>
 public void AddPlayerInput(PlayerColor playerColor, CapturedInput capturedInput)
 {
     switch (playerColor)
     {
     case PlayerColor.Red:
         if (redInput != null)
             Debug.LogWarning("Replaced red input where input already existed!");
         redInput = capturedInput;
         break;
     case PlayerColor.Green:
         if (greenInput != null)
             Debug.LogWarning("Replaced green input where input already existed!");
         greenInput = capturedInput;
         break;
     case PlayerColor.Blue:
         if (blueInput != null)
             Debug.LogWarning("Replaced blue input where input already existed!");
         blueInput = capturedInput;
         break;
     }
 }
Ejemplo n.º 7
0
        void AddGestureNodes(TreeNode root, Controller cc, CapturedInput slot)
        {
            var n = root.Nodes.Add("Link");

            n.Tag = new GestureTag {
                cc = cc, slot = slot, g = ButtonActions.Gesture.Link
            };

            n     = root.Nodes.Add("Tap");
            n.Tag = new GestureTag {
                cc = cc, slot = slot, g = ButtonActions.Gesture.Tap
            };

            n     = root.Nodes.Add("Double Tap");
            n.Tag = new GestureTag {
                cc = cc, slot = slot, g = ButtonActions.Gesture.DoubleTap
            };

            n     = root.Nodes.Add("Hold");
            n.Tag = new GestureTag {
                cc = cc, slot = slot, g = ButtonActions.Gesture.Hold
            };
        }
Ejemplo n.º 8
0
 void Awake()
 {
     this.resetting = false;
     // Set our activate cooldown
     this.activateTimer = 0;
     // Find our game controller
     this.gameController = FindObjectOfType<GameControllerScript>();
     int levelCompletionTime = FindObjectOfType<LevelStats>().levelCompletionTime;
     // Allocate enough space in the array for recorded input
     this.recordedInput = new CapturedInput[levelCompletionTime];
     this.groundCheck = GetComponent<GroundCheck>();
     this.playerColor = GetComponent<SpriteRenderer>().color;
     this.originalPosition = transform.position;
     this.currentInput = new CapturedInput();
     this.activatorsList = new Hashtable();
     this.overwriteLoop = false;
 }
Ejemplo n.º 9
0
 public void SetInput(CapturedInput capturedInput)
 {
     this.currentInput = capturedInput;
 }
Ejemplo n.º 10
0
 public void SetInput(CapturedInput slot)
 {
     slotCapture.SetInput(slot);
 }
Ejemplo n.º 11
0
 public CombinedInput(PlayerColor playerColor, CapturedInput capturedInput)
 {
     this.AddPlayerInput(playerColor, capturedInput);
 }
Ejemplo n.º 12
0
 public CombinedInput()
 {
     redInput = null;
     greenInput = null;
     blueInput = null;
 }
Ejemplo n.º 13
0
        public void SetInput(CapturedInput input, bool alreadyMapped)
        {
            Controller.Virtual.CancelCapture();

            if (input == null)
            {
                lblSlot.Text = "";
                Value        = null;
                return;
            }

            if (alreadyMapped)
            {
                previousMapping = input.Clone();
            }

            input = input.Clone();
            bool error = false;

            if (input.IsAxisGesture)
            {
                string name = "Unknown Axis";
                string dir  = "Unknown direction";
                var    slot = Controller.Virtual.GetAxis(input.Axis).GetPole(input.AxisGesture).GetGesture(input.ButtonGesture);

                name = Util.GetStickDisplayName(input.Axis);
                dir  = Util.GetAxisGestureName(input.Axis, input.IsPositive);

                lblSlot.Text = "Slot: " + name + " (" + dir + ")";

                if (slot != null && previousMapping != input)
                {
                    lblSlot.Text += ", which is already assigned to " + Util.GetActionName(slot) + ". This action will be replaced.";
                    error         = true;
                }
            }
            else
            {
                string name = input.Button.ToString();

                if (input.Button == VirtualController.Button.Bl)
                {
                    name = "Left Bumper";
                }
                if (input.Button == VirtualController.Button.Br)
                {
                    name = "Right Bumper";
                }
                if (input.Button == VirtualController.Button.Tl)
                {
                    name = "Left Trigger";
                }
                if (input.Button == VirtualController.Button.Tr)
                {
                    name = "Right Trigger";
                }


                lblSlot.Text = "Slot: " + name;
            }

            if (error)
            {
                lblSlot.Font      = new Font(lblSlot.Font, FontStyle.Regular);
                lblSlot.ForeColor = Color.Maroon;
            }
            else
            {
                lblSlot.Font      = new Font(lblSlot.Font, FontStyle.Regular);
                lblSlot.ForeColor = Control.DefaultForeColor;
            }

            if ((int)input.ButtonGesture != this.gestureBox.SelectedIndex)
            {
                this.gestureBox.SelectedIndex = (int)input.ButtonGesture;
            }

            Value = input;
        }
Ejemplo n.º 14
0
 public void SetInput(CapturedInput input)
 {
     SetInput(input, false);
 }