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); }