From c384532c3ae81f2d6075cdd8b6ae856113996c02 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 20 Oct 2013 20:00:15 +0200 Subject: Fixed giving commands to dead tanks --- Entelect.BattleCity.Challenge/AiAgent.cs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'Entelect.BattleCity.Challenge/AiAgent.cs') diff --git a/Entelect.BattleCity.Challenge/AiAgent.cs b/Entelect.BattleCity.Challenge/AiAgent.cs index df9afb4..02ebd3b 100644 --- a/Entelect.BattleCity.Challenge/AiAgent.cs +++ b/Entelect.BattleCity.Challenge/AiAgent.cs @@ -17,11 +17,15 @@ namespace Entelect.BattleCity.Challenge ChallengeService.unit tank = null; bool bulletInAir = false; - foreach (var unit in me.units) + if (me != null && me.units != null) { - if (unit.id == _tankId) + foreach (var unit in me.units) { - tank = unit; + if (unit.id == _tankId) + { + Console.WriteLine("Tank found in list of tanks"); + tank = unit; + } } } @@ -31,6 +35,23 @@ namespace Entelect.BattleCity.Challenge return null; } + /*if (game.events != null && game.events.unitEvents != null) + { + foreach (var unitEvent in game.events.unitEvents) + { + if (unitEvent.unit != null && unitEvent.unit.id == _tankId && unitEvent.bullet != null) + { + Console.WriteLine("Tank was shot"); + return null; + } + } + Console.WriteLine("No relevant events in unit events list", _tankId); + } + else + { + Console.WriteLine("No events in unit events list", _tankId); + }*/ + if (me.bullets != null) { foreach (var bullet in me.bullets) -- cgit v1.2.3