public MultiAction(GameAction p_action, int p_count, int p_delay) { this.action = p_action; this.count = p_count; this.delay = p_delay; this.waiting = false; }
public override void TagAndNotify(Player source, List<Player> dests, ICard card, GameAction action = GameAction.Use) { if (this.IsReforging(source, null, null, dests)) { if (card is CompositeCard) { foreach (Card c in (card as CompositeCard).Subcards) { c.Log.Source = source; c.Log.GameAction = GameAction.Reforge; } } else { var c = card as Card; Trace.Assert(card != null); c.Log.Source = source; c.Log.GameAction = GameAction.Reforge; } Game.CurrentGame.NotificationProxy.NotifyReforge(source, card); return; } base.TagAndNotify(source, dests, card, action); }
public override bool validate( GameAction gameAction ) { PieceSelection selectionAction = (PieceSelection)gameAction; // Verify that the selected piece belongs to player on turn return selectionAction.belongsToAttacker == Game.currentPlayer.isAttackerPlayer ; }
/* The keeper will move to a new position depending on the ball's position and direction. */ public override PlayerAction ActionWithoutBall(Player player, GameAction gameAction) { Pathfinding pathfinding = new Pathfinding(); Point ballTarget = GameAI.BallNextRoundLocation(); bool onOwnSide = GameAI.IsPointOnOwnSide(GameAI.PlayersTeam(player), ballTarget); if (onOwnSide) { if (GameAI.GameBall.IsInShootState) { Point ballTargetGridLocation = pathfinding.GetGridLocation(GameAI.GameBall.ExactTargetLocation); Goal ownGoal = GameAI.PlayersTeam(player).TeamGoal; Point? pointBeforeGoalEntry = GameAI.PointBeforeRectangleEntry(ownGoal.GoalRectangle); //true if the ball will go through the goal if (pointBeforeGoalEntry.HasValue) { return GoalKeeperShootDefense(player, pointBeforeGoalEntry.Value); } } else { return GoalKeeperPassDefense(player, ballTarget); } } return null; }
public SkeletonAction(GameAction p_jump) { this.jump = p_jump; this.reverse = new Reverse(); this.facePlayer = new FacePlayer(); this.wait = new Wait(120); }
public void SendAction(GameAction gameAction, Dictionary<string, GameData> data) { var sb = new StringBuilder(); sb.Append((int) gameAction); if (data != null) { sb.Append(":"); foreach (var d in data) { var valueStr = d.Value.String(); if (d.Value.Type == GameDataType.String) { valueStr = "'" + valueStr + "'"; } sb.Append($"['{d.Key}':{valueStr}]"); } } sb.Append(";\n"); Console.WriteLine(sb); _dataWriter.Write(sb.ToString()); _dataWriter.Flush(); }
private void HandleAction(GameAction action) { TryHandlePlayCardAction(action); TryHandleAttackAction(action); TryHandleDeathAction(action); TryHandleShowEntity(action); TryHandleOtherAction(action); }
public ProcessResult ProcessSubAction(GameAction action) { var actionResult = ProcessAction(action); painter.DrawMessage(Message); return actionResult; }
static public void PushActionPool(int actionId, GameAction action) { RemoveActionPool(actionId); SocketPackage package = new SocketPackage(); package.ActionId = actionId; package.Action = action; ActionPools.Add(package); }
void Next () { if (queue.Count < 1) { return; } currentAction = (GameAction)queue.Dequeue(); currentAction.behaviour.SendMessage(currentAction.methodName, SendMessageOptions.RequireReceiver); }
public DataTransfer(CardIdentifier _cardID, GameAction _gameAction, int _other1, int _other2, int _other3, string _str1) { cardID = _cardID; gameAction = _gameAction; other1 = _other1; other2 = _other2; other3 = _other3; str1 = _str1; }
public void SetUpInput() { GameAction timeTravel = new GameAction( this, this.GetType().GetMethod("TimeTravel"), new object[0]); InputManager.AddToKeyboardMap(Keys.X, timeTravel); InputManager.AddToButtonsMap(Buttons.X, timeTravel); }
public override bool Update(GameAction action, object p1, object p2) { if ((int)p1 == 1) { killcount += (int)p2; return killcount <= maxkill; } return false; }
public override bool validate( GameAction gameAction ) { PieceMove moveAction = (PieceMove)gameAction; SquareState destinationState = Game.board [(int)moveAction.squareIndex.y, (int)moveAction.squareIndex.x].state; // Verify that the selected square is a valid destination for the selected piece return destinationState == SquareState.VALID || destinationState == SquareState.VALID_TRACED; }
public override void performAction( GameAction gameAction ) { if( currentPlayer.Equals(player2) ) // currentPlayer == player2 turn gameAction.execute (); else if (gameAction.validate ()) { BManager.sendGameMessage(gameAction.getMessage()); gameAction.execute (); } else audio.playError (); }
public ProcessResult Process(GameAction action) { var actionResult = ProcessAction(action); var mapPicture = GetMapPicture(Dungeon); painter.DrawMap(mapPicture); painter.DrawMessage(Message); return actionResult; }
public PickAction(GameAction[] p_actions, int[] p_chances, int[] p_delays) { this.actions = new GameAction[p_actions.Length]; this.chances = new int[p_chances.Length]; this.delays = new int[p_chances.Length]; for (int i = 0; i < p_actions.Length; i++) { this.actions[i] = p_actions[i]; this.chances[i] = p_chances[i]; this.delays[i] = p_delays[i]; } }
GamePosition IGameRunner.Step(GamePosition currentPosition, GameAction gameAction) { Contract.Requires<ArgumentNullException>(currentPosition != null); Contract.Requires<ArgumentNullException>(gameAction != null); Contract.Ensures(Contract.Result<GamePosition>() != null); Contract.Ensures(Contract.Result<GamePosition>().FirstTeamPosition != null); Contract.Ensures(Contract.Result<GamePosition>().FirstTeamPosition.Count() == currentPosition.FirstTeamPosition.Count()); Contract.Ensures(Contract.Result<GamePosition>().SecondTeamPosition != null); Contract.Ensures(Contract.Result<GamePosition>().SecondTeamPosition.Count() == currentPosition.SecondTeamPosition.Count()); throw new InvalidOperationException(); }
/* The keeper will shoot to the unmarked player who is the closest to the enemy's goal. */ public override PlayerAction ActionWithBall(Player player, GameAction gameAction) { if (RoundsWithBall < 5) { RoundsWithBall++; return null; } else { /* Sets the middle point of the enemy's goal as the target point*/ Point targetPoint = GameAI.GetEnemyTeam(GameAI.PlayersTeam(player)).TeamGoal.MiddlePoint; /* Searches the nearest unmarked player to the target point */ Player unmarkedPlayer = SearchPassPlayers(player).ElementAt(0); return new PlayerAction(unmarkedPlayer, unmarkedPlayer.Location, ActionType.Pass); } }
public GameDataAction(string actionString) { Data = new Dictionary<string, GameData>(); var start = actionString.IndexOf(':'); var enumString = actionString.Substring(0, start); Action = (GameAction) Enum.Parse(typeof (GameAction), enumString); var i = start; while (++i < actionString.Length) { if (actionString[i] != '[') continue; i++; var param = GetString(actionString, ref i); if (actionString[i] != ':') throw new FormatException($"Was expecting ':' @ {i}, found '{actionString[i]}' instead."); i++; if (actionString[i] == '\'') { Data.Add(param, GetString(actionString, ref i)); } else if (char.IsDigit(actionString[i]) || actionString[i] == '-' || actionString[i] == '.') { var numStart = i; while (actionString[++i] != ']') ; var sub = actionString.Substring(numStart, i - numStart); if (sub.EndsWith("f")) { Data.Add(param, float.Parse(sub.Substring(0, sub.Length - 1), NumberStyles.Float | NumberStyles.AllowThousands)); } else if (sub.Contains(".")) { Data.Add(param, double.Parse(sub, NumberStyles.Float | NumberStyles.AllowThousands)); } else { Data.Add(param, int.Parse(sub, NumberStyles.Integer)); } } } }
public void NotifyCardUse(Player source, List<Player> dests, List<Player> secondary, ICard card, GameAction action) { List<Player> logTargets = ActualTargets(source, dests, card); ActionLog log = new ActionLog(); log.Source = source; log.Targets = logTargets; log.SecondaryTargets = secondary; log.SkillAction = null; log.GameAction = action; log.CardAction = card; Game.CurrentGame.NotificationProxy.NotifySkillUse(log); if (card is Card) { Card terminalCard = card as Card; if (terminalCard.Log == null) { terminalCard.Log = new ActionLog(); } terminalCard.Log.Source = source; terminalCard.Log.Targets = dests; terminalCard.Log.SecondaryTargets = secondary; terminalCard.Log.CardAction = card; terminalCard.Log.GameAction = action; } else if (card is CompositeCard) { foreach (var s in (card as CompositeCard).Subcards) { if (s.Log == null) { s.Log = new ActionLog(); } s.Log.Source = source; s.Log.Targets = dests; s.Log.SecondaryTargets = secondary; s.Log.CardAction = card; s.Log.GameAction = action; } } }
private static JObject SerializeAction(GameAction action, TimeSpan time) { if (action is SetStoneAction) { var action2 = (SetStoneAction)action; Position pos = action2.Positions.GetPositions(null).Single(); return new JObject( new JProperty("a", "S"), new JProperty("x", pos.X), new JProperty("y", pos.Y), new JProperty("v", action2.Color.ShortName()), new JProperty("t", time.TotalSeconds) ); } else if (action is CreateBoardAction) { var action2 = (CreateBoardAction)action; return new JObject( new JProperty("a", "Board"), new JProperty("x", action2.Width), new JProperty("y", action2.Height), new JProperty("t", time.TotalSeconds) ); } else if (action is LabelAction) { var action2 = (LabelAction)action; Position pos = action2.Positions.GetPositions(null).Single(); return new JObject( new JProperty("a", "L"), new JProperty("x", pos.X), new JProperty("y", pos.Y), new JProperty("v", action2.Text), new JProperty("t", time.TotalSeconds) ); } else throw new NotSupportedException(); }
private void ProcessAction(GameAction gameAction) { _agent.EnqueueAction(gameAction); }
public abstract void Do(GameAction source);
public Result ShouldOverrideAuth(GameAction action) { return(WorldObjectUtil.ShouldOverrideAuth(this, action)); }
/// <summary> /// Advance the game one frame. /// </summary> public UpdateResult Update(TicCmd[] cmds) { // Do player reborns if needed. var players = this.options.Players; for (var i = 0; i < Player.MaxPlayerCount; i++) { if (players[i].InGame && players[i].PlayerState == PlayerState.Reborn) { this.DoReborn(i); } } // Do things to change the game state. while (this.gameAction != GameAction.Nothing) { switch (this.gameAction) { case GameAction.LoadLevel: this.DoLoadLevel(); break; case GameAction.NewGame: this.DoNewGame(); break; case GameAction.LoadGame: this.DoLoadGame(); break; case GameAction.SaveGame: this.DoSaveGame(); break; case GameAction.Completed: this.DoCompleted(); break; case GameAction.Victory: this.DoFinale(); break; case GameAction.WorldDone: this.DoWorldDone(); break; case GameAction.Nothing: break; } } for (var i = 0; i < Player.MaxPlayerCount; i++) { if (players[i].InGame) { var cmd = players[i].Cmd; cmd.CopyFrom(cmds[i]); // Check for turbo cheats. if (cmd.ForwardMove > GameConst.TurboThreshold && (this.world.LevelTime & 31) == 0 && ((this.world.LevelTime >> 5) & 3) == i) { var player = players[this.options.ConsolePlayer]; player.SendMessage(players[i].Name + " is turbo!"); } } } // Check for special buttons. for (var i = 0; i < Player.MaxPlayerCount; i++) { if (players[i].InGame) { if ((players[i].Cmd.Buttons & TicCmdButtons.Special) != 0) { if ((players[i].Cmd.Buttons & TicCmdButtons.SpecialMask) == TicCmdButtons.Pause) { this.paused = !this.paused; if (this.paused) { this.options.Sound.Pause(); } else { this.options.Sound.Resume(); } } } } } // Do main actions. var result = UpdateResult.None; switch (this.gameState) { case GameState.Level: if (!this.paused || this.world.FirstTicIsNotYetDone) { result = this.world.Update(); if (result == UpdateResult.Completed) { this.gameAction = GameAction.Completed; } } break; case GameState.Intermission: result = this.intermission.Update(); if (result == UpdateResult.Completed) { this.gameAction = GameAction.WorldDone; if (this.world.SecretExit) { players[this.options.ConsolePlayer].DidSecret = true; } if (DoomApplication.Instance.IWad == "doom2" || DoomApplication.Instance.IWad == "freedoom2" || DoomApplication.Instance.IWad == "plutonia" || DoomApplication.Instance.IWad == "tnt") { switch (this.options.Map) { case 6: case 11: case 20: case 30: this.DoFinale(); result = UpdateResult.NeedWipe; break; case 15: case 31: if (this.world.SecretExit) { this.DoFinale(); result = UpdateResult.NeedWipe; } break; } } } break; case GameState.Finale: result = this.finale.Update(); if (result == UpdateResult.Completed) { this.gameAction = GameAction.WorldDone; } break; } this.gameTic++; if (result == UpdateResult.NeedWipe) { return(UpdateResult.NeedWipe); } else { return(UpdateResult.None); } }
private void DoCompleted() { this.gameAction = GameAction.Nothing; for (var i = 0; i < Player.MaxPlayerCount; i++) { if (this.options.Players[i].InGame) { // Take away cards and stuff. this.options.Players[i].FinishLevel(); } } if (DoomApplication.Instance.IWad != "doom2" && DoomApplication.Instance.IWad != "freedoom2" && DoomApplication.Instance.IWad != "plutonia" && DoomApplication.Instance.IWad != "tnt") { switch (this.options.Map) { case 8: this.gameAction = GameAction.Victory; return; case 9: for (var i = 0; i < Player.MaxPlayerCount; i++) { this.options.Players[i].DidSecret = true; } break; } } if ((this.options.Map == 8) && (DoomApplication.Instance.IWad != "doom2" && DoomApplication.Instance.IWad != "freedoom2" && DoomApplication.Instance.IWad != "plutonia" && DoomApplication.Instance.IWad != "tnt")) { // Victory. this.gameAction = GameAction.Victory; return; } if ((this.options.Map == 9) && (DoomApplication.Instance.IWad != "doom2" && DoomApplication.Instance.IWad != "freedoom2" && DoomApplication.Instance.IWad != "plutonia" && DoomApplication.Instance.IWad != "tnt")) { // Exit secret level. for (var i = 0; i < Player.MaxPlayerCount; i++) { this.options.Players[i].DidSecret = true; } } var imInfo = this.options.IntermissionInfo; imInfo.DidSecret = this.options.Players[this.options.ConsolePlayer].DidSecret; imInfo.Episode = this.options.Episode - 1; imInfo.LastLevel = this.options.Map - 1; // IntermissionInfo.Next is 0 biased, unlike GameOptions.Map. if (DoomApplication.Instance.IWad == "doom2" || DoomApplication.Instance.IWad == "freedoom2" || DoomApplication.Instance.IWad == "plutonia" || DoomApplication.Instance.IWad == "tnt") { if (this.world.SecretExit) { switch (this.options.Map) { case 15: imInfo.NextLevel = 30; break; case 31: imInfo.NextLevel = 31; break; } } else { switch (this.options.Map) { case 31: case 32: imInfo.NextLevel = 15; break; default: imInfo.NextLevel = this.options.Map; break; } } } else { if (this.world.SecretExit) { // Go to secret level. imInfo.NextLevel = 8; } else if (this.options.Map == 9) { // Returning from secret level. switch (this.options.Episode) { case 1: imInfo.NextLevel = 3; break; case 2: imInfo.NextLevel = 5; break; case 3: imInfo.NextLevel = 6; break; case 4: imInfo.NextLevel = 2; break; } } else { // Go to next level. imInfo.NextLevel = this.options.Map; } } imInfo.MaxKillCount = this.world.TotalKills; imInfo.MaxItemCount = this.world.TotalItems; imInfo.MaxSecretCount = this.world.TotalSecrets; imInfo.TotalFrags = 0; if (DoomApplication.Instance.IWad == "doom2" || DoomApplication.Instance.IWad == "freedoom2" || DoomApplication.Instance.IWad == "plutonia" || DoomApplication.Instance.IWad == "tnt") { imInfo.ParTime = 35 * DoomInfo.ParTimes.Doom2[this.options.Map - 1]; } else { imInfo.ParTime = 35 * DoomInfo.ParTimes.Doom1[this.options.Episode - 1][this.options.Map - 1]; } var players = this.options.Players; for (var i = 0; i < Player.MaxPlayerCount; i++) { imInfo.Players[i].InGame = players[i].InGame; imInfo.Players[i].KillCount = players[i].KillCount; imInfo.Players[i].ItemCount = players[i].ItemCount; imInfo.Players[i].SecretCount = players[i].SecretCount; imInfo.Players[i].Time = this.world.LevelTime; Array.Copy(players[i].Frags, imInfo.Players[i].Frags, Player.MaxPlayerCount); } this.gameState = GameState.Intermission; this.intermission = new Intermission(this.options, imInfo); }
public override void Execute(BattleObject actor, GameAction action) { base.Execute(actor, action); actor.SendMessage("UnRotate"); }
public override void Execute(BattleObject obj, GameAction action) { obj.BroadcastMessage("DoAction", arg_dict["actionName"].GetData(obj, action)); }
public void LogAction(GameAction action) { var actionBytes = BitConverter.GetBytes((int) action); _logFile.Write(actionBytes, 0, actionBytes.Length); }
private void bCancel_Click(object sender, EventArgs e) { SelectedAction = AvailableActions.Where(x => { return(x.ID == -2); }).First(); }
public void BuyWorker() { this.client.Send(GameAction.CreateBuyWorkerAction(this.player)); }
public void Upgrade() { this.client.Send(GameAction.CreateUpgradeAction(this.player)); }
public GenericDebugAssignment(IJobObserver parent, GameAction action) : base(parent) { m_action = action; }
internal GameMetadata GetGameMetadata(GameID gameId) { var appId = gameId.AppID; var downloadedMetadata = DownloadGameMetadata(appId, library.LibrarySettings.BackgroundSource); var gameInfo = new GameInfo { Name = downloadedMetadata.ProductDetails?["common"]["name"]?.Value ?? downloadedMetadata.GameInfo.Name, Links = new List <Link>() { new Link("Community Hub", $"https://steamcommunity.com/app/{appId}"), new Link("Discussions", $"https://steamcommunity.com/app/{appId}/discussions/"), new Link("News", $"https://store.steampowered.com/news/?appids={appId}"), new Link("Store Page", $"https://store.steampowered.com/app/{appId}"), new Link("PCGamingWiki", $"https://pcgamingwiki.com/api/appid.php?appid={appId}") } }; downloadedMetadata.GameInfo = gameInfo; var metadata = new GameMetadata() { GameInfo = gameInfo, Icon = downloadedMetadata.Icon, CoverImage = downloadedMetadata.CoverImage, BackgroundImage = downloadedMetadata.BackgroundImage }; if (downloadedMetadata.StoreDetails?.categories?.FirstOrDefault(a => a.id == 22) != null) { gameInfo.Links.Add(new Link("Achievements", Steam.GetAchievementsUrl(appId))); } if (downloadedMetadata.StoreDetails?.categories?.FirstOrDefault(a => a.id == 30) != null) { gameInfo.Links.Add(new Link("Workshop", Steam.GetWorkshopUrl(appId))); } if (downloadedMetadata.StoreDetails != null) { gameInfo.Description = ParseDescription(downloadedMetadata.StoreDetails.detailed_description); var cultInfo = new CultureInfo("en-US", false).TextInfo; gameInfo.ReleaseDate = downloadedMetadata.StoreDetails.release_date.date; gameInfo.CriticScore = downloadedMetadata.StoreDetails.metacritic?.score; if (downloadedMetadata.StoreDetails.publishers.HasNonEmptyItems()) { gameInfo.Publishers = new List <string>(downloadedMetadata.StoreDetails.publishers); } if (downloadedMetadata.StoreDetails.developers.HasNonEmptyItems()) { gameInfo.Developers = new List <string>(downloadedMetadata.StoreDetails.developers); } if (downloadedMetadata.StoreDetails.categories.HasItems()) { gameInfo.Tags = new List <string>(downloadedMetadata.StoreDetails.categories.Select(a => cultInfo.ToTitleCase(a.description))); } if (downloadedMetadata.StoreDetails.genres.HasItems()) { gameInfo.Genres = new List <string>(downloadedMetadata.StoreDetails.genres.Select(a => a.description)); } } if (downloadedMetadata.ProductDetails != null) { var tasks = new List <GameAction>(); var launchList = downloadedMetadata.ProductDetails["config"]["launch"].Children; foreach (var task in launchList.Skip(1)) { var properties = task["config"]; if (properties.Name != null) { if (properties["oslist"].Name != null) { if (properties["oslist"].Value != "windows") { continue; } } } // Ignore action without name - shoudn't be visible to end user if (task["description"].Name != null) { var newTask = new GameAction() { Name = task["description"].Value, Arguments = task["arguments"].Value ?? string.Empty, Path = task["executable"].Value, IsHandledByPlugin = false, WorkingDir = ExpandableVariables.InstallationDirectory }; tasks.Add(newTask); } } var manual = downloadedMetadata.ProductDetails["extended"]["gamemanualurl"]; if (manual.Name != null) { tasks.Add((new GameAction() { Name = "Manual", Type = GameActionType.URL, Path = manual.Value, IsHandledByPlugin = false })); } gameInfo.OtherActions = tasks; } return(downloadedMetadata); }
public void ActionPerformed(GameAction action) { WorldObjectUtil.ActionPerformed(this, action); }
void OnActionExecutionStarted(GameAction gameAction) { this.ClearHighlightedTiles(); this.Player.ActionMenu.IsVisible = false; }
private async Task NotifyClientsForGameAction(GameAction gameAction) { await _hubContext.Clients.All.SendAsync("ActionSubmitted", gameAction); }
public override void Execute(BattleObject actor, GameAction action) { base.Execute(actor, action); //TODO }
public IEnumerator <YieldInstruction> ProcessInput(GameAction action) { GroundChar character = FocusedCharacter; switch (action.Type) { case GameAction.ActionType.Dir: { //result.Success = ActionResult.ResultType.Success; break; } case GameAction.ActionType.Move: { character.CurrentCommand = action; break; } case GameAction.ActionType.Drop: { yield return(CoroutineManager.Instance.StartCoroutine(ProcessTrashItem(character, action[0], action[1] != 0))); break; } case GameAction.ActionType.Give: { //[0] = item slot to use (-1 for the ground item) //[1] = who to give it to (-1 for the user) yield return(CoroutineManager.Instance.StartCoroutine(ProcessGiveItem(character, action[0], action[1]))); break; } case GameAction.ActionType.Take: { //[0] = team slot to take from yield return(CoroutineManager.Instance.StartCoroutine(ProcessTakeItem(character, action[0]))); break; } case GameAction.ActionType.Attack: { character.CurrentCommand = action; yield return(CoroutineManager.Instance.StartCoroutine(ProcessObjectInteract(character))); break; } case GameAction.ActionType.ShiftTeam: { int charIndex = action[0]; Character targetChar = DataManager.Instance.Save.ActiveTeam.Players[charIndex]; DataManager.Instance.Save.ActiveTeam.Players.RemoveAt(charIndex); DataManager.Instance.Save.ActiveTeam.Players.Insert(charIndex + 1, targetChar); //update the leader indices if (DataManager.Instance.Save.ActiveTeam.LeaderIndex == charIndex) { DataManager.Instance.Save.ActiveTeam.LeaderIndex++; } else if (DataManager.Instance.Save.ActiveTeam.LeaderIndex == charIndex + 1) { DataManager.Instance.Save.ActiveTeam.LeaderIndex--; } break; } case GameAction.ActionType.SetLeader: { yield return(CoroutineManager.Instance.StartCoroutine(MakeLeader(action[0], action[1] != 0))); break; } case GameAction.ActionType.SendHome: { yield return(CoroutineManager.Instance.StartCoroutine(SendHome(action[0]))); break; } case GameAction.ActionType.GiveUp: { GameManager.Instance.SceneOutcome = GameManager.Instance.EndSegment((GameProgress.ResultType)action[0]); break; } case GameAction.ActionType.Tactics: { //saves all the settings to the characters for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.Players.Count; ii++) { int choice = action[ii]; Character target = DataManager.Instance.Save.ActiveTeam.Players[ii]; AITactic tactic = DataManager.Instance.GetAITactic(choice); if (tactic.ID != target.Tactic.ID) { target.Tactic = new AITactic(tactic); } } break; } case GameAction.ActionType.SetSkill: { Skill skill = DataManager.Instance.Save.ActiveTeam.Players[action[0]].Skills[action[1]].Element; skill.Enabled = !skill.Enabled; break; } case GameAction.ActionType.ShiftSkill: { int slot = action[1]; Character targetChar = DataManager.Instance.Save.ActiveTeam.Players[action[0]]; BackReference <Skill> upState = targetChar.Skills[slot]; BackReference <Skill> downState = targetChar.Skills[slot + 1]; targetChar.Skills[slot] = downState; targetChar.Skills[slot + 1] = upState; if (upState.BackRef > -1 && downState.BackRef > -1) { SlotSkill skill = targetChar.BaseSkills[slot]; targetChar.BaseSkills.RemoveAt(slot); targetChar.BaseSkills.Insert(slot + 1, skill); } break; } case GameAction.ActionType.SortItems: { DataManager.Instance.Save.ActiveTeam.SortItems(); break; } default: { throw new Exception("Undefined Command: " + action.Type); } } }
public IEnumerator <YieldInstruction> MoveCommand(GameAction action, int switchSlot) { yield return(CoroutineManager.Instance.StartCoroutine((GameManager.Instance.CurrentScene == DungeonScene.Instance) ? DungeonScene.Instance.ProcessPlayerInput(action) : GroundScene.Instance.ProcessInput(action))); MenuManager.Instance.ReplaceMenu(new TeamMenu(false, switchSlot)); }
public void StartAction(GameAction action, ActionPriority priority) { StartAction(action, priority, 0); }
private void HttpRequest(GameAction gameAction, ActionParam actionParam, IHeadFormater formater, bool bShowLoading) { StartCoroutine(HttpGetRequest(gameAction, actionParam, formater, bShowLoading)); NetWriter.resetData(); }
private void DoNewGame() { this.gameAction = GameAction.Nothing; this.InitNew(this.options.Skill, this.options.Episode, this.options.Map); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // get the player's current action based on a keyboard event playerGameAction = GetKeyboardEvents(); switch (playerGameAction) { case GameAction.None: break; // move player right case GameAction.PlayerRight: player.PlayerDirection = Player.Direction.Right; // only move player if allowed if (CanMove()) { player.Position = new Vector2(player.Position.X + player.SpeedHorizontal, player.Position.Y); } break; //move player left case GameAction.PlayerLeft: player.PlayerDirection = Player.Direction.Left; // only move player if allowed if (CanMove()) { player.Position = new Vector2(player.Position.X - player.SpeedHorizontal, player.Position.Y); } break; // move player up case GameAction.PlayerUp: player.PlayerDirection = Player.Direction.Up; // only move player if allowed if (CanMove()) { player.Position = new Vector2(player.Position.X, player.Position.Y - player.SpeedVertical); } break; case GameAction.PlayerDown: player.PlayerDirection = Player.Direction.Down; // only move player if allowed if (CanMove()) { player.Position = new Vector2(player.Position.X, player.Position.Y + player.SpeedVertical); } break; // quit game case GameAction.Quit: Exit(); break; default: break; } base.Update(gameTime); }
//////////////////////////////////////////////////////////// // Public methods to control the game state //////////////////////////////////////////////////////////// /// <summary> /// Start a new game. /// Can be called by the startup code or the menu task. /// </summary> public void DeferedInitNew() { this.gameAction = GameAction.NewGame; }
public void SetupActions(List <GameAction> actions) { //Setup SelectedAction = null; AvailableActions = actions; bOK.Enabled = false; bCancel.Enabled = false; grpPlayer1.ContextMenu = null; grpPlayer2.ContextMenu = null; ContextMap.Clear(); foreach (GameAction ga in AvailableActions) { if (ga.AssociatedGameObjectID == -1) { bOK.Enabled = true; continue; } if (ga.AssociatedGameObjectID == -2) { bCancel.Enabled = true; continue; } ViewObject vo = ViewMap[ga.AssociatedGameObjectID]; if (vo is CardView) { ContextMenuStrip cont; if (ContextMap.ContainsKey(vo.ID)) { cont = ContextMap[vo.ID]; } else { cont = new ContextMenuStrip(); } ToolStripMenuItem tsmi = new ToolStripMenuItem(ga.Description); tsmi.Click += (o, e) => { SelectedAction = ga; }; cont.Items.Add(tsmi); ContextMap.Add(vo.ID, cont); } else if (vo is PlayerView) { ContextMenuStrip cont; if (ContextMap.ContainsKey(vo.ID)) { cont = ContextMap[vo.ID]; } else { cont = new ContextMenuStrip(); } ToolStripMenuItem tsmi = new ToolStripMenuItem(ga.Description); tsmi.Click += (o, e) => { SelectedAction = ga; }; cont.Items.Add(tsmi); if (vo.ID == MainPlayer) { grpPlayer1.ContextMenuStrip = cont; } else { grpPlayer2.ContextMenuStrip = cont; } ContextMap.Add(vo.ID, cont); } else if (vo is ManaPointView) { ContextMenuStrip cont; if (ContextMap.ContainsKey(vo.ID)) { cont = ContextMap[vo.ID]; } else { cont = new ContextMenuStrip(); } ToolStripMenuItem tsmi = new ToolStripMenuItem(ga.Description); tsmi.Click += (o, e) => { SelectedAction = ga; }; cont.Items.Add(tsmi); if (!ContextMap.ContainsKey(vo.ID)) { ContextMap.Add(vo.ID, cont); } } else if (vo is CounterView) { ContextMenuStrip cont; if (ContextMap.ContainsKey(vo.ID)) { cont = ContextMap[vo.ID]; } else { cont = new ContextMenuStrip(); } ToolStripMenuItem tsmi = new ToolStripMenuItem(ga.Description); tsmi.Click += (o, e) => { SelectedAction = ga; }; cont.Items.Add(tsmi); ContextMap.Add(vo.ID, cont); } } }
public void Reaction(GameState state, GameAction reaction) { }
public void SetData(GameAction action) { }
public void StartAction(GameAction action, ActionPriority priority, int userID) { D("DoAction: {0}, uid: {1}", action, userID); Debug.Assert(!this.HasAction); Debug.Assert(priority != ActionPriority.Undefined); Debug.Assert(action.MagicNumber != 0); this.CurrentAction = action; this.ActionPriority = priority; this.ActionTotalTicks = 0; this.ActionTicksUsed = 0; this.ActionUserID = userID; var e = new ActionStartEvent() { Action = action, Priority = priority, UserID = userID, }; if (m_ai != null) m_ai.ActionStarted(e); var c = new ActionStartedChange(this) { ActionStartEvent = e, }; this.World.AddChange(c); }
private IEnumerator AddThisAsAssociatedCardSource(GameAction ga) { ga.CardSource.AddAssociatedCardSource(GetCardSource()); yield return(null); }
public static Paragraph RichTranslateCardMove(List<Card> cards, DeckPlace source, DeckPlace dest, GameAction reason) { string sourceStr = Translate(source.Player); string destStr = Translate(dest.Player); var cardsInline = RichTranslate(cards); Paragraph paragraph = new Paragraph(); if (source.Player != null) { if (reason == GameAction.Discard) { paragraph.Inlines.Add(string.Format("{0}弃置了", sourceStr)); paragraph.Inlines.AddRange(cardsInline); } else if (reason == GameAction.PlaceIntoDiscard) { paragraph.Inlines.Add(string.Format("{0}将", sourceStr)); paragraph.Inlines.AddRange(cardsInline); paragraph.Inlines.Add("置入了弃牌堆"); } } if (dest.Player != null) { bool added = true; if (source.DeckType == DeckType.Dealing && dest.DeckType == DeckType.Hand) { paragraph.Inlines.Add(string.Format("{0}从牌堆里摸了", destStr)); } else if (source.DeckType == DeckType.Discard) { paragraph.Inlines.Add(string.Format("{0}从弃牌堆里回收了", destStr)); } else if (source.Player == dest.Player) { if (dest.DeckType == DeckType.Equipment) { paragraph.Inlines.Add(string.Format("{0}装备了", destStr)); } else if (source.DeckType == DeckType.Hand && dest.DeckType == DeckType.Hand) { paragraph.Inlines.Add(string.Format("{0}获得了自己的", destStr)); } else if (dest.DeckType is PrivateDeckType) { paragraph.Inlines.Add(string.Format("{0}将", destStr)); paragraph.Inlines.AddRange(cardsInline); paragraph.Inlines.Add(string.Format("置于武将牌上")); added = false; } else if (dest.DeckType == DeckType.Hand) { paragraph.Inlines.Add(string.Format("{0}获得了", destStr)); } else added = false; } else if (dest.DeckType == DeckType.Hand || dest.DeckType == DeckType.Equipment) { var owners = (from card in cards select card.Owner).Distinct(); if (owners.Contains(null)) { Trace.TraceWarning("Cannot resolve log: reason is {0}, from {1}{2} to {3}{4}", reason, Translate(source.Player), source.DeckType, Translate(dest.Player), dest.DeckType); paragraph.Inlines.Add(string.Format("{0}获得了", destStr)); } else { List<Player> players = new List<Player>(owners); paragraph.Inlines.Add(string.Format("{0}获得了{1}的", destStr, Translate(players))); if (dest.DeckType == DeckType.Equipment) { paragraph.Inlines.AddRange(cardsInline); paragraph.Inlines.Add(string.Format("并装备上")); added = false; } } } else { added = false; } if (added) { paragraph.Inlines.AddRange(cardsInline); } } return paragraph; }
public override void Reaction(GameAction reaction, PlayerType playerToMove) { Add(this.Previous, reaction, playerToMove); base.Reaction(reaction, playerToMove); }
/// <summary> /// get keyboard events /// </summary> /// <returns>GameAction</returns> private GameAction GetKeyboardEvents() { GameAction playerGameAction = GameAction.None; newState = Keyboard.GetState(); if (CheckKey(Keys.Right) == true) { playerGameAction = GameAction.PlayerRight; } else if (CheckKey(Keys.Left) == true) { playerGameAction = GameAction.PlayerLeft; } else if (CheckKey(Keys.Up) == true) { playerGameAction = GameAction.PlayerUp; } else if (CheckKey(Keys.Down) == true) { playerGameAction = GameAction.PlayerDown; } else if (CheckKey(Keys.Escape) == true) { playerGameAction = GameAction.Quit; } oldState = newState; return playerGameAction; }
private void Add(GameState state, GameAction action, PlayerType playerToMove) { this.States.Add(FlattenState.Create(state, action, playerToMove)); }
public void Nuke() { this.client.Send(GameAction.CreateNukeAction(this.player)); }
private IEnumerator DjinnDestroyInsteadReponse(GameAction action) { var storedResults = new List <DestroyCardAction>(); var cards = base.GameController.FindCardsWhere(c => _djinnOngoingCriteria.Criteria(c) && !this.GameController.IsCardIndestructible(c), visibleToCard: GetCardSource()); IEnumerator coroutine; if (!cards.Any()) { string message = $"There are no {_djinnOngoingCriteria.Description()} in play for {Card.Title} to destroy. {Card.Title} will be returned to {Card.Owner.Name}'s hand."; coroutine = base.GameController.SendMessageAction(message, Priority.Medium, cardSource: GetCardSource()); if (base.UseUnityCoroutines) { yield return(base.GameController.StartCoroutine(coroutine)); } else { base.GameController.ExhaustCoroutine(coroutine); } } else { coroutine = base.GameController.SelectAndDestroyCard(this.DecisionMaker, _djinnOngoingCriteria, false, storedResults, action.CardSource.Card, cardSource: GetCardSource()); if (base.UseUnityCoroutines) { yield return(base.GameController.StartCoroutine(coroutine)); } else { base.GameController.ExhaustCoroutine(coroutine); } } if (DidDestroyCard(storedResults)) { coroutine = base.GameController.SetHP(this.Card, this.Card.MaximumHitPoints.Value, cardSource: GetCardSource()); if (base.UseUnityCoroutines) { yield return(base.GameController.StartCoroutine(coroutine)); } else { base.GameController.ExhaustCoroutine(coroutine); } var card = GetDestroyedCards(storedResults).First(); string message = $"{card.Title} was destroyed, and {Card.Title} was restored to {Card.MaximumHitPoints}."; coroutine = base.GameController.SendMessageAction(message, Priority.Medium, cardSource: GetCardSource()); if (base.UseUnityCoroutines) { yield return(base.GameController.StartCoroutine(coroutine)); } else { base.GameController.ExhaustCoroutine(coroutine); } } else { coroutine = base.GameController.MoveCard(this.DecisionMaker, this.Card, this.HeroTurnTaker.Hand, cardSource: GetCardSource()); if (base.UseUnityCoroutines) { yield return(base.GameController.StartCoroutine(coroutine)); } else { base.GameController.ExhaustCoroutine(coroutine); } } }
public virtual void TagAndNotify(Player source, List<Player> dests, ICard card, GameAction action = GameAction.Use) { NotifyCardUse(source, dests, new List<Player>(), card, action); }
public void BuyUnit(int slot, UnitType type) { this.client.Send(GameAction.CreateBuyUnitAction(this.player, slot, type)); }