public InfanteryMind Create(Infantery infantery) { var infanteryMind = InfanteryMinds.Get(infantery.Id); if (infanteryMind == null) { infanteryMind = new InfanteryMind(infantery, _aiEventProcessor); InfanteryMinds.Store(infantery.Id, infanteryMind); } return infanteryMind; }
public InfanteryMind(Infantery infantery, AiEventProcessor aiEventProcessor) { _aiEventProcessor = aiEventProcessor; Infantery = infantery; SpottedUnitsBag = new List<ComponentMetaProxy>(99999); aiEventProcessor.OnEnemyComponentSpotted += aiEventProcessor_OnEnemyComponentSpotted; aiEventProcessor.OnEnemyComponentLeftFieldOfVision += aiEventProcessor_OnEnemyComponentLeftFieldOfVision; aiEventProcessor.OnEnemyComponentNotInAttackRange += aiEventProcessor_OnEnemyComponentNotInAttackRange; aiEventProcessor.OnTargetPositonBlocked += aiEventProcessor_OnTargetPositonBlocked; aiEventProcessor.OnEnemyComponentDestroyed += aiEventProcessor_OnEnemyComponentDestroyed; aiEventProcessor.OnUnitUnderAttack += aiEventProcessor_OnUnitUnderAttack; }
public void Test_IsInAttackRange_MustMatch() { var enemy = new Infantery(); enemy.OwnerId = "2"; enemy.Position = new Vector2(500, 510); var infantery = new Infantery(); infantery.OwnerId = "1"; infantery.Position = new Vector2(0,0); var barrack = new Barrack(); barrack.OwnerId = "1"; barrack.Position = new Vector2(500,500); Assert.False(infantery.IsInAttackRange(enemy.Position)); Assert.True(enemy.IsInAttackRange(barrack.Position)); }
private MoveUnitEvent MoveUnitEvent(Infantery infantery) { return new MoveUnitEvent(_ai.Id, infantery.Id, _random.Next(20, 250), _random.Next(20, 250)); }