示例#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;
	}
示例#3
0
        protected override void Update(GameTime gameTime)
        {
            KeyboardWrapper.UpdateState();
            GamePadWrapper.UpdateAllGamePads();
            MouseUtility.Update();
            FrameCounter.IncrementFrameCount();

            myStateStack.ResolveQueuedThings();

            if (myStateStack.GetCurrentState() == null)
            {
                Exit();
                return;
            }

            myStateStack.Update();

            base.Update(gameTime);
            NetPostMaster.Master.ResolveMessages();
        }
示例#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);
    }