⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 targetmessage.java

📁 2004年robotcup世界冠军源代码
💻 JAVA
字号:
package MRL.Utilities.MessageManagement;import yab.agent.DisasterSpace;import yab.agent.object.*;import java.util.Map;import java.util.Collections;import java.util.Iterator;/** * Created by JBuilder 2006. * User: Omid AmirGhiasvand * * Date: 2006-05-19 * Time: 5:32 pm *///saeed 85-2-3public class TargetMessage extends Message{    int targetId;    int index;    static final int indexSize = 4;    static final int idSize = 32;    public TargetMessage(int index, int targetId)    {        super(Type.TARGET_REPORT, null);        this.index = index;        this.targetId = targetId;    }    char[] toCharArray(Map idToVirtualId)    {        char[] result = new char[length()];        char[] temp = Util.intToCharArray(index, indexSize);        Util.copyArray(temp, result, 0, 0, indexSize);        temp = Util.intToCharArray(targetId, idSize);        Util.copyArray(temp, result, 0, indexSize, idSize);        return result;    }    protected int length()    {        return staticLength();    }    protected static int staticLength()    {        return idSize + indexSize;    }    public boolean equals(Object m)    {        if (!(m instanceof TargetMessage)) return false;        return ((TargetMessage) m).index == index;    }    public int hashCode()    {        return index;    }    void updateWorld(DisasterSpace world, int time)    {        Collections.sort(world.ambulanceTeams, yab.agent.Util.idComparator);           AmbulanceTeam ambulance = (AmbulanceTeam) world.ambulanceTeams.get(index);           Humanoid target = (Humanoid) world.get(targetId);              if (! (world.self instanceof AmbulanceTeam))                 return;             obj = world.get(targetId);              if (obj == null)               {                   obj = RCRObject.produce(TYPE_CIVILIAN, targetId, world);                   world.add((RealObject) obj);                   obj.setTime(0);                   obj.setHearTime(time);                   target=(Humanoid)obj;               }                  if (world.self == ambulance  )                  {                    ambulance.tempTarget=target;                  }                  else                  {                    ambulance.myAssignedTarget=target;                  }    }    public TargetMessage(char[] message)    {        super(Type.TARGET_REPORT, null);        this.index = Util.charArrayToint(message, 0, indexSize);        this.targetId = Util.charArrayToint(message, indexSize, idSize);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -