📄 world.java.svn-base
字号:
package base;import interfaces.AnimationInterface;import interfaces.GroundControllerInterface;import java.util.ArrayList;import java.util.List;import world.*;import world.Plane;import world.Tower;import agents.LocalControllerAgent;/** * The world. * * @author Josh Villbrandt */public class World { public static List<WorldObject> world_objects = new ArrayList<WorldObject>(); public static AnimationInterface animation_interface = null; public static long update_interval = 1000; public static int update_multiplier = 1; public static WorldThread thread; /** Sets the animation. */ public static final synchronized void setAnimation(AnimationInterface animation) { animation_interface = animation; } /** Starts the world. */ public static final synchronized void startWorld() { thread = new WorldThread(update_interval); thread.start(); } /** Starts the world. */ public static final synchronized void startWorld(long updateInterval) { update_interval = updateInterval; thread = new WorldThread(update_interval); thread.start(); } /** Starts the world. */ public static final synchronized void startWorld(long updateInterval, int updateMultiplier) { update_interval = updateInterval; update_multiplier = updateMultiplier; thread = new WorldThread(update_interval); thread.start(); } /** Stops the world. */ public static final synchronized void stopWorld() { thread.stop_thread(); } public static final synchronized void update_world() { if (animation_interface != null) animation_interface.drawWorld(world_objects); } public static final boolean runways_exist() { for (WorldObject world_object : world_objects) { if ((world_object instanceof Runway)) { return true; } } // If for loop exits, there are no runways return false; } public static final Plane get_plane(String call_num) { for (WorldObject world_object : world_objects) if ((world_object instanceof Plane)&& (world_object.name.equals(call_num))) return (Plane)world_object; return null; } public static final LocalControllerAgent get_local_controller(Tower tower) { for (WorldObject world_object : world_objects) if ((world_object instanceof LocalControllerAgent)&& (((LocalControllerAgent)world_object).tower == tower)) return (LocalControllerAgent)world_object; return null; } public static final GroundControllerInterface get_ground_controller(Tower tower) { /* for (WorldObject world_object : world_objects) { if (world_object instanceof GroundController) System.out.println("found gc"); if ((world_object instanceof GroundController)&& (((GroundController)world_object).tower == tower)) return (GroundController)world_object; }*/ return tower.get_gc(); } public static final void update_planes() { for (WorldObject object : world_objects) if (object instanceof Plane){ ((Plane)object).update(); //object.get_world_object_state().update(); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -