public void onUpdate(BattlefieldState state, long version) { foreach (var handler in handlers) { handler.onUpdate(state, version); } }
public void accumulateUpdates(BattlefieldState prev, BattlefieldState next, int row, int column) { if (wasChanged(prev, next, row, column)) { _updates.Add(getUpdates(prev, next, row, column)); } }
public virtual void initItems(BattlefieldState state) { foreach (var tankName in state.tanks.Keys) { _itemManagerDelegate.createItem(tankName, state.tanks[tankName]); } }
/// <summary> /// This send invitation to player to join the queue. /// </summary> /// <param name="queueId">The queue id of Bf</param> /// <param name="battleState">Battlefield State</param> public void SendBfInvitePlayerToQueue(ulong queueId, BattlefieldState battleState) { BFMgrQueueInvite bfMgrQueueInvite = new BFMgrQueueInvite(); bfMgrQueueInvite.QueueID = queueId; bfMgrQueueInvite.BattleState = battleState; SendPacket(bfMgrQueueInvite); }
/// <summary> /// This is call when player leave battlefield zone. /// </summary> /// <param name="queueId">The queue id of Bf</param> /// <param name="queueId">The queue id of Bf</param> /// <param name="battleState">Battlefield status</param> /// <param name="relocated">Whether player is added to Bf on the spot or teleported from queue</param> /// <param name="reason">Reason why player left battlefield</param> public void SendBfLeaveMessage(ulong queueId, BattlefieldState battleState, bool relocated, BFLeaveReason reason = BFLeaveReason.Exited) { BFMgrEjected bfMgrEjected = new BFMgrEjected(); bfMgrEjected.QueueID = queueId; bfMgrEjected.Reason = reason; bfMgrEjected.BattleState = battleState; bfMgrEjected.Relocated = relocated; SendPacket(bfMgrEjected); }
/// <summary> /// This send packet for inform player that he join queue. /// </summary> /// <param name="queueId">The queue id of Bf</param> /// <param name="zoneId">The zone where the battle is (4197 for wg)</param> /// <param name="battleStatus">Battlefield status</param> /// <param name="canQueue">if able to queue</param> /// <param name="loggingIn">on log in send queue status</param> public void SendBfQueueInviteResponse(ulong queueId, uint zoneId, BattlefieldState battleStatus, bool canQueue = true, bool loggingIn = false) { BFMgrQueueRequestResponse bfMgrQueueRequestResponse = new BFMgrQueueRequestResponse(); bfMgrQueueRequestResponse.QueueID = queueId; bfMgrQueueRequestResponse.AreaID = (int)zoneId; bfMgrQueueRequestResponse.Result = (sbyte)(canQueue ? 1 : 0); bfMgrQueueRequestResponse.BattleState = battleStatus; bfMgrQueueRequestResponse.LoggingIn = loggingIn; SendPacket(bfMgrQueueRequestResponse); }
public virtual void initItem(BattlefieldState state, int row, int column) { if (canProcess(state.field[row][column])) { this._itemManagerDelegate.createItem(new MapItem { symbol = state.field[row][column], row = row, column = column }); } }
private void accumulateUpdatedTanks(BattlefieldState prev, BattlefieldState next) { foreach (var name in prev.tanks.Keys) { if (next.tanks.ContainsKey(name)) { _updates.Add(new TankMapItemDelta { name = name, prev = prev.tanks[name], next = next.tanks[name] }); } } }
private void handleUpdates(BattlefieldState prev, BattlefieldState next) { for (var i = 0; i < _fieldSize; i++) { for (var j = 0; j < _fieldSize; j++) { foreach (var handler in updatesHandlers) { handler.accumulateUpdates(prev, next, i, j); } } } }
public void accumulateUpdates(BattlefieldState prev, BattlefieldState next, int row, int column) { var fieldSize = prev.field.Length; var prevIsBullet = _symbols.IndexOf(prev.field[row][column]) >= 0; var nextIsBullet = _symbols.IndexOf(next.field[row][column]) >= 0; if (prevIsBullet) { var moveDelta = MapUtils.calculatePositionDelta(MapUtils.getBulletDirection(prev.field[row][column]), 2); int nextRow; int nextColumn; var isInsideField = MapUtils.getCoordinatesWithDelta(fieldSize, row, column, moveDelta, out nextRow, out nextColumn); addUpdate(new MapItem { symbol = prev.field[row][column], row = row, column = column }, new MapItem { symbol = isInsideField ? next.field[nextRow][nextColumn] : MapItems.OUTBOUNDS, row = nextRow, column = nextColumn } ); } else if (nextIsBullet) { var moveDelta = MapUtils.calculatePositionDelta(MapUtils.getBulletDirection(next.field[row][column]), -2); int prevRow; int prevColumn; var isInsideField = MapUtils.getCoordinatesWithDelta(fieldSize, row, column, moveDelta, out prevRow, out prevColumn); addUpdate(new MapItem { symbol = isInsideField ? prev.field[prevRow][prevColumn] : MapItems.OUTBOUNDS, row = prevRow, column = prevColumn }, new MapItem { symbol = next.field[row][column], row = row, column = column } ); } }
protected virtual MapItemDelta getUpdates(BattlefieldState prev, BattlefieldState next, int row, int column) { return(new MapItemDelta { prev = new MapItem { row = row, column = column, symbol = prev.field[row][column] }, next = new MapItem { row = row, column = column, symbol = next.field[row][column] } }); }
private void initBattlefield(BattlefieldState state) { var symbols = generateSymbols(MapItems.MAP_KEYS); foreach (var handler in updatesHandlers) { handler.setSymbols(symbols[handler.prefabName()]); } _tanksProcessor.setSymbols(symbols[_tanksProcessor.prefabName()]); for (var i = 0; i < state.field.Length; i++) { for (var j = 0; j < state.field[i].Length; j++) { foreach (var handler in updatesHandlers) { handler.initItem(state, i, j); } } } }
public void accumulateUpdates(BattlefieldState prev, BattlefieldState next, int row, int column) { this._accumulator.accumulateUpdates(prev, next, row, column); }
public void accumulateUpdates(BattlefieldState prev, BattlefieldState next) { accumulateNewTanks(prev, next); accumulateDestroyedTanks(prev, next); accumulateUpdatedTanks(prev, next); }
public void onUpdate(BattlefieldState state, long version) { _states.Add(state); }
protected virtual bool wasChanged(BattlefieldState prev, BattlefieldState next, int row, int column) { return((_symbols.IndexOf(prev.field[row][column]) >= 0 || _symbols.IndexOf(next.field[row][column]) >= 0) && prev.field[row][column] != next.field[row][column]); }
public void accumulateUpdates(BattlefieldState prev, BattlefieldState next) { this._accumulator.accumulateUpdates(prev, next); }