private void ShouldOpemPopupList() { List <JumpCommandObject> autoCompletions = JumpCommand.GetAutoCompletionCommandObjects(input); if (autoCompletions.Count > 0) { List <string> content = new List <string>(); foreach (var command in autoCompletions) { content.Add(GetCommandRichText(command)); } popupListCommand = autoCompletions; popupListContent = content.ToArray(); if (!popupListOpen) { OpenPopupList(); } } else { if (popupListOpen) { ClosePopupList(); } } }
static private void ChangeGameObjectCallee(string gameObjectPath = "") { if (gameObjectPath == "~" || gameObjectPath == "") // go to current selected game object { JumpCommand.SetCallee(Selection.activeGameObject); } else if (gameObjectPath == "/") // go to root, always null { JumpCommand.SetCallee(null); } else if (gameObjectPath.StartsWith("/")) // use absolut path { var foundOne = GameObject.Find(gameObjectPath); if (foundOne != null) { JumpCommand.SetCallee(foundOne); } else { Debug.LogError("Can not found " + gameObjectPath); } } else { string[] paths = gameObjectPath.Split(new char[] { '/' }); foreach (var p in paths) { ChangeGameObjectCalleeInner(p); } } }
void InitMoveCommand() { var leftMove = new MoveCommand(movement2D, animator, transform, -1); var rightMove = new MoveCommand(movement2D, animator, transform, 1); var stopMove = new MoveCommand(movement2D, animator, transform, 0); commandInvoker.AddCommand("LEFT_MOVE", leftMove); commandInvoker.AddCommand("RIGHT_MOVE", rightMove); commandInvoker.AddCommand("STOP_MOVE", stopMove); var dash = new DashCommand(movement2D); commandInvoker.AddCommand("DASH", dash); var jump = new JumpCommand(movement2D); commandInvoker.AddCommand("JUMP", jump); var downJump = new DownJumpCommand(movement2D); commandInvoker.AddCommand("DOWN_JUMP", downJump); var swordAttack = new SwordAttackCommand(playerBattle, animator); commandInvoker.AddAttackCommand("SWORD_ATTACK", swordAttack); }
void Update() { testVel = Velocity; // abstract out input float inputX = Input.GetAxisRaw("Horizontal"); if (inputX != 0) { SwitchState(State.Run); if (inputX < 0) { SwitchDir(Direction.Left); } else { SwitchDir(Direction.Right); } moveByXCommand.execute(this); } else { SwitchState(State.Idle); } if (Input.GetKeyDown(KeyCode.Space)) { JumpCommand j = new JumpCommand(); j.execute(this); } }
private void BuildJumpTable(Sequence seq) { jumpTargets = new Dictionary <uint, int>(); foreach (BaseSequenceCommand cmd in seq.commands) { JumpCommand jmp = cmd as JumpCommand; if (jmp == null) { continue; } if (jmp is OpenTrackCommand trk) { jumpTargets[jmp.target] = trk.Track; } else { if (jmp.type == JumpCommand.JumpType.CALL) { jumpTargets.TrySet(jmp.target, -2); } else { jumpTargets.TrySet(jmp.target, -1); } } } }
// Start is called before the first frame update void Start() { commandSpace = new JumpCommand(); commandA = new MoveLeftCommand(); commandS = new MoveBackwardCommand(); commandD = new MoveRightCommand(); commandW = new MoveForwardCommand(); }
private static void Main(string[] args) { ICommand moveCommand = new MoveCommand(); ICommand jumpCommand = new JumpCommand(); ICommand shootCommand = new ShootCommand(); InputHandler inputHandler = new InputHandler(moveCommand, jumpCommand, shootCommand); }
private void ShowWork(object sender, System.Windows.RoutedEventArgs e) { ICommand command = new FlyCommand(); command.Execute(ExampleBlock); command = new JumpCommand(); command.Execute(ExampleBlock); }
private void Jump() { JumpCommand jumpCommand = new JumpCommand(PlayerSettings.JumpForce, _heightAtJump); jumpCommand.execute(null, _player); _jumpCommands.Enqueue(jumpCommand); _player.PlaySound("jump"); }
// Use this for initialization void Start() { buttonZ = new Slowtime(); buttonX = new NormalizeTime(); buttonLeftMouse = new FireWeapon(); buttonESC = new PauseGame(); buttonSpace = new JumpCommand(); buttonLeftShift = new DashCommand(); buttonB = new ChangeWeapon(); }
public void JumpCommand_With_Supercruise_Payload_Does_Nothing() { var sut = new JumpCommand(_communicator, _navigator, _phrases, new Preferences()); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand).WithPayload("JumpType", "Supercruise"); sut.Handle(testEvent); _communicator.MessagesCommunicated.Should().BeEmpty(); }
private void Start() { rightCom = new RightCommand(); leftCom = new LeftCommand(); attackCom = new AttackCommand(); jumpCom = new JumpCommand(); crouchCom = new CrouchCommand(); idleCom = new IdleCommand(); specialCom = new SpecialCommand(); altSpecialCom = new AltSpecialCommand(); mindControlCom = new MindControlCommand(); }
private void Awake() { _commandProcessor = new CommandProcessor(); _walkCommand = new WalkCommand(this, moveVel); _jumpCommand = new JumpCommand(this, jumpForce); m_rigidbody = GetComponent <Rigidbody2D>(); m_animator = transform.GetChild(0).GetComponent <Animator>(); isJumping = false; isFalling = false; }
protected internal override void VisitJumpCommand(JumpCommand jumpCommand) { this.WriteIndent(); if (string.IsNullOrWhiteSpace(jumpCommand.Label)) { this.writer.WriteLine("jump {0}", jumpCommand.Path); } else { this.writer.WriteLine("jump {0} {1}", jumpCommand.Path, jumpCommand.Label); } }
public void OnJumpCommand(JumpCommand cmd) { //非溶入状态且在地面设置跳跃标志位 if (IsGroundByCollider() && !Model.MeltStatus) { Model.Jump = true; } else { Model.LastJumpReqTime = Time.fixedTime; } }
public void JumpCommand_With_System_Not_In_Expedition_Skips_System_And_Does_Not_Communicate() { var preferences = new Preferences() { CommunicateSkippableSystems = false }; var sut = new JumpCommand(_communicator, _navigator, _phrases, preferences); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand).WithPayload("StarSystem", "Test"); sut.Handle(testEvent); _communicator.MessagesCommunicated.Single().Should().Be(_phrases.Jumping.Single()); }
public void JumpCommand_With_Unscanned_System_In_Expedition_Communicates() { var sut = new JumpCommand(_communicator, _navigator, _phrases, new Preferences()); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand).WithPayload("StarSystem", _starSystems.First().Name); _navigator.ExtendExpedition(_starSystems); sut.Handle(testEvent); _communicator.MessagesCommunicated[0].Should().Be(_phrases.Jumping.Single()); _communicator.MessagesCommunicated[1].Should().Contain(_phrases.Scanning.Single()); }
private void Fall() { JumpCommand fallCommand = new JumpCommand(_currentFallForce, _heightAtJump); fallCommand.execute(null, _player); _jumpCommands.Enqueue(fallCommand); _currentFallForce += PlayerSettings.DefaultFallAcceleration; _currentTimer--; if (_player.IsGrounded() && _currentTimer <= 0 && !_undoActive) { _player.EnterState(new DefaultPlayerState()); } }
//跳跃 protected virtual CommandReplyType CheckJump(JumpCommand cmd) { if (CannotControlSelf()) { return(CommandReplyType.NO); } if (GetActorState(ActorStateType.IsRide)) { ShowWarning("100011"); return(CommandReplyType.NO); } ChangeState <ActorJumpFsm>(); return(CommandReplyType.YES); }
private void SerializeIf(JumpCommand cmd) { switch (cmd.type) { case JumpCommand.JumpType.JUMP: sb.AppendFormat("jump_if {0}\n", positionLabel(cmd.target)); break; case JumpCommand.JumpType.CALL: sb.AppendFormat("call_if {0}\n", positionLabel(cmd.target)); break; default: throw new ArgumentException("bogus jump type"); } }
private void OnSumbitCommandAction() { try { JumpCommand.Execute(input); input = ""; } catch (JumpCommandException e) { shockPixel = 2; Invoke("StopShock", 0.2f); Debug.LogError("Execute Failed: " + e.Message); } catch { shockPixel = 2; Invoke("StopShock", 0.2f); throw; } }
void Start() { // Instantiate commands Command jumpCommand = new JumpCommand(); Command moveCommand = new MoveCommand(); // TODO: do this more dynamically // TODO: pull commands from Actor, rather than operating off same set of commands for each actor commands = new List <Command> { moveCommand, jumpCommand }; // Set actor to player if null if (controlledActor == null) { SetActor(FindPlayer()); } }
private void HandleTab() { TextEditor te = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); if (KeyDown("tab") && popupListOpen) { input = popupListCommand[popupListSelIndex].Name; te.pos = input.Length; te.selectPos = te.pos; ClosePopupList(); } else if (KeyDown("tab") && !popupListOpen) { List <JumpCommandObject> autoCompletions = JumpCommand.GetAutoCompletionCommandObjects(input); if (autoCompletions.Count > 0) { List <string> content = new List <string>(); foreach (var command in autoCompletions) { content.Add(GetCommandRichText(command)); } popupListCommand = autoCompletions; popupListContent = content.ToArray(); input = popupListCommand[popupListSelIndex].Name; te.pos = input.Length; te.selectPos = te.pos; OpenPopupList(); } } // Press tab to switch among auto-completion commands // if (KeyDown("tab")) // { // // eg: com[mand] // // The unselected part of a command // string substr = input.Substring(0, te.pos); // string command = JumpCommand.GetAutoCompletionCommand(substr, input); // if(command != null) { // input = command; // te.pos = input.Length; // } // } }
//----------------------------------------------------------------- private void MainWindow_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.Space) { MainWindow.JumpCommand jump = new JumpCommand(); jump.Execute(); } if (e.Key == Key.W) { ClimbCommand climb = new ClimbCommand(); climb.Execute(); } if (e.Key == Key.F) { FireCommand fire = new FireCommand(); fire.Execute(); } }
private void InitializeDefaultControls() { //mapping the defaultControls JumpCommand jump = new JumpCommand(); _AButton = SetButton(jump); InitCrouchCommand crouch = new InitCrouchCommand(); _BButton = SetButton(crouch); InitiateGrappleCommand grap = new InitiateGrappleCommand(); _LeftBumperDown = SetButton(grap); DeatchGrappleCommand dGrap = new DeatchGrappleCommand(); _LeftBumperUp = SetButton(dGrap); }
static private void ChangeGameObjectCalleeInner(string gameObjectPath = "") { if (gameObjectPath == "..") // return to parent game object { if (JumpCommand.Callee is GameObject) { var go = JumpCommand.Callee as GameObject; if (go.transform.parent == null) { JumpCommand.SetCallee(null); } else { JumpCommand.SetCallee(go.transform.parent.gameObject); } } } else if (gameObjectPath == ".") { // do nothing } else if (gameObjectPath == "~" || gameObjectPath == "") // go to current selected game object { JumpCommand.SetCallee(Selection.activeGameObject); } else if (gameObjectPath == "/") // go to root, always null { JumpCommand.SetCallee(null); } else { string fullGameObjectPath = GetGameObjectFullName(JumpCommand.Callee as GameObject) + gameObjectPath; var foundOne = GameObject.Find(fullGameObjectPath); if (foundOne != null) { JumpCommand.SetCallee(foundOne); } else { Debug.LogError("Can not found " + gameObjectPath); } } }
// Use this for initialization void Start() { commandStream = new CommandStream(); commandRecord = new Dictionary <ObjectBase, List <CommandStream> > (); CommandConversion Do_FrieCommand = (ObjectBase playObj) => { FrieCommand frie = new FrieCommand(); frie.Execute(playObj); commandRecord [playObj].Add(frie); }; CommandConversion Do_EludeCommand = (ObjectBase playObj) => { EludeCommand elude = new EludeCommand(); elude.Execute(playObj); commandRecord [playObj].Add(elude); }; CommandConversion Do_JumpCommand = (ObjectBase playObj) => { JumpCommand jump = new JumpCommand(); jump.Execute(playObj); commandRecord [playObj].Add(jump); }; CommandConversion Do_SupplementCommand = (ObjectBase playObj) => { SupplementCommand supplement = new SupplementCommand(); supplement.Execute(playObj); commandRecord [playObj].Add(supplement); }; CommandConversion Do_WalkCommand = (ObjectBase playObj) => { WalkCommand walk = new WalkCommand(); walk.Execute(playObj); commandRecord [playObj].Add(walk); }; CommandRoute.Add(CommandType.EludeCommand, Do_EludeCommand); CommandRoute.Add(CommandType.FrieCommand, Do_FrieCommand); CommandRoute.Add(CommandType.JumpCommand, Do_JumpCommand); CommandRoute.Add(CommandType.SupplementCommand, Do_SupplementCommand); CommandRoute.Add(CommandType.WalkCommand, Do_WalkCommand); }
public void JumpCommand_With_Already_Scanned_Skips_System_And_Does_Not_Communicate() { var preferences = new Preferences() { CommunicateSkippableSystems = false }; var sut = new JumpCommand(_communicator, _navigator, _phrases, preferences); var celestial = Build.A.Celestial.ThatHasBeenScanned(); var system = Build.A.StarSystem.WithCelestial(celestial); var systems = Build.Many.StarSystems(system); _navigator.ExtendExpedition(systems); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand).WithPayload("StarSystem", system.Name); sut.Handle(testEvent); _communicator.MessagesCommunicated.Single().Should().Be(_phrases.Jumping.Single()); }
public UnitCommand Process(IController controller) { var state = controller.Get; if (state.WantJump) { var jumpTime = state.JumpPressTime; var process = new JumpCommand(_context); if (jumpTime < MinJumpTime) { process.JumpPower = MinJumpPower; } else { process.JumpPower = MinJumpPower + Mathf.Clamp01((jumpTime - MinJumpTime) / (MaxJumpTime - MinJumpTime)) * JumpPowerDelta; } return(process); } return(null); }
public GameController(Game1 game) { _keyboard = new KeyboardController(); var quit = new QuitCommand(game); BindCommand(quit, null, Keys.Q); var moveLeft = new MoveLeftCommand(game); var releaseLeft = new ReleaseLeftCommand(game); var moveRight = new MoveRightCommand(game); var releaseRight = new ReleaseRightCommand(game); var jump = new JumpCommand(game); var releaseJump = new ReleaseJumpCommand(game); BindCommand(moveLeft, releaseLeft, Keys.A); BindCommand(moveRight, releaseRight, Keys.D); BindCommand(jump, releaseJump, Keys.W); var boundbox = new DrawBoundBoxCommand(game); BindCommand(boundbox, null, Keys.C); }
void Update() { testVel = Velocity; // abstract out input float inputX = Input.GetAxisRaw("Horizontal"); if (inputX != 0) { SwitchState(State.Run); if (inputX < 0) SwitchDir(Direction.Left); else SwitchDir(Direction.Right); moveByXCommand.execute(this); } else { SwitchState(State.Idle); } if (Input.GetKeyDown(KeyCode.Space)) { JumpCommand j = new JumpCommand(); j.execute(this); } }