public sEvent GenerateEvent() { EventType eT = PickEventType(); sEvent newEvent = null; if (eT.type is RepairHatchEvent) { RepairStation rS = eT.stations.GetRandomStation() as RepairStation; if (rS == null) { return(null); //means all stations are broken } newEvent = ScriptableObject.CreateInstance <RepairHatchEvent>(); //new RepairEvent(); // Instantiate<sEvent>(eT.type); activeEvents.Add(newEvent); (newEvent as RepairHatchEvent).station = rS; newEvent.InitiateEvent(this); if (rS.location != map.playerLocation) { diagH.DisplayRepairMessage(newEvent as RepairHatchEvent); } } else if (eT.type is RepairPipeEvent) { RepairStation rS = eT.stations.GetRandomStation() as RepairStation; if (rS == null) { return(null); //means all stations are broken } newEvent = ScriptableObject.CreateInstance <RepairPipeEvent>(); //new RepairEvent(); // Instantiate<sEvent>(eT.type); activeEvents.Add(newEvent); (newEvent as RepairPipeEvent).station = rS; newEvent.InitiateEvent(this); if (rS.location != map.playerLocation) { diagH.DisplayRepairMessage(newEvent as RepairPipeEvent); } } else if (eT.type is RepairPumpEvent) { RepairStation rS = eT.stations.GetRandomStation() as RepairStation; if (rS == null) { return(null); //means all stations are broken } newEvent = ScriptableObject.CreateInstance <RepairPumpEvent>(); //new RepairEvent(); // Instantiate<sEvent>(eT.type); activeEvents.Add(newEvent); (newEvent as RepairPumpEvent).station = rS; newEvent.InitiateEvent(this); if (rS.location != map.playerLocation) { diagH.DisplayRepairMessage(newEvent as RepairPumpEvent); } } return(newEvent); }
public void GenerateScriptedEvent() { if (currentScriptedEventIndex >= ScriptedStations.Length) { NotificationManager.Instance.QueueNotificationMessage("End of Practice Mode\nGood Luck!"); this.DelayedCall(() => { ScriptedDone = true; map.ResetSpeed(); }, 5f); return; } else { RepairStation rS = ScriptedStations[currentScriptedEventIndex] as RepairStation; if (rS == null) { return; } sEvent newEvent = null; if (rS.GetRepairEventType() == RepairEvent.RepairEventType.Hatch) { newEvent = ScriptableObject.CreateInstance <RepairHatchEvent>(); //new RepairEvent(); // Instantiate<sEvent>(eT.type); activeEvents.Add(newEvent); (newEvent as RepairHatchEvent).station = rS; newEvent.InitiateEvent(this); if (rS.location != map.playerLocation) { diagH.DisplayRepairMessage(newEvent as RepairHatchEvent); } } else if (rS.GetRepairEventType() == RepairEvent.RepairEventType.Pipe) { newEvent = ScriptableObject.CreateInstance <RepairPipeEvent>(); //new RepairEvent(); // Instantiate<sEvent>(eT.type); activeEvents.Add(newEvent); (newEvent as RepairPipeEvent).station = rS; newEvent.InitiateEvent(this); if (rS.location != map.playerLocation) { diagH.DisplayRepairMessage(newEvent as RepairPipeEvent); } } else if (rS.GetRepairEventType() == RepairEvent.RepairEventType.Pump) { newEvent = ScriptableObject.CreateInstance <RepairPumpEvent>(); //new RepairEvent(); // Instantiate<sEvent>(eT.type); activeEvents.Add(newEvent); (newEvent as RepairPumpEvent).station = rS; newEvent.InitiateEvent(this); if (rS.location != map.playerLocation) { diagH.DisplayRepairMessage(newEvent as RepairPumpEvent); } } currentScriptedEventIndex++; } }