public void GetVisibleAntsTest() { Worker worker1 = new Worker(new Position(2, 2)); Warrior warrior1 = new Warrior(new Position(3, 3)); Spider spider1 = new Spider(new Position(2, 3)); XmlReaderWriter reader = new XmlReaderWriter(); reader.ReadMe("..\\..\\tests\\test-RAIN-anthill.xml"); AHGraphics.Init(); Simulation tmp_isw = new Simulation(new Map(AntHillConfig.mapColCount, AntHillConfig.mapRowCount, AntHillConfig.tiles)); tmp_isw.ants.AddLast(worker1); tmp_isw.ants.AddLast(warrior1); tmp_isw.spiders.AddLast(spider1); Rain test_rain = new Rain(new Position(3, 3)); tmp_isw.rain = test_rain; LIList <Ant> list1 = tmp_isw.GetVisibleAnts(test_rain); LIList <Ant> list2 = tmp_isw.GetVisibleAnts(warrior1); LIList <Ant> list3 = tmp_isw.GetVisibleAnts(worker1); LIList <Ant> list4 = tmp_isw.GetVisibleAnts(spider1); Assert.IsFalse(list1.Contains(worker1), "GetVisibleAntsTest problem to see worker by rain"); Assert.IsTrue(list1.Contains(warrior1), "GetVisibleAntsTest problem to see warrior by rain"); Assert.IsTrue(list2.Contains(worker1), "GetVisibleAntsTest problem to see worker by warriror"); Assert.IsTrue(list3.Contains(warrior1), "GetVisibleAntsTest problem to see warrior by worker"); Assert.IsTrue(list4.Contains(worker1), "GetVisibleAntsTest problem to see worker by rain"); Assert.IsTrue(list4.Contains(warrior1), "GetVisibleAntsTest problem to see warrior by rain"); }
public LIList <Message> GetVisibleMessages(Element c) { LIList <Message> res_messages = new LIList <Message>(); LinkedListNode <Message> messageNode; if (c is Ant) { messageNode = Map.GetTile(c.Position).messages.First; while (messageNode != null) { res_messages.AddLast(messageNode.Value); messageNode = messageNode.Next; } } else if (c is Rain) { for (int i = 0; i < AntHillConfig.rainWidth; i++) { for (int j = 0; j < AntHillConfig.rainWidth; j++) { messageNode = Map.GetTile(c.Position.X + i, c.Position.Y + j).messages.First; while (messageNode != null) { if (!res_messages.Contains(messageNode.Value)) { res_messages.AddLast(messageNode.Value); } messageNode = messageNode.Next; } } } } return(res_messages); }