private void HandleSpawnBot(Guid botId, Coordinate position, BotInformation botInformation) { var cell = Cells.FirstOrDefault(c => c.X == position.X && c.Y == position.Y); cell.IsOnBot = true; cell.BotId = botId; cell.Health = botInformation.Health; cell.MaxHealth = botInformation.MaxHealth; cell.TeamColor = TeamColors[botInformation.Team]; }
private void HandleBotAction(Guid botId, BotAction action, BotInformation botInformation) { switch (action.Action) { case ActionType.Move: MoveBot(botId, action.Target, botInformation); break; case ActionType.Attack: AttackBot(botId, action.Target, botInformation); break; } }
private Task ReportStartupTime() { if (!_storage.HasObject("Info/BotInformation")) { var newBotInformation = new BotInformation(startupTime: System.DateTime.Now); _storage.StoreObject(newBotInformation, "Info/BotInformation"); return(Task.CompletedTask); } var botInformation = _storage.RestoreObject <BotInformation>("Info/BotInformation"); botInformation.TimeOfPreviousStartup = System.DateTime.Now; _storage.StoreObject(botInformation, "Info/BotInformation"); return(Task.CompletedTask); }
private void AttackBot(Guid botId, Coordinate target, BotInformation botInformation) { //var sourceCell = Cells.FirstOrDefault(b => b.BotId == botId); // trigger and reverse animation //sourceCell.IsAttacker = true; //sourceCell.IsAttacker = false; var targetCell = Cells.FirstOrDefault(c => c.X == target.X && c.Y == target.Y); targetCell.Health = botInformation.Health; targetCell.MaxHealth = botInformation.MaxHealth; // trigger and reverse animation //targetCell.IsAttacked = true; //sourceCell.IsAttacked = false; }
private void MoveBot(Guid botId, Coordinate to, BotInformation botInformation) { Log.Add(string.Format("Move to {0}:{1}", to.X, to.Y)); var source = Cells.FirstOrDefault(c => c.BotId == botId); source.IsOnBot = false; source.BotId = Guid.Empty; source.Health = 0; source.TeamColor = Constants.EmptyCellBrush; var target = Cells.FirstOrDefault(c => c.X == to.X && c.Y == to.Y); target.IsOnBot = true; target.BotId = botId; target.Health = botInformation.Health; target.MaxHealth = botInformation.MaxHealth; target.TeamColor = TeamColors[botInformation.Team]; }