public static TopDownActions CreateWithKeyboardBindings() { var actions = new TopDownActions(); actions.Jump.AddDefaultBinding(Key.Space); actions.Crouch.AddDefaultBinding(Key.LeftShift); actions.Interact.AddDefaultBinding(Key.E); actions.Command.AddDefaultBinding(Key.Q); actions.MoveUp.AddDefaultBinding(Key.W); actions.MoveDown.AddDefaultBinding(Key.S); actions.MoveLeft.AddDefaultBinding(Key.A); actions.MoveRight.AddDefaultBinding(Key.D); actions.FaceUp.AddDefaultBinding(Mouse.PositiveY); actions.FaceDown.AddDefaultBinding(Mouse.NegativeY); actions.FaceLeft.AddDefaultBinding(Mouse.NegativeX); actions.FaceRight.AddDefaultBinding(Mouse.PositiveX); actions.Primary.AddDefaultBinding(Mouse.LeftButton); actions.Secondary.AddDefaultBinding(Mouse.RightButton); actions.LockOn.AddDefaultBinding(Mouse.MiddleButton); return(actions); }
public HumanPlayer(UnityView view, InputDevice inputDevice, TopDownActionCamera camera) { this.view = view; this.inputDevice = inputDevice; actions = TopDownActions.CreateWithJoystickBindings(); actions.Device = inputDevice; GameObject cursorObject = new GameObject(); CameraFocus focus = cursorObject.AddComponent <CameraFocus> (); focus.weight = 1f; cursor = cursorObject.AddComponent <BuildCursor> (); this.camera = camera; camera.SetFocus(cursor.gameObject.GetComponent <CameraFocus>()); cursor.AssertControl(actions, this); SetState(ControlState.BUILDING_GAME); }
public static TopDownActions CreateWithJoystickBindings() { var actions = new TopDownActions(); actions.Jump.AddDefaultBinding(InputControlType.Action1); actions.Crouch.AddDefaultBinding(InputControlType.Action2); actions.Interact.AddDefaultBinding(InputControlType.Action3); actions.Command.AddDefaultBinding(InputControlType.Action4); actions.MoveUp.AddDefaultBinding(InputControlType.LeftStickUp); actions.MoveDown.AddDefaultBinding(InputControlType.LeftStickDown); actions.MoveLeft.AddDefaultBinding(InputControlType.LeftStickLeft); actions.MoveRight.AddDefaultBinding(InputControlType.LeftStickRight); actions.FaceUp.AddDefaultBinding(InputControlType.RightStickUp); actions.FaceDown.AddDefaultBinding(InputControlType.RightStickDown); actions.FaceLeft.AddDefaultBinding(InputControlType.RightStickLeft); actions.FaceRight.AddDefaultBinding(InputControlType.RightStickRight); actions.Primary.AddDefaultBinding(InputControlType.RightBumper); actions.Secondary.AddDefaultBinding(InputControlType.LeftBumper); actions.TriggerAction.AddDefaultBinding(InputControlType.RightTrigger); actions.LockOn.AddDefaultBinding(InputControlType.LeftTrigger); actions.SpeechUp.AddDefaultBinding(InputControlType.DPadUp); actions.SpeechDown.AddDefaultBinding(InputControlType.DPadDown); actions.SpeechLeft.AddDefaultBinding(InputControlType.DPadLeft); actions.SpeechRight.AddDefaultBinding(InputControlType.DPadRight); actions.Back.AddDefaultBinding(InputControlType.Back); actions.Start.AddDefaultBinding(InputControlType.Start); actions.Bonus1.AddDefaultBinding(InputControlType.RightStickButton); actions.Bonus2.AddDefaultBinding(InputControlType.LeftStickButton); return(actions); }
public void AssertControl(TopDownActions actions, HumanPlayer player) { this.actions = actions; this.player = player; underDirectControl = true; cc = gameObject.GetComponent <CharacterController> (); if (cc == null) { cc = gameObject.AddComponent <CharacterController> (); } if (characterFocus == null) { characterFocus = (new GameObject()).transform; CameraFocus focus = characterFocus.gameObject.AddComponent <CameraFocus> (); focus.weight = 1f; focus.mustStayOnScreen = true; characterFocus.position = transform.position; } if (player != null) { //TODO this is a problem right here.... player.camera.AddFocus(characterFocus.gameObject.GetComponent <CameraFocus> ()); } }
bool JoinButtonWasPressedOnListener(TopDownActions actions) { return(actions.Primary.WasPressed || actions.Jump || actions.Crouch || actions.Interact || actions.Command); }
public void ReleaseControl() { this.actions = null; underDirectControl = false; player = null; }
public void AssertControl(TopDownActions actions, HumanPlayer player) { this.actions = actions; this.player = player; underDirectControl = true; }