public static CharacterSelectActions CreateWithKeyboardBindingsToJoin() { var actions = new CharacterSelectActions(); actions.Join.AddDefaultBinding(Key.Space); actions.Start.AddDefaultBinding(Key.Return); return(actions); }
public void Join(Sprite portrait, CharacterSelectActions actions, int characterIndex) { portraitRenderer.sprite = portrait; anim.SetTrigger("Join"); available = false; this.actions = actions; CharacterIndex = characterIndex; }
public static CharacterSelectActions CreateWithKeyboardBindingsToSelectCharacter(Key left, Key right, Key leave) { var actions = new CharacterSelectActions(); actions.ChangeLeft.AddDefaultBinding(left); actions.ChangeRight.AddDefaultBinding(right); actions.Leave.AddDefaultBinding(leave); return(actions); }
public void Leave() { anim.SetTrigger("Leave"); portraitRenderer.sprite = null; available = true; actions = null; container.Remove(CharacterIndex); }
public static CharacterSelectActions CreateWithJoystickBindings() { var actions = new CharacterSelectActions(); actions.Join.AddDefaultBinding(InputControlType.Action1); actions.Leave.AddDefaultBinding(InputControlType.Action2); actions.ChangeLeft.AddDefaultBinding(InputControlType.LeftBumper); actions.ChangeRight.AddDefaultBinding(InputControlType.RightBumper); actions.Start.AddDefaultBinding(InputControlType.Start); return(actions); }
PlayerInputConfiguration CreatePlayer(PlayerActions actions, CharacterSelectActions characterSelectActions) { if (players.Count < container.MAX_PLAYERS) { int index = container.GetAvailablePlayerIndex(); PlayerInputConfiguration player = new PlayerInputConfiguration(index, actions, players.Count + 1); players.Add(player); playerJoin.Join(index, characterSelectActions); return(player); } return(null); }
void OnEnable() { container = PlayerConfigurationContainer.getInstance(); players = container.Configurations; players.Clear(); InputManager.OnDeviceDetached += OnDeviceDetached; playerJoin = GetComponent <PlayerJoin> (); selectKeyboardListenerP1 = CharacterSelectActions.CreateWithKeyboardBindingsToSelectCharacter(Key.A, Key.D, Key.LeftShift); selectKeyboardListenerP2 = CharacterSelectActions.CreateWithKeyboardBindingsToSelectCharacter(Key.LeftArrow, Key.RightArrow, Key.RightShift); joinKeyboardListener = CharacterSelectActions.CreateWithKeyboardBindingsToJoin(); joystickListener = CharacterSelectActions.CreateWithJoystickBindings(); keyboardP1 = PlayerActions.CreateWithKeyboardBindingsForPlayerOne(); keyboardP2 = PlayerActions.CreateWithKeyboardBindingsForPlayerTwo(); }
void Update() { if (JoinButtonWasPressedOnListener(joystickListener)) { var inputDevice = InputManager.ActiveDevice; if (FindPlayerUsingJoystick(inputDevice) == null) { var actions = PlayerActions.CreateWithJoystickBindings(); var characterSelectActions = CharacterSelectActions.CreateWithJoystickBindings(); characterSelectActions.Device = inputDevice; actions.Device = inputDevice; CreatePlayer(actions, characterSelectActions); } } if (JoinButtonWasPressedOnListener(joinKeyboardListener)) { var keyboardCount = container.GetKeyboardCount(); if (keyboardCount >= 2) { return; } PlayerActions actions = keyboardCount == 0 ? keyboardP1 : keyboardP2; CharacterSelectActions characterSelectActions = keyboardCount == 0 ? selectKeyboardListenerP1 : selectKeyboardListenerP2; CreatePlayer(actions, characterSelectActions); } if (container.Configurations.Count <= 1) { return; } if (joinKeyboardListener.Start.WasPressed || joystickListener.Start.WasPressed) { StartGame(); } }
public void Join(int colorIndex, CharacterSelectActions bannerActions) { var banner = GetAvailableBanner(); banner.Join(portraitImages[colorIndex], bannerActions, colorIndex); }
bool JoinButtonWasPressedOnListener(CharacterSelectActions actions) { return(actions.Join.WasPressed); }