/// <summary> /// 切换场景空间开始 /// </summary> /// <param name="destination">传送目的地</param> void ChangeSpaceTo(Teleport destination) { initializer.AdaptiveWindowSize(); LayoutRoot.Children.Add(initializer); dramaDialogue.Hide(); space.ClearAllRoles(); LayoutRoot.MouseLeftButtonDown -= LayoutRoot_MouseLeftButtonDown; LayoutRoot.MouseLeftButtonUp -= LayoutRoot_MouseLeftButtonUp; LayoutRoot.MouseRightButtonDown -= LayoutRoot_MouseRightButtonDown; memoryCollector.Stop(); LayoutRoot.MouseWheel -= LayoutRoot_MouseWheel; leader.PositionChanged -= leader_PositionChanged; leader.MoveChanged -= leader_MoveChanged; EventHandler handler = null; initializer.ResReady += handler = (s, e) => { initializer.ResReady -= handler; space.Code = (int)s; space.SetScale(spaceScale); space.EndEasingMapTo(terrain.GetPositionFromCoordinate(destination.ToCoordinate)); //根据目标空间是否是副本以创建相应副本 if ((int)destination.Instance != -1) { //通过反射来实例化副本 Assembly assembly = Assembly.Load("Components,Version=1.0.0.0"); instance = assembly.CreateInstance(string.Format("Components.Instance.{0}", destination.Instance)) as InstanceBase; instance.Z = 99; instance.AddRoles += AddRoles; instance.Leave += instance_Leave; LayoutRoot.Children.Add(instance); instance.Run(new List<RoleBase>() { leader }, space); } }; initializer.spaceInit(destination.ToSpace); }
void instance_Leave(object sender, LeaveEventArgs e) { instance.AddRoles -= AddRoles; instance.Leave -= instance_Leave; ChangeSpaceTo(teleport = e.Destination); LayoutRoot.Children.Remove(instance); instance = null; }