private void NotifyOfCollision(MappedObjectPotentialMove v) { hub.Launch <Message_GameCombat>(new Message_GameCombat(MainMessageKind.CombatMessage, KnownSubkinds.CollisionOccured)); hub.Launch <Message_Ui>(new Message_Ui(MainMessageKind.UIMessage, KnownSubkinds.CollisionOccured)); bd2TickAction act = new bd2TickAction(); act.ActionType = LastTickEventType.Collision; CreateNextTurnNotificationMessage(v.Underlying.EngineId, act); }
private void ApplyWeaponfireHit(MappedBot victim, CombatResult cr) { ApplyDamageToObject(victim.EngineId, cr.TotalDamage, DamageType.Projectile); bd2TickAction ta = new bd2TickAction(); ta.ActionType = LastTickEventType.Shot; CreateNextTurnNotificationMessage(victim.EngineId, ta); }
private void CreateNextTurnNotificationMessage(int p, bd2TickAction action) { LastTickRecord ltr; if (activeData.LastTickRecords.ContainsKey(p)) { ltr = activeData.LastTickRecords[p]; } else { ltr = new LastTickRecord(); activeData.LastTickRecords.Add(p, ltr); } ltr.Events.Push(action); }
private void PerformMovementForTick() { List <MappedObjectPotentialMove> potentialMoves = new List <MappedObjectPotentialMove>(); EachActiveBot(bt => { MappedObjectPotentialMove res; if (SpeedTriggersMoveForTick(Tick, bt.Speed)) { res = MoveMappableObject(bt); } else { res = new MappedObjectPotentialMove(bt); res.DesiredPosition = bt.Position; } potentialMoves.Add(res); }); List <string> collisionsAlreadyRecorded = new List <string>(); b.Verbose.Log("All potential moves are recorded, resolving collisions"); foreach (var v in potentialMoves) { if (v.HasBoundaryCollision) { ApplyCollision(v); } else { foreach (var p in potentialMoves) { if (v.Underlying.EngineId == p.Underlying.EngineId) { continue; } b.Assert.True(v.Underlying.Position != p.Underlying.Position, "Two objects sat on top of each other problem. [" + v.Underlying.Position.ToString() + "][" + v.Underlying.Position.ToString() + "]"); if ((v.DesiredPosition == p.DesiredPosition) || (v.Underlying.Position == p.DesiredPosition) || (v.DesiredPosition == p.Underlying.Position)) { string key = CreateKeyForCollision(v, p); if (!collisionsAlreadyRecorded.Contains(key)) { collisionsAlreadyRecorded.Add(key); ApplyCollision(v, p); } } } } } b.Verbose.Log("Move potentials done, finalising"); foreach (var move in potentialMoves) { if (move.Underlying.Position != move.DesiredPosition) { move.Underlying.Position = move.DesiredPosition; MapObjectPositionChangeContext ctxt = new MapObjectPositionChangeContext(); ctxt.ObjectIdentity = move.Underlying.EngineId; ctxt.Destination = move.DesiredPosition; bd2TickAction act = new bd2TickAction(); act.ActionType = LastTickEventType.Moved; CreateNextTurnNotificationMessage(move.Underlying.EngineId, act); hub.Launch <Message_Game>(new Message_Game(MainMessageKind.MapObjectMovementChange, KnownSubkinds.BotPositionChange) { RequestContext = ctxt }); } } }