// Use this for initialization void Start () { command = GetComponent <PlayerCommand> (); thisCollider = GetComponent <SphereCollider> (); _audio = GetComponent<AudioSource> (); if(GamePlay.IsSingle) { heart = PlayerPrefs.GetInt("Difficulty",1); } //_audio.loop = true; //_audio.volume = 1f; //_audio.clip = audioIdle; _audio.Play(); }
public EngineCommand PollCommand(Bot bot) { var line = Console.ReadLine(); if (string.IsNullOrWhiteSpace(line)) return null; EngineCommand command = null; var parse = line.Split(' '); switch (parse[0]) { case "settings": command = new SettingsCommand(bot.MatchSettings, parse[1], parse[2]); break; case "update": if (parse[1] == "game") { command = new GameStateCommand(bot.GameState, parse[2], parse[3]); } else { if (bot.MatchSettings.PlayerNames.Contains(parse[1])) { if (!bot.Players.ContainsKey(parse[1])) { bot.Players.Add(parse[1], new PlayerState(bot.MatchSettings.FieldWidth, bot.MatchSettings.FieldHeight)); } var player = bot.Players[parse[1]]; command = new PlayerCommand(player, parse[1], parse[2], parse[3]); } else { Console.WriteLine("Invalid player: '{0}'", parse[1]); } } break; case "action": command = new BotCommand(bot, parse[1], parse[2]); break; } if (command == null) { Console.WriteLine("Invalid command: '{0}'", parse[0]); } return command; }
public void ReceiveCommand(PlayerCommand command) { switch (command.Key) { case "row_points": RowsPoints = int.Parse(command.Value); break; case "combo": Combo = int.Parse(command.Value); break; case "field": Field.Parse(command.Value); break; default: Console.WriteLine("Invalid player command: {0}", command.Key); break; } }
public void updateInput(MouseState input, Controller testGameController, View gameView, ViewGamePlayMenu gamePlayMenu) { // Right click to give a command if (input.RightButton == ButtonState.Pressed && prevInput.RightButton == ButtonState.Released) { giveCommand(input, gameView, testGameController); } if(gamePlayMenu.containsPoint(input.X, input.Y)) { if (input.LeftButton == ButtonState.Pressed) { /** Handle Menu Input **/ int button = gamePlayMenu.onButton(input.X, input.Y); //button corespons with the button pressed 0 to 3 left to right if (button == 0) { currentPlayerCommand = PlayerCommand.CANCEL; } if (button == 1) { currentPlayerCommand = PlayerCommand.BUILD; } if (button == 2) { currentPlayerCommand = PlayerCommand.MOVE; } if (button == 3) { currentPlayerCommand = PlayerCommand.ATTACK; } } } else { handleSelecting(input, testGameController, gameView, gamePlayMenu); } prevInput = input; }
// Use this for initialization void Start () { _camera.SetActive(true); command = GetComponent<PlayerCommand>(); mainBomb = GetComponent<MainBomb>(); pa = GetComponent<PlayerAnimation>(); //gamePlay = GameObject.Find("Scripts").GetComponent<GamePlay>(); //hit = GameObject.Find ("CheckHit"); //hit.SetActive(false); Transform controller = GameObject.Find("Controller").transform; // forwardGO = controller.GetChild(0).gameObject; // backwardGO = controller.GetChild(1).gameObject; // leftGO = controller.GetChild(2).gameObject; // rightGO = controller.GetChild(3).gameObject; // bombGO = controller.GetChild(4).gameObject; forwardAnim = controller.GetChild(0).GetComponent<Animator> (); backwardAnim = controller.GetChild(1).GetComponent<Animator> (); leftAnim = controller.GetChild(2).GetComponent<Animator> (); rightAnim = controller.GetChild(3).GetComponent<Animator> (); BombAnim = controller.GetChild(4).GetComponent<Animator> (); }
private static void jumpSpike(PlayerCommand command, Player player) { Jump(command); player.IsSpiking = true; }
public async Task Execute(PlayerCommand command) { var url = "device/execute"; await this.PostAsync <PlayerCommand>(url, command); }
/// <summary> /// Handles execusion of player command by this engine /// </summary> /// <param name="enteredCommand">Options that the game offers to a player</param> private void ExecutePlayerCommand(PlayerCommand playerCommand) { switch (playerCommand) { case PlayerCommand.Top: UserInterface.ShowScoreboard(this.ScoreBoard); break; case PlayerCommand.Help: if (this.number.RevealDigit(this.player.Cheats)) { UserInterface.ShowHelp(this.number.HelpNumber.ToString()); this.player.Cheats++; } else { UserInterface.ShowCheatsLimitReached(); } break; case PlayerCommand.Restart: Restart(); break; case PlayerCommand.Exit: Exit(); break; default: break; } }
/// <summary> /// Method handles entered by the player command <paramref name="enteredCommand"/>, /// calling other methods each responsible for different interactions. /// </summary> /// <param name="enteredCommand">Options that the game offers to a player</param> /// <param name="playerInput">Command that player enters</param> /// <param name="player">The user that's playing at the moment</param> private void ExecuteCommand(PlayerCommand enteredCommand, string playerInput) { if (enteredCommand != PlayerCommand.Other) { ExecutePlayerCommand(enteredCommand); } else { CheckPlayerInput(playerInput); } }
/// <summary> /// This is the method that each new game strats with. It calls several /// other helper methods. /// </summary> public void StartGame() { PlayerCommand enteredCommand = new PlayerCommand(); do { UserInterface.ShowWelcomeGreeting(); this.player = new Player("NoName"); this.number = new GameNumber(); this.restart = false; this.exit = false; do { string playerInput = UserInterface.GetPlayerCommand(); enteredCommand = CommandParser.PlayerInputToPlayerCommand(playerInput); ExecuteCommand(enteredCommand, playerInput); } while (!this.restart && !this.exit); UserInterface.EndOfGameMessage(); } while (!this.exit); UserInterface.ShowFairwell(); }
private void OnPlayerCommand(PlayerCommand command) { if (command is PlaylistBegins) OnPlaylistBegins(); if (command is PlaylistFinished) OnPlaylistFinished(); if (command is PlayClip) OnPlayClip((PlayClip)command); }
public static void SetPlayerCommand(SMFPlayer player, PlayerCommand value) { player.SetValue(PlayerCommandProperty, value); }
public void Handle(PlayerCommand command) { var ball = command.Ball; var player = command.Player; var isRightSide = player.Position.x > 0; var side = isRightSide ? 4f : -4f; var state = player.SpikeState; var target = new Vector3(side, 0, player.TeamFoward.z * -1); if (player.IsPassTarget && ball.LandingSpot.HasValue) { var newTarget = ball.Trajectory.Points.Where(ballPosition => ballPosition.y <player.SpikeHeight && ballPosition.y> 2.4f).LastOrDefault(); target = newTarget != default(Vector3) ? newTarget : ball.LandingSpot.Value; } if (state == SpikeStateEnum.Initial || state == SpikeStateEnum.Moving || state == SpikeStateEnum.AwaitingOrMovingToPassTarget) { if (state == SpikeStateEnum.Initial) { state = SpikeStateEnum.Moving; } if (!player.ArrivedInTarget(target)) { MoveToTarget(target, command); return; } else { state = state == SpikeStateEnum.Moving ? SpikeStateEnum.AwaitingOrMovingToPassTarget : SpikeStateEnum.PreJump; command.PlayerTransform.forward = player.TeamFoward; player.SpikeState = state; return; } } if (!player.IsPassTarget) { return; } if (state == SpikeStateEnum.PreJump && player.CanStartSpikeJump(ball.transform.position, ball.Velocity)) { jumpSpike(command, player); player.SpikeState = SpikeStateEnum.Jumping; return; } if (state == SpikeStateEnum.Jumping && player.InSpikeRange(ball.Position)) { spike(ball, player, isRightSide); player.SpikeState = SpikeStateEnum.Finished; return; } }
// the user has issued a command // the ship will attempt to comply public void SendCommand(PlayerCommand command, GameTime gameTime) { float timeScale = (float)gameTime.ElapsedGameTime.TotalSeconds; timeScale = 1.0f; // default animation -- may get overwritten later in SendCommand: currentAnim = ShipAnim.FlyStraight; switch(command) { case PlayerCommand.Idle: { // no commands from the user break; } case PlayerCommand.FlyLeft: { xPos -= (int)(speed * timeScale); if (xPos <= 0) xPos = 0; currentAnim = ShipAnim.FlyLeft; break; } case PlayerCommand.FlyRight: { xPos += (int)(speed * timeScale); if (xPos >= 700) xPos = 700; currentAnim = ShipAnim.FlyRight; break; } case PlayerCommand.FlyForward: { yPos -= (int)(speed * timeScale); if (yPos <= 0) yPos = 0; break; } case PlayerCommand.FlyBackward: { yPos += (int)(speed * timeScale); if (yPos >= 500) yPos = 500; // TODO: get rid of magic numbers break; } case PlayerCommand.Fire: { fireCooldownRemaining = fireDelay; break; } case PlayerCommand.AltFire: { break; } default: { break; } } }
private void ExecuteCommand(PlayerCommand command) { switch (command) { case PlayerCommand.Top: { ScoreBoard.Instance.Print(); break; } case PlayerCommand.Restart: { PlayerHelper.ClearHelp(); this.cheats = 0; this.attempts = 0; Console.WriteLine(); break; } case PlayerCommand.Help: { this.cheats = PlayerHelper.PrintHelp(cheats, generatedNumber); break; } case PlayerCommand.Exit: { break; } case PlayerCommand.Other: if (IsValidInput()) { ProcessGame(); } else { ConsolePrinter.PrintWrongCommandMessage(); } break; default: { throw new InvalidOperationException("Invalid Input Command!"); } } }
protected override void CommandCompleted() { PlayerCommand.CommandComplete(); }
/// <summary> /// 注册动作事件 /// </summary> /// <param name="type">Type.</param> /// <param name="methodName">Method name.</param> public void RegisterActorMethod(PlayerCommand type, string methodName) { Actor.AddMethod((int)type, methodName); }