public void teleport(TeleportPortal teleport) { if (teleport == null || teleport.dropZone == null && teleport.teleportInfo.mapName.Length <= 0) { return; } //传送到当前地图的目标传送点 if (teleport.dropZone != null && teleport.dropZoneEventAction != null && teleport.dropZoneEventAction.type == EventActionType.teleport) { this.teleport(new TeleportTargetInfo(teleport)); } else { //传送到指定地图 var mapName = teleport.teleportInfo.mapName; var roomName = teleport.teleportInfo.roomName; var teleportPortalName = teleport.teleportInfo.teleportPortalName; if (teleportPortalName != null && teleportPortalName.Length > 0) { this.teleport(new TeleportTargetInfo(mapName, roomName, teleportPortalName, teleport.soundEffect)); } else { var postion = teleport.teleportInfo.teleportPoint; this.teleport(new TeleportTargetInfo(mapName, roomName, postion, teleport.soundEffect)); } } }
public TeleportTargetInfo(TeleportPortal teleportPortal) { var room = RoomInfo.getParentRoom(teleportPortal.dropZone.gameObject); this.map = room.gameObject.GetComponentInParentIncludeInactive <MapInfo>(); this.mapName = map.name; this.room = room; this.roomName = room.name; this.position = (Vector2)teleportPortal.dropZone.transform.position + teleportPortal.dropZoneTeleportPortal.dropZoneOffset; this.soundEffect = teleportPortal.soundEffect; this.backgroundMusic = this.room.backgroundMusic; this.cameraConfiner = this.room.cameraConfiner; }
public static TeleportPortal ConvertEventActionToTeleportPortal(EventAction eventAction) { TeleportPortal teleport = new TeleportPortal(); teleport.dropZone = eventAction.transformVar1; teleport.dropZoneOffset = eventAction.vector2Var1; teleport.soundEffect = eventAction.audioClipVar1; if (eventAction.stringVar1.Length > 0) { teleport.teleportInfo = new TeleportInfo(); teleport.teleportInfo.mapName = eventAction.stringVar1; teleport.teleportInfo.roomName = eventAction.stringVar2; teleport.teleportInfo.teleportPortalName = eventAction.stringVar3; teleport.teleportInfo.teleportPoint = eventAction.vector2Var2; } teleport.gameObject = eventAction.gameObject; return(teleport); }
public TeleportTargetInfo(string mapName, string roomName, string teleportPortalName, AudioClip soundEffect) { this.mapName = mapName; this.roomName = roomName; if (MMX.GameManager.map.name == mapName) { this.map = MMX.GameManager.map.GetComponent <MapInfo>(); } else { this.map = Resources.Load <GameObject>("地图/" + mapName).GetComponent <MapInfo>(); } foreach (var item in map.rooms) { if (item.name == roomName) { this.room = item; break; } } foreach (var item in room.gameObject.GetComponentsInChildren <EventAction>()) { if (item.type == EventActionType.teleport) { if (item.name == teleportPortalName) { var teleportPortal = TeleportPortal.ConvertEventActionToTeleportPortal(item); this.position = (Vector2)teleportPortal.gameObject.transform.position + teleportPortal.dropZoneOffset; } } } this.soundEffect = soundEffect; this.backgroundMusic = this.room.backgroundMusic; this.cameraConfiner = this.room.cameraConfiner; }
public void execute(EventAction eventAction) { TeleportPortal teleport = TeleportPortal.ConvertEventActionToTeleportPortal(eventAction); this.teleport(teleport); }