public GameAction(byte[] bytes, Game game) { this.player = game.players.Find(player => player.id == bytes[0]); this.type = (GameActionType)bytes[1]; this.slot = bytes[2]; this.unitType = (UnitType)bytes[3]; }
//добавляет спец возможности игроку void AddItemsAction(GameActionType type, int count) { //добавляем отдельно для режима MP if (ModeGame == GameMode.MULTIPLAYER) { if (mp_gameSetting.actionItems.ContainsKey(type)) { mp_gameSetting.actionItems[type] += count; } else { mp_gameSetting.actionItems.Add(type, count); } } else //для остальных режимов (Classic, Levels) { if (CurrentGame.actionItems.ContainsKey(type)) { CurrentGame.actionItems[type] += count; } else { CurrentGame.actionItems.Add(type, count); } } AddActionItemEvent?.Invoke(); }
public QueuedGameAction(uint objectId, GameActionType actionType) { this.ObjectId = objectId; this.ActionType = actionType; this.StartTime = WorldManager.PortalYearTicks; this.EndTime = this.StartTime; }
/// <summary> /// The call path for this function is as follows: /// InboundMessageManager.HandleClientMessage() queues work into NetworkManager.InboundMessageQueue that is run in WorldManager.UpdateWorld() /// That work invokes GameActionPacket.HandleGameAction() which calls this. /// </summary> public static void HandleGameAction(GameActionType opcode, ClientMessage message, Session session) { if (actionHandlers.TryGetValue(opcode, out var actionHandlerInfo)) { // It's possible that before this work is executed by WorldManager, and after it was enqueued here, the session.Player was set to null // To avoid null reference exceptions, we make sure that the player is valid before the message handler is invoked. //if (session.Player == null) // return; try { switch (opcode) { case GameActionType.Talk: // Handle any commands we might wire up actionHandlerInfo.Handler.Invoke(message, session); break; default: // nothing break; } } catch (Exception ex) { log.Error($"Received GameAction packet that threw an exception from account: {session.AccountId}:{session.Account}, player: {session.Player?.Name}, opcode: 0x{((int)opcode):X4}:{opcode}"); log.Error(ex); } } else { log.Warn($"Received unhandled GameActionType: 0x{(int)opcode:X4} - {opcode}"); } }
public void BuyAutoClicker(GameActionType actionType, int level) { if (Points.GetValue() >= AutoClickerCosts[level]) { Points.Add(-AutoClickerCosts[level]); switch (actionType) { case GameActionType.Mine: MineAutoClickers[level]++; SpawnSprite(GameActionType.Mine, level, GenerateRandomPoint(MinerSpawnPoint)); break; case GameActionType.Process: ProcessAutoClickers[level]++; SpawnSprite(GameActionType.Process, level, GenerateRandomPoint(GeomancerSpawnPoint)); break; case GameActionType.Craft: CraftAutoClickers[level]++; SpawnSprite(GameActionType.Craft, level, GenerateRandomPoint(ArtificerSpawnPoint)); break; case GameActionType.Sell: SellAutoClickers[level]++; SpawnSprite(GameActionType.Sell, level, GenerateRandomPoint(SalesmanSpawnPoint)); break; } } }
public GameActionData(string playerId, GameActionType actionType, int origin, int target) { Id = ObjectId.GenerateNewId().ToString(); PlayerId = playerId; ActionType = actionType; PieceType = null; Target = target; Origin = origin; }
public GameActionData(string playerId, GameActionType actionType, PieceType pieceType) { Id = ObjectId.GenerateNewId().ToString(); PlayerId = playerId; ActionType = actionType; PieceType = pieceType; Target = null; Origin = null; }
public async Task <bool> DoAction(GameAction gameAction) { Room room = Server.GetRoomByUserId(Context.ConnectionId); if (room != null && room.IsStarted) { Player player = room.GetPlayer(Context.ConnectionId); if (player.IsTurn) { int actionsCount = (int)Context.Items["Actions"]; GameActionType prevAction = (GameActionType)Context.Items["PrevAction"]; if (actionsCount == 0 || (actionsCount == 1 && prevAction != gameAction.Type) || gameAction.Type == GameActionType.DropItem) { gameAction.CurrentPlayer = player; Func <bool> action = gameAction.Type switch { GameActionType.Move => () => Move(room, gameAction), GameActionType.Dig => () => Dig(room, gameAction), GameActionType.Attack => () => Attack(room, gameAction), GameActionType.UseItem => () => UseItem(room, gameAction), GameActionType.DropItem => () => DropItem(gameAction), GameActionType.UseAbility => () => UseAbility(room, gameAction), GameActionType.TakeTheFlag => () => TakeTheFlag(room, gameAction), _ => null }; if (action != null && action()) { if (gameAction.Type == GameActionType.Move || gameAction.Type == GameActionType.Dig) { Context.Items["IsDice"] = false; } if (gameAction.Type != GameActionType.DropItem) { Context.Items["Actions"] = actionsCount + 1; Context.Items["PrevAction"] = gameAction.Type; } if (player.WithFlag && player.Position.Equals(player.SpawnPoint)) { player.Score++; room.DropTheFlag(player); room.FlagPosition = room.GetGameMap().FlagSpawnPoint; if (room.CheckWinner(player)) { Server.RemoveRoom(room.Code); } } await Clients.Group(room.Code).ChangeStateWithAction(room, gameAction); return(true); } } } } return(false); }
void SpawnSprite(GameActionType actionType, int level, Vector3 position) { if (pools.ContainsKey(actionType) && sprites[pools[actionType]].Count < MAX_SPRITES) { tmpAnim = ObjectPools.Spawn <Animator>(pools[actionType], position, null); tmpAnim.speed = 1 + (level * 0.5f); tmpAnim.transform.localScale = new Vector3(2 * (Random.value > 0.5f ? 1 : -1), 2, 1); sprites[pools[actionType]].Add(tmpAnim); } }
//покупка Actions (Ice, Bomb) void PurchaseAction(GameActionType type) { var myMoney = GameManager.CurrentGame.MoneyCount; var costAct = GameManager.Config.costAction; if (myMoney >= costAct) { BuyGameActionEvent?.Invoke(type, 1, costAct); } }
public GameActionData(string playerId, GameActionType actionType, int origin, PieceType pieceType, bool?discarded) { Id = ObjectId.GenerateNewId().ToString(); PlayerId = playerId; ActionType = actionType; PieceType = pieceType; Target = null; Origin = origin; Discarded = discarded ?? false; }
//возвращает остаток GameAction по типу int GetCountAct(GameActionType type) { var items = GameManager.CurrentGame.actionItems; if (items.ContainsKey(type)) { return(items[type]); } return(0); }
//использование GameActions void ExecuteAction(GameActionType type) { if (ModeGame == GameMode.MULTIPLAYER) { mp_gameSetting.actionItems[type]--; } else { CurrentGame.actionItems[type]--; } RegisteringUseForce(type); }
//обновляет визуальное состояние действия на панеле UI void Action_UpdateUI(GameActionType type) { switch (type) { case GameActionType.ICE_FORCE: Action_1_ActivateEvent?.Invoke(gameActions[0].ItemCount); break; case GameActionType.TIME_BOMB: Action_2_ActivateEvent?.Invoke(gameActions[1].ItemCount); break; } }
//обрабатывает события от нажатия пользователем кнопок ACTIONS void GameActionReaction(GameActionType typeAction) { switch (typeAction) { case GameActionType.TIME_BOMB: StartCoroutine(TimeBombBlast()); break; case GameActionType.ICE_FORCE: StartCoroutine(IceForce()); break; } }
private Guid GenerateGameAction <TEvent>(GameActionType gameActionType, GameActionData gameActionData, GameActionContext context) where TEvent : GameActionEventBase, new() { if (gameActionData.ExternalTransactionId == null) { throw new ArgumentNullException("externalTransactionId"); } var gameActionId = Guid.NewGuid(); var amount = gameActionData.Amount; if (gameActionType == GameActionType.Placed) { amount = -amount; } Data.GameActions.Add(new GameAction { Id = gameActionId, ExternalTransactionId = gameActionData.ExternalTransactionId, ExternalBetId = gameActionData.ExternalBetId, ExternalTransactionReferenceId = gameActionData.TransactionReferenceId, Round = Data, GameActionType = gameActionType, Amount = amount, Description = gameActionData.Description, WalletTransactionId = gameActionData.WalletTransactionId, Timestamp = DateTimeOffset.UtcNow.ToBrandOffset(Data.Brand.TimezoneId), Context = context }); var relatedGameAction = GetGameActionByReferenceId(gameActionData.TransactionReferenceId); Events.Add(new TEvent { Amount = gameActionData.Amount, GameActionId = gameActionId, BrandId = Data.BrandId, GameId = Data.GameId, PlayerId = Data.PlayerId, RoundId = Data.Id, Turnover = context.TurnoverContribution, Ggr = context.GgrContribution, UnsettledBets = context.UnsettledBetsContribution, RelatedGameActionId = relatedGameAction == null? (Guid?)null : relatedGameAction.Id, CreatedOn = DateTimeOffset.UtcNow.ToBrandOffset(Data.Brand.TimezoneId) }); return(gameActionId); }
public static void HandleGameAction(GameActionType opcode, ClientMessage message, Session session) { if (actionHandlers.TryGetValue(opcode, out var actionHandlerInfo)) { session.InboundGameActionQueue.EnqueueAction(new ActionEventDelegate(() => { actionHandlerInfo.Handler.Invoke(message, session); })); } else { log.Warn($"Received unhandled GameActionType: 0x{opcode:X4}"); } }
public void Draw(GameActionType type, int seat) { // Check if we need to shuffle the discard pile if (deck.Empty) { deck = discard; deck.Shuffle(generator.Next()); discard = new Deck(); LogAction(new GameAction(GameActionType.ShuffleDiscard)); } players[seat].Draw(deck.Draw()); LogAction(new GameAction(type), seat, players[seat].ToString()); }
//задействует action по типу void ExecuteAction(GameActionType type) { foreach (var action in gameActions) { if (action.TypeAction == type) { //если действие можно задействовать if (action.ExecuteAction()) { ExecuteActionEvent?.Invoke(action.TypeAction); } } } }
private GameAction CreateGameAction(decimal amount, GameActionType gameActionType, string description, Guid walletTransactionId, string externalTransactionId, string externalBetId, string externalTransactionReferenceId, string batchId) { if (externalTransactionId == null) { throw new ArgumentNullException(nameof(externalTransactionId)); } if (gameActionType == GameActionType.Placed) { amount = -amount; } var relatedGameAction = Data.GameActions.SingleOrDefault(x => x.ExternalTransactionId == externalTransactionReferenceId); var relatedGameActionId = Guid.Empty; if (relatedGameAction != null) { relatedGameActionId = relatedGameAction.Id; } var gameAction = new GameAction { Id = Guid.NewGuid(), ExternalTransactionId = externalTransactionId, ExternalBetId = externalBetId, ExternalTransactionReferenceId = externalTransactionReferenceId, RelatedGameActionId = relatedGameActionId, Round = Data, GameActionType = gameActionType, Amount = amount, Description = description, WalletTransactionId = walletTransactionId, ExternalBatchId = batchId, Timestamp = DateTimeOffset.UtcNow.ToBrandOffset(Data.Brand.TimezoneId) }; Data.GameActions.Add(gameAction); return(gameAction); }
public static void HandleGameAction(GameActionType opcode, ClientMessage message, Session session) { if (!actionHandlers.ContainsKey(opcode)) { log.WarnFormat("Received unhandled GameActionType: 0x{0:X4}", ((uint)opcode)); } else { ActionHandlerInfo actionHandlerInfo; if (actionHandlers.TryGetValue(opcode, out actionHandlerInfo)) { actionHandlerInfo.Handler.Invoke(message, session); } } }
//делает подсчёт использования сил void RegisteringUseForce(GameActionType typeForce) { switch (typeForce) { case GameActionType.ICE_FORCE: //Ice CurrentGame.StatisticGame.NumUsedIcePower++; StatisticUpdateEvent?.Invoke(AchievementType.USING_ICE_FORCE); break; case GameActionType.TIME_BOMB: //Bomb CurrentGame.StatisticGame.NumUsedBombPower++; StatisticUpdateEvent?.Invoke(AchievementType.USING_BOMB_FORCE); break; } }
public static void HandleGameAction(GameActionType opcode, ClientMessage message, Session session) { if (!actionHandlers.ContainsKey(opcode)) { log.WarnFormat("Received unhandled GameActionType: 0x{0:X4}", ((uint)opcode)); } else { if (actionHandlers.TryGetValue(opcode, out var actionHandlerInfo)) { session.EnqueueAction(new ActionEventDelegate(() => { actionHandlerInfo.Handler.Invoke(message, session); })); } } }
void ProcessAutoClicker(GameActionType actionType, long[] clickerCounts, long[] clickerOutputs, long minimumOutput = 0) { long totalOutput = 0; for (long i = 0; i < clickerCounts.Length; i++) { totalOutput += (clickerOutputs[i] * clickerCounts[i]); } if (totalOutput < minimumOutput) { totalOutput = minimumOutput; } HandleAction(actionType, totalOutput, true); }
// TODO: This needs to be reworked. Activator.CreateInstance is not going to be performant. public static void HandleGameAction(GameActionType opcode, ClientPacketFragment fragment, Session session) { if (!actionHandlers.ContainsKey(opcode)) { Console.WriteLine($"Received unhandled action opcode: 0x{(uint)opcode:X4}"); } else { Type actionType; if (actionHandlers.TryGetValue(opcode, out actionType)) { var gameAction = (GameActionPacket)Activator.CreateInstance(actionType, session, fragment); gameAction.Read(); gameAction.Handle(); } } }
/// <summary> /// The call path for this function is as follows: /// InboundMessageManager.HandleClientMessage() queues work into WorldManager.InboundMessageQueue that is run in WorldManager.UpdateWorld() /// That work invokes GameActionPacket.HandleGameAction() which calls this. /// </summary> public static void HandleGameAction(GameActionType opcode, ClientMessage message, Session session) { if (actionHandlers.TryGetValue(opcode, out var actionHandlerInfo)) { // It's possible that before this work is executed by WorldManager, and after it was enqueued here, the session.Player was set to null // To avoid null reference exceptions, we make sure that the player is valid before the message handler is invoked. if (session.Player == null) { return; } actionHandlerInfo.Handler.Invoke(message, session); } else { log.Warn($"Received unhandled GameActionType: 0x{(int)opcode:X4} - {opcode}"); } }
void ProcessTick(GameActionType actionType, int minimumOutput = 0) { switch (actionType) { case GameActionType.Sell: ProcessAutoClicker(GameActionType.Sell, SellAutoClickers, SellAutoClickerOutput, minimumOutput); break; case GameActionType.Craft: ProcessAutoClicker(GameActionType.Craft, CraftAutoClickers, CraftAutoClickerOutput, minimumOutput); break; case GameActionType.Process: ProcessAutoClicker(GameActionType.Process, ProcessAutoClickers, ProcessAutoClickerOutput, minimumOutput); break; case GameActionType.Mine: ProcessAutoClicker(GameActionType.Mine, MineAutoClickers, MineAutoClickerOutput, minimumOutput); break; } }
public void HandleAction(GameActionType actionType, long amount, bool applyPenalty) { switch (actionType) { case GameActionType.Mine: MineItem(amount, applyPenalty); break; case GameActionType.Process: ProcessItem(amount, applyPenalty); break; case GameActionType.Craft: CraftItem(amount, applyPenalty); break; case GameActionType.Sell: SellItem(amount, applyPenalty); break; } }
public GameActionAttribute(GameActionType opcode) { Opcode = opcode; }
public GameAction(GameActionType type) { ActionType = type; }