Example #1
0
    // gets offset for camera and starts camera in static view
    void Start()
    {
        initPos = transform.position;  // stores static camera position

        // camera axis button created
        CameraButton = new AxisButton(CameraAxis, 0.5f);
    }
Example #2
0
 /// <summary>
 /// Create a new Axis using AxisButtons.
 /// </summary>
 /// <param name="up">The AxisButton for Up.</param>
 /// <param name="right">The AxisButton for Right.</param>
 /// <param name="down">The AxisButton for Down.</param>
 /// <param name="left">The AxisButton for Left.</param>
 /// <param name="joystick">The joystick id to use.</param>
 public Axis(AxisButton up, AxisButton right, AxisButton down, AxisButton left, params int[] joystick)
     : this()
 {
     AddButton(up, Direction.Up, joystick);
     AddButton(right, Direction.Right, joystick);
     AddButton(down, Direction.Down, joystick);
     AddButton(left, Direction.Left, joystick);
 }
Example #3
0
 /// <summary>
 /// Add a joystick axis button.
 /// </summary>
 /// <param name="button">The joystick axis button.</param>
 /// <param name="direction">The direction this axis button should effect.</param>
 /// <param name="joystick">The joystick id.</param>
 /// <returns>The Axis.</returns>
 public Axis AddButton(AxisButton button, Direction direction, params int[] joystick)
 {
     foreach (var j in joystick)
     {
         AddButton((int)button, direction, j);
     }
     return(this);
 }
Example #4
0
    void Start()
    {
        // Set axis strings based on the user's controller selection from the menu screen
        if (GameControl.ControllerMode)
        {
            FireAxis         = FireAxis_Controller;
            ClimbDescendAxis = ClimbDescendAxis_Controller;
        }
        else
        {
            FireAxis         = FireAxis_Mouse;
            ClimbDescendAxis = ClimbDescendAxis_Mouse;
        }

        // set up the fire button axis
        FireButton = new AxisButton(FireAxis);
    }
Example #5
0
    /// <summary>
    /// Creates the rebind buttons
    /// </summary>
    private void CreateAxisButtons()
    {
        foreach (AxisBase a in Axes)
        {
            GameObject p = Instantiate(AxisRebindButton);
            p.transform.SetParent(AxesGrid, false);
            AxisButton pB = p.GetComponent <AxisButton>();
            pB.Init(a.AxisName, a.PkeyDescription, a.Pkey.ToString());
            a.PUIButton = pB;

            if (a.Nkey != KeyCode.None)
            {
                GameObject n = Instantiate(AxisRebindButton);
                n.transform.SetParent(AxesGrid, false);
                AxisButton nB = n.GetComponent <AxisButton>();

                nB.Init(a.AxisName, a.NkeyDescription, a.Nkey.ToString(), true);
                a.NUIButton = nB;
            }
        }
    }
Example #6
0
    private void CollisionEnded(object sender, PointerEventArgs e)
    {
        if (e.target.GetComponent <Point>() != null)
        {
            inPointCollision = false;
        }

        else if (e.target.GetComponent <ScaleButton>() != null)
        {
            scaleButton = null;
        }

        else if (e.target.GetComponent <AxisButton>() != null)
        {
            axisButton = null;
        }

        else if (e.target.GetComponent <InvertAxisButton>() != null)
        {
            invertAxisButton = null;
        }
    }
    // Use this for initialization
    void Start()
    {
        // Set based on player's control selection on the menu screen
        ControllerMode = GameControl.ControllerMode;

        // Set all the axis strings to use _P2 versions, enabling controller use
        if (ControllerMode)
        {
            AimHorizontalAxis = AimHorizontalAxis_Controller;
            AimVerticalAxis   = AimVerticalAxis_Controller;
            StrafeAxis        = StrafeAxis_Controller;
            JumpAxis          = JumpAxis_Controller;
        }
        else
        {
            AimHorizontalAxis = AimHorizontalAxis_Mouse;
            AimVerticalAxis   = AimVerticalAxis_Mouse;
            StrafeAxis        = StrafeAxis_Mouse;
            JumpAxis          = JumpAxis_Mouse;
        }

        PlayerRigidBody = GetComponent <Rigidbody2D>();

        // default to being on the ground
        onGround = true;

        // set up the jump button axis
        JumpButton = new AxisButton(JumpAxis, 0.5f);

        // and the fire button axis
        // FireButton = new AxisButton(FireAxis);

        // Initialize the player position
        playerPos = transform.position;

        // Initialize the joystick position Vector3
        joystickPosition = new Vector3(0, 0, 0);
    }
Example #8
0
    private void Collision(object sender, PointerEventArgs e)
    {
        if (e.target.GetComponent <Point>() != null)
        {
            inPointCollision = true;
            selectedPoint    = e.target.GetComponent <Point>();
        }

        else if (e.target.GetComponent <ScaleButton>() != null)
        {
            scaleButton = e.target.GetComponent <ScaleButton>();
        }

        else if (e.target.GetComponent <AxisButton>() != null)
        {
            axisButton = e.target.GetComponent <AxisButton>();
        }

        else if (e.target.GetComponent <InvertAxisButton>() != null)
        {
            invertAxisButton = e.target.GetComponent <InvertAxisButton>();
        }
    }
Example #9
0
 /// <summary>
 /// Add a joystick AxisButton to the Button.
 /// </summary>
 /// <param name="button">The AxisButton to add.</param>
 /// <param name="joystick">The joystick id of the button to add.</param>
 /// <returns>The Button.</returns>
 public Button AddAxisButton(AxisButton button, int joystick = 0)
 {
     AddJoyButton((int)button, joystick);
     return(this);
 }
Example #10
0
 /// <summary>
 /// Add a joystick AxisButton to the Button.
 /// </summary>
 /// <param name="button">The AxisButton to add.</param>
 /// <param name="joystick">The joystick id of the button to add.</param>
 /// <returns>The Button.</returns>
 public Button AddAxisButton(AxisButton button, int joystick = 0)
 {
     AddJoyButton((int)button, joystick);
     return this;
 }
Example #11
0
 public static bool GetButton( AxisButton button, Index controlIndex )
 {
     var pair    = m_axisButton[ (int)controlIndex ];
     return pair[ button ].m_trigger;
 }
Example #12
0
 /// <summary>
 /// Check if the joystick button is up.
 /// </summary>
 /// <param name="button">The AxisButton to check.</param>
 /// <param name="joystick">The joystick to check.</param>
 /// <returns>True if the AxisButton is up.</returns>
 public bool ButtonUp(AxisButton button, int joystick = 0)
 {
     return(ButtonUp((int)button, joystick));
 }
Example #13
0
 /// <summary>
 /// Check if the joystick AxisButton is released.
 /// </summary>
 /// <param name="button">The AxisButton to check.</param>
 /// <param name="joystick">The joystick to check.</param>
 /// <returns>True if the AxisButton is released.</returns>
 public bool ButtonReleased(AxisButton button, int joystick = 0)
 {
     return ButtonReleased((int)button, joystick);
 }
Example #14
0
 /// <summary>
 /// Add a joystick axis button.
 /// </summary>
 /// <param name="button">The joystick axis button.</param>
 /// <param name="direction">The direction this axis button should effect.</param>
 /// <param name="joystick">The joystick id.</param>
 /// <returns>The Axis.</returns>
 public Axis AddButton(AxisButton button, Direction direction, params int[] joystick) {
     foreach (var j in joystick) {
         AddButton((int)button, direction, j);
     }
     return this;
 }
Example #15
0
 /// <summary>
 /// Create a new Axis using AxisButtons.
 /// </summary>
 /// <param name="up">The AxisButton for Up.</param>
 /// <param name="right">The AxisButton for Right.</param>
 /// <param name="down">The AxisButton for Down.</param>
 /// <param name="left">The AxisButton for Left.</param>
 /// <param name="joystick">The joystick id to use.</param>
 public Axis(AxisButton up, AxisButton right, AxisButton down, AxisButton left, params int[] joystick)
     : this() {
     AddButton(up, Direction.Up, joystick);
     AddButton(right, Direction.Right, joystick);
     AddButton(down, Direction.Down, joystick);
     AddButton(left, Direction.Left, joystick);
 }
Example #16
0
 public static void BindButtonInput(GameButtonID id, string axisName)
 {
     buttons[id] = new AxisButton(axisName);
     PlayerPrefs.SetString(savePref + id, axisName);
 }
Example #17
0
 /// <summary>
 /// Check if the joystick AxisButton is released.
 /// </summary>
 /// <param name="button">The AxisButton to check.</param>
 /// <param name="joystick">The joystick to check.</param>
 /// <returns>True if the AxisButton is released.</returns>
 public bool ButtonReleased(AxisButton button, int joystick = 0)
 {
     return(ButtonReleased((int)button, joystick));
 }
Example #18
0
 /// <summary>
 /// Check if the joystick button is up.
 /// </summary>
 /// <param name="button">The AxisButton to check.</param>
 /// <param name="joystick">The joystick to check.</param>
 /// <returns>True if the AxisButton is up.</returns>
 public bool ButtonUp(AxisButton button, int joystick = 0)
 {
     return ButtonUp((int)button, joystick);
 }
Example #19
0
 /// <summary>
 /// Add a joystick axis button.
 /// </summary>
 /// <param name="button">The joystick axis button.</param>
 /// <param name="direction">The direction this axis button should effect.</param>
 /// <param name="joystick">The joystick id.</param>
 /// <returns>The Axis.</returns>
 public Axis AddButton(AxisButton button, Direction direction, int joystick = 0)
 {
     AddButton((int)button, direction, joystick);
     return this;
 }