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

📄 victimmessage.java

📁 2004年robotcup世界冠军源代码
💻 JAVA
字号:
package MRL.Utilities.MessageManagement;import yab.agent.DisasterSpace;import yab.agent.object.*;import java.util.Map;import MRL.Police.EPoliceForce;/** * Created by IntelliJ IDEA. * User: Maryam * Date: Apr 27, 2005 * Time: 4:51:15 PM * To change this template use File | Settings | File Templates. *///saeed 85-2-3public class VictimMessage extends Message{    private int realId;    private int posId;    private int hp;    private int damage;    private int buriedness;    private int time;    static final int realIdSize = 32;    static final int hpSize = 14;    static final int damageSize = 8;    static final int buriednessSize = 6;    static final int timeSize = 9;    public VictimMessage(Humanoid victim)    {        super(Type.CIVILIAN_REPORT, victim);        this.realId = victim.id;        this.posId = victim.position().id;        this.hp = victim.hp();        this.damage = victim.damage() - 4;        this.buriedness = victim.buriedness();        this.time = victim.time();    }    public VictimMessage(char[] message, Map virtualIdToId)    {        super(Type.CIVILIAN_REPORT, null);        this.realId = Util.charArrayToint(message, 0, realIdSize);        this.posId = ((Integer) virtualIdToId.get(new Integer(Util.charArrayToint(message, realIdSize, idSize)))).intValue();        this.hp = Util.charArrayToint(message, realIdSize + idSize, hpSize);        this.damage = Util.charArrayToint(message, realIdSize + idSize + hpSize, damageSize);        this.buriedness = (Util.charArrayToint(message, realIdSize + idSize + hpSize + damageSize, buriednessSize));        this.time = Util.charArrayToint(message, realIdSize + idSize + hpSize + damageSize + buriednessSize, timeSize);    }    public VictimMessage(int id, int posId, int hp, int damage, int burriedness, int time)    {        super(Type.CIVILIAN_REPORT, null);        this.realId = id;        this.posId = posId;        this.hp = hp;        this.damage = damage;        this.buriedness = burriedness;        this.time = time;    }    protected static int staticLength()    {        return realIdSize + idSize + hpSize + damageSize + buriednessSize + timeSize;    }    public boolean equals(Object m)    {        if (!(m instanceof VictimMessage)) return false;        return realId == ((VictimMessage) m).realId;    }    public int hashCode()    {        return realId;    }    void updateWorld(DisasterSpace world, int worldTime)    {        obj = world.get(realId);        if (obj == null)        {            obj = RCRObject.produce(TYPE_CIVILIAN, realId, world);            world.add((RealObject) obj);            obj.setTime(0);            obj.setHearTime(time);  /// ????? Omid AmirGh        }   //     System.out.println("eva! ressssssssssssssssssssid!" + obj.id+" , world time = " +worldTime + " , " + obj.time());        if (obj.time() < worldTime - 2)        {                ;//System.out.flush();            obj.setProperty(world.time(), PROPERTY_POSITION, new int[]{posId});            obj.setProperty(world.time(), PROPERTY_HP, new int[]{hp});            obj.setProperty(world.time(), PROPERTY_DAMAGE, new int[]{damage});            obj.setProperty(world.time(), PROPERTY_BURIEDNESS, new int[]{buriedness});            Humanoid human = (Humanoid)obj;            human.setLastDamage(human.damage());            human.setLastUpdateTime(time);            human.setLastHp(human.hp());            if (human instanceof Civilian && human.position() instanceof Refuge)                ((Civilian)human).setReportedInRefuge();            //obj.setIsChanged (true);            obj.setHearTime(time);            world.civCheckTime.remove(obj);            world.civCheckTime.put(obj, new Integer(time));        }        if(world.self instanceof PoliceForce){            if(obj instanceof PoliceForce){                EPoliceForce me = (EPoliceForce) world.self;                PoliceForce target = (PoliceForce) obj;                if(target.buriedness() == 0 && target.hp() > 0 && ! me.freePolices.contains(target)){                    me.freePolices.add(target);                    world.sortByID(me.freePolices);                }            }        }    }    char[] toCharArray(Map idToVirtualIds)  // id - posId - hp - damage - buriedness    {        char[] result = new char[length()];        char[] temp;        temp = Util.intToCharArray(obj.id, realIdSize);        Util.copyArray(temp, result, 0, 0, realIdSize);        temp = Util.intToCharArray(((Integer) idToVirtualIds.get(new Integer(posId))).intValue(), idSize);        Util.copyArray(temp, result, 0, realIdSize, idSize);        temp = Util.intToCharArray(hp, hpSize);        Util.copyArray(temp, result, 0, realIdSize + idSize, hpSize);        temp = Util.intToCharArray(damage, damageSize);        Util.copyArray(temp, result, 0, realIdSize + idSize + hpSize, damageSize);        temp = Util.intToCharArray(buriedness, buriednessSize);        Util.copyArray(temp, result, 0, realIdSize + idSize + hpSize + damageSize, buriednessSize);        temp = Util.intToCharArray(time, timeSize);        Util.copyArray(temp, result, 0, realIdSize + idSize + hpSize + damageSize + buriednessSize, timeSize);        return result;    }    protected int length()    {        return staticLength();    }    public Humanoid getVictim()    {        return (Humanoid) obj;    }}

⌨️ 快捷键说明

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