/* * Licensed Materials - Property of Perforce Software, Inc. * © Copyright Perforce Software, Inc. 2014, 2021 * © Copyright IBM Corp. 2009, 2014 * © Copyright ILOG 1996, 2009 * All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * The Software and Documentation were developed at private expense and * are "Commercial Items" as that term is defined at 48 CFR 2.101, * consisting of "Commercial Computer Software" and * "Commercial Computer Software Documentation", as such terms are * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4, * as applicable. */ package simulation; import ilog.views.maps.defense.symbology.app6a.IlvApp6aSymbol; import ilog.views.sdm.IlvSDMEngine; /** * Class for enemy unit being targets of missiles. * * @see Missile * */ public class Target extends Mobile { private boolean clockwiseMovement; Target(IlvSDMEngine sym) { this("Target", sym); //$NON-NLS-1$ } /** * Creates a target with a different symboloc tag. * * @param tag * tag (used in the CSS file) * @param sym * symbology. */ protected Target(String tag, IlvSDMEngine sym) { super(tag, sym, "SNAPCF-----CUS-");//$NON-NLS-1$ if (SimulationContext.random() > 0.5) { double rnd = SimulationContext.random(); String a; if (rnd > 0.75) { a = "A";//$NON-NLS-1$ } else if (rnd > 0.5) { a = "P";//$NON-NLS-1$ } else if (rnd > 0.25) { a = "F";//$NON-NLS-1$ } else { a = "N";//$NON-NLS-1$ } setSymbolProperty(IlvApp6aSymbol.ID_CODE, "S" + a + "APCF-----CUS-", true);//$NON-NLS-1$//$NON-NLS-2$ } double lon0 = SimulationContext.getRandomLongitude(); double lat0 = SimulationContext.getRandomLatitude(); symbol.setLocation(null, lon0, lat0); setHorizontalSpeed(((int) (SimulationContext.random() * 20) + 10) * 5.0); setVerticalSpeed(SimulationContext.random() * 6.0 - 3.0); clockwiseMovement = (SimulationContext.random() > 0.5); updateLocation(); } Override double getDirection() { double v = (getLastUpdateTime() / (10000 * getHorizontalSpeed() / SimulationContext.getTimeAcceleration())); double l = (v - Math.floor(v)); if (!clockwiseMovement) l = -l; return l * 2 * Math.PI - Math.PI; } }