Example #1
0
 private void checkMainBase(FakeMessage msg) {
   EntityKnowledge mainBase = getMainBase();
   if ((mainBase != null) && (msg.getSender() == mainBase.getID())) {
     x = (int) -(Math.cos(Math.toRadians(msg.getAngle())) * msg.getDistance());
     y = (int) -(Math.sin(Math.toRadians(msg.getAngle())) * msg.getDistance());
   }
 }
Example #2
0
  public void processMessage(FakeMessage msg) {
    if (msg.getMessage().equals("alive")) {
      SortedMap<Integer, EntityKnowledge> a = allies.get(msg.getSenderType());
      if (a == null) {
        a = new TreeMap<Integer, EntityKnowledge>();
        allies.put(msg.getSenderType(), a);
      }
      EntityKnowledge ent = a.get(msg.getSender());
      if (ent == null) {
        ent = new EntityKnowledge(msg, getTick());
        a.put(msg.getSender(), ent);
      } else {
        ent.update(msg, getTick());
      }
      if (msg.getSenderType().equals(Names.BASE)) {
        checkMainBase(msg);
      }
    } else if (msg.getMessage().equals("ennemy")) {
      String[] content = msg.getContent();
      int id = Integer.parseInt(content[0]);
      String type = content[2];

      SortedMap<Integer, EntityKnowledge> a = ennemies.get(type);
      if (a == null) {
        a = new TreeMap<Integer, EntityKnowledge>();
        ennemies.put(type, a);
      }
      EntityKnowledge ent = a.get(id);
      if (ent == null) {
        ent = new EntityKnowledge(msg, getTick());
        a.put(id, ent);
      } else {
        ent.update(msg, getTick());
      }
    } else if (msg.getMessage().equals("beginContract")) {
      String[] content = msg.getContent();
      setActiveContract(content[0], Integer.parseInt(content[1]));
    } else if (msg.getMessage().equals("endContract")) {
      String[] content = msg.getContent();
      setActiveContract(content[0], -1);
    }
  }