//Variable Initialization for derived classes public TimedEvent( int pAnomalousEventId, TimeSpan ts, ICallbackAction<TimedEvent> pFinishedCallback, Vector3 pStartingLocation, Color pColor, Vector3 pIconScale, bool pPlayerEvent, string pEventCreator, string pIconPrefabID ) { timeUnitsPassed = 0; targetID = pAnomalousEventId; ETA = ts; finishedCallback = pFinishedCallback; GameUtils.SphericalToCartesian(GeoscapeVariables.ICON_ALTITUDE, pStartingLocation.y * Mathf.Deg2Rad, pStartingLocation.x * Mathf.Deg2Rad, out startingLocation); playerEvent = pPlayerEvent; eventCreator = pEventCreator; iconPrefabID = pIconPrefabID; destroyMe = false; SetupIcon(pIconScale, pColor); SetupUpdateCallback(); }
public TravelTimedEvent( ICallbackAction<TimedEvent> pFinishedCallback, ICallbackAction<TravelTimedEvent, string> pDestroyedAction, int pAnomalousEventId, Vector2 pStartingLocation, Vector2 pEndingLocation, string pIconPrefabID, Vector3 pIconScale, Color pColor, float pSpeed = 310.0f, string pEventCreator = "SCP Foundation", bool pIsPlayerEvent = true) : base ( pAnomalousEventId, new TimeSpan(0, 0, (int)(GameUtils.CalculateDistance(pStartingLocation, pEndingLocation) / pSpeed * GeoscapeVariables.SECONDS_IN_HOUR)), pFinishedCallback, pStartingLocation, pColor, pIconScale, pIsPlayerEvent, pEventCreator, pIconPrefabID ) { //Variable Inits speed = pSpeed; destroyedAction = pDestroyedAction; detectionStatus = 0; GameUtils.SphericalToCartesian(GeoscapeVariables.ICON_ALTITUDE, pEndingLocation.y * Mathf.Deg2Rad, pEndingLocation.x * Mathf.Deg2Rad, out endingLocation); SetupIcon(pIconScale, pColor); }
public void RegisterAction(ICallbackAction action) { if (callbacks.Any(x => x.Name == action.Name)) { throw new ArgumentException($"An action named \"{action.Name}\" is already registered.", nameof(action)); } callbacks.Add(action); }
public override void Reroute(Vector2 newEndingLoc, ICallbackAction<TimedEvent> pFinishedAction, int pNewAnomalousEventId = -1) { base.Reroute(newEndingLoc, pFinishedAction, pNewAnomalousEventId); returningToBase = true; if (interceptTarget.GetComponent<TravelPopup>() != null && interceptTarget.GetComponent<TravelPopup>().interceptingCrafts.Contains(icon)) { interceptTarget.GetComponent<TravelPopup>().interceptingCrafts.Remove(icon); interceptTarget.GetComponent<TravelPopup>().RefreshIntercepts(); } }
//For events that simply need time to pass nothing more. public TimedEvent(TimeSpan ts, ICallbackAction<TimedEvent> pFinishedCallback, bool pIsPlayerEvent = true, string pEventCreator = "World") { timeUnitsPassed = 0; targetID = -1; finishedCallback = pFinishedCallback; destroyMe = false; ETA = ts; playerEvent = pIsPlayerEvent; eventCreator = pEventCreator; SetupUpdateCallback(); }
//Timed Popup Message Events public TimedEvent(TimeSpan ts, int pAnomalousEventId, Vector2 pStartingLocation, string pIconPrefabID, Vector3 pIconScale, string popUpText) { timeUnitsPassed = 0; finishedCallback = new EmptyCallback(); targetID = pAnomalousEventId; destroyMe = false; ETA = ts; iconPrefabID = pIconPrefabID; playerEvent = false; eventCreator = "World"; startingLocation = pStartingLocation; SetupUpdateCallback(); SetupIcon(pIconScale, Color.white); }
public TimedWeaponEvent(int pInterceptTarget, GameObject pIcon, ICallbackAction<TimedEvent> pFinishedCallback, bool pPlayerEvent = true, float pSpeed = 3000f, string pCreator = "SCP Foundation") { speed = pSpeed; icon = pIcon; finishedCallback = pFinishedCallback; startingLocation = icon.transform.position; holdingPattern = false; interceptTarget = GeoscapeVariables.TEM.EventList[pInterceptTarget].icon; endingLocation = interceptTarget.transform.position; playerEvent = pPlayerEvent; eventCreator = pCreator; float tempR; Vector2 tempE; Vector2 tempS; GameUtils.CartesianToSpherical(startingLocation, out tempR, out tempS.y, out tempS.x); GameUtils.CartesianToSpherical(interceptTarget.transform.position, out tempR, out tempE.y, out tempE.x); float distance = GameUtils.CalculateDistance(tempS * Mathf.Rad2Deg, tempE * Mathf.Rad2Deg); ETA = new System.TimeSpan(0, 0, (int)(distance / speed * 3600f)); }
public virtual void Reroute(Vector2 newEndingLoc, ICallbackAction<TimedEvent> pFinishedAction, int pNewAnomalousEventId = -1) { //Create new starting location equal to where the icon currently is. Vector2 SphericalCoords; float radius; GameUtils.CartesianToSpherical(icon.transform.position, out radius, out SphericalCoords.y, out SphericalCoords.x); //Create new distance and ETA float newDistance = GameUtils.CalculateDistance(SphericalCoords * Mathf.Rad2Deg, newEndingLoc); //New Timespan TimeSpan ts = new TimeSpan(0, 0, (int)(newDistance / 310f * GeoscapeVariables.SECONDS_IN_HOUR)); ETA = ts; //Create new starting and ending locations and reset variables GameUtils.SphericalToCartesian(GeoscapeVariables.ICON_ALTITUDE, SphericalCoords.y, SphericalCoords.x, out startingLocation); GameUtils.SphericalToCartesian(GeoscapeVariables.ICON_ALTITUDE, newEndingLoc.y * Mathf.Deg2Rad, newEndingLoc.x * Mathf.Deg2Rad, out endingLocation); //Debug.Log("Start(" + EventIndex + "): " + SphericalCoords + " Result: " + newEndingLoc); holdingPattern = false; finishedCallback = pFinishedAction; timeUnitsPassed = 0; targetID = pNewAnomalousEventId; }
public TimedInterceptEvent(int eventTarget, float pTailDistance, string pIconPrefabID, Color pColor, Vector3 pIconScale, ICallbackAction<TimedEvent> pEventCallback, ICallbackAction<TravelTimedEvent, string> pDestroyedAction, Vector2 pStartingLocation, bool pPlayerEvent = true, float pSpeed = 1150f, float pFuel = 3000f, string pCreator = "SCP Foundation") : base ( pEventCallback, pDestroyedAction, eventTarget, pStartingLocation, GeoscapeVariables.TEM.EventList[eventTarget].icon.transform.position, pIconPrefabID, pIconScale, pColor, pSpeed, pCreator, pPlayerEvent ) { Weapons = new List<bool>(); Weapons.Add(false); originalSpeed = pSpeed; fuelDistance = pFuel; tailDistance = pTailDistance; interceptTarget = GeoscapeVariables.TEM.EventList[eventTarget].icon; currentDistance = GameUtils.CalculateDistance(pStartingLocation, interceptTarget.transform.position); float tempR; Vector2 tempC; GameUtils.CartesianToSpherical(interceptTarget.transform.position, out tempR, out tempC.y, out tempC.x); endingLocation = interceptTarget.transform.position; }
public virtual void Reroute(GameObject newInterceptTarget, ICallbackAction<TimedEvent> pFinishedAction) { //Create new starting location equal to where the icon currently is. Vector2 SphericalCoordsCurrent; Vector2 SphericalCoordsIntercept; float radius; GameUtils.CartesianToSpherical(icon.transform.position, out radius, out SphericalCoordsCurrent.y, out SphericalCoordsCurrent.x); GameUtils.CartesianToSpherical(newInterceptTarget.transform.position, out radius, out SphericalCoordsIntercept.y, out SphericalCoordsIntercept.x); //Create new distance float newDistance = GameUtils.CalculateDistance(SphericalCoordsCurrent * Mathf.Rad2Deg, SphericalCoordsIntercept * Mathf.Rad2Deg); //New Timespan TimeSpan ts = new TimeSpan(0, 0, (int)(newDistance / 310f * GeoscapeVariables.SECONDS_IN_HOUR)); GameUtils.SphericalToCartesian(GeoscapeVariables.ICON_ALTITUDE, SphericalCoordsCurrent.y, SphericalCoordsCurrent.x, out startingLocation); GameUtils.SphericalToCartesian(GeoscapeVariables.ICON_ALTITUDE, SphericalCoordsIntercept.y, SphericalCoordsIntercept.x, out endingLocation); //Debug.Log("Start(" + EventIndex + "): " + SphericalCoords + " Result: " + newEndingLoc); currentDistance = newDistance; holdingPattern = false; returningToBase = true; finishedCallback = pFinishedAction; timeUnitsPassed = 0; if (interceptTarget.GetComponent<TravelPopup>() != null && interceptTarget.GetComponent<TravelPopup>().interceptingCrafts.Contains(icon)) { interceptTarget.GetComponent<TravelPopup>().interceptingCrafts.Remove(icon); interceptTarget.GetComponent<TravelPopup>().RefreshIntercepts(); } }
public TimedEvent(JSONNode N) { ID = N["ID"].AsInt; ETA = TimeSpan.Parse(N["ETA"]); playerEvent = N["playerEvent"].AsBool; detectionStatus = N["detectionStatus"].AsInt; targetID = N["anomalousEventId"].AsInt; eventCreator = N["eventCreator"]; timeUnitsPassed = N["timeUnitsPassed"].AsFloat; finishedCallback = (ICallbackAction<TimedEvent>)Activator.CreateInstance(Type.GetType(N["finishedCallback"])); if (N["iconPrefabID"] != null) { startingLocation = GameUtils.ParseVector3(N["startingLocation"]); SetupIcon(GameUtils.ParseVector3(N["iconScale"]), GameUtils.ParseColor(N["iconColor"])); } SetupUpdateCallback(); }
public TravelTimedEvent(JSONNode N) : base(N) { endingLocation = GameUtils.ParseVector3(N["endingLocation"]); holdingPattern = N["holdingPattern"].AsBool; hiding = N["hiding"].AsBool; destroyedAction = (ICallbackAction<TravelTimedEvent, string>)Activator.CreateInstance(Type.GetType(N["destroyedAction"])); speed = N["speed"].AsFloat; N["speed"] = speed.ToString(); }
//This can only be called for TravelTimedEvents public void RerouteEvent(int pEventIndex, Vector2 newEndingLoc, ICallbackAction<TimedEvent> pFinishedAction) { ((TravelTimedEvent)EventList[pEventIndex]).Reroute(newEndingLoc, pFinishedAction); }