Example #1
0
	public void AddPlayer(ControllerInputWrapper.Buttons connectCode) {
		KeyboardWrapper kw = new KeyboardWrapper(-1);
		if(!playerControls.ContainsValue(kw) && kw.GetButton(connectCode)) {
			for(int j = 1; j < 5; j++) {
				if(!playerControls.ContainsKey((PlayerID)j)) {
					playerControls.Add((PlayerID)(j), kw);
					Debug.Log((PlayerID)(j) + ": " + kw + " added");
					return;
				}
			}
		}
		if(playerControls.Count < 4) {
			string[] controllerNames = Input.GetJoystickNames();
			for (int i = 0; i < controllerNames.Length; i++) {
				ControllerInputWrapper ciw = getControllerType(i);
				if(ciw != null && !playerControls.ContainsValue(ciw) && ciw.GetButton(connectCode)) {
					for(int j = 1; j < 5; j++) {
						if(!playerControls.ContainsKey((PlayerID)j)) {
							playerControls.Add((PlayerID)(j), ciw);
							Debug.Log((PlayerID)(j) + ": " + ciw + " added");
							break;
						}
					}
				}
			}
		}
	}
	public bool AddPlayer(ControllerInputWrapper.Buttons connectCode) {
		KeyboardWrapper kw = new KeyboardWrapper(-1);
		if(!playerControls.ContainsValue(kw) && kw.GetButton(connectCode)) {
			for(int j = 1; j < 5; j++) {
				if(!playerControls.ContainsKey((PlayerID)j)) {
					RegisterPlayerController(j, kw);
					return true;
				}
			}
		}
		if(playerControls.Count < 4) {
			string[] controllerNames = Input.GetJoystickNames();
			for (int i = 0; i < controllerNames.Length; i++) {
				ControllerInputWrapper ciw = getControllerType(i);
				if(ciw != null && !playerControls.ContainsValue(ciw) && ciw.GetButton(connectCode)) {
					for(int j = 1; j < 5; j++) {
						if(!playerControls.ContainsKey((PlayerID)j)) {
							RegisterPlayerController(j, ciw);
							return true;
						}
					}
				}
			}
		}

		return false;
	}
Example #3
0
 public static bool GetButton(ControllerInputWrapper.Buttons button, int joyNum, bool isDown = false)
 {
     joyNum--;
     //Debug.Log(joyNum);
     if (joyNum < 0)
     {
         if (joyNum == -1)
         {
             return(keyboardWrapper.GetButton(button, joyNum, isDown));
         }
         return(false);
     }
     if (playerControls[joyNum] == null)
     {
         return(false);
     }
     return(playerControls[joyNum].GetButton(button, joyNum + 1, isDown));
 }
Example #4
0
    public bool AddPlayer(ControllerInputWrapper.Buttons connectCode)
    {
        KeyboardWrapper kw = new KeyboardWrapper(-1);

        if (!playerControls.ContainsValue(kw) && kw.GetButton(connectCode))
        {
            for (int j = 1; j < 5; j++)
            {
                if (!playerControls.ContainsKey((PlayerID)j))
                {
                    playerControls.Add((PlayerID)(j), kw);
                    Debug.Log((PlayerID)(j) + ": " + kw + " added");
                    return(true);
                }
            }
        }
        if (playerControls.Count < 4)
        {
            string[] controllerNames = Input.GetJoystickNames();
            for (int i = 0; i < controllerNames.Length; i++)
            {
                ControllerInputWrapper ciw = getControllerType(i);
                if (ciw != null && !playerControls.ContainsValue(ciw) && ciw.GetButton(connectCode))
                {
                    for (int j = 1; j < 5; j++)
                    {
                        if (!playerControls.ContainsKey((PlayerID)j))
                        {
                            playerControls.Add((PlayerID)(j), ciw);
                            Debug.Log((PlayerID)(j) + ": " + ciw + " added");
                            return(true);
                        }
                    }
                }
            }
        }

        return(false);
    }