/// <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);
 }
Beispiel #2
0
 /// <summary>
 /// 添加传送点
 /// </summary>
 /// <param name="teleport">传送点</param>
 /// <param name="data">地形描述字符串</param> 
 public void AddTeleport(Teleport teleport, string data)
 {
     teleports.Add(teleport);
     string[] teleportData = data.Split(',');
     for (int j = 0; j < teleportData.Count(); j++) {
         if (teleportData[j] != "") {
             string[] position = teleportData[j].Split('_');
             teleportMatrix[Convert.ToByte(position[0]), Convert.ToByte(position[1])] = (byte)teleport.Code;
         }
     }
 }
 /// <summary>
 /// 主角玩家位置改变时
 /// </summary>
 void leader_PositionChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     radarMap.CoordinateValue = leader.Coordinate;
     if (space.ViewPortMoveMode == ViewPortMoveModes.Synchronization) { space.MovingMap(leader.Position); }
     space.LayingMap(leader.Position, false); //根据主角当前位置铺设空间地砖
     //判断是否采到传送点
     Teleport tempTeleport = terrain.InToTeleport(leader.Coordinate);
     if (tempTeleport != null && tempTeleport.SpaceLayer == leader.SpaceLayer) {
         spaceScale = space.Scale;
         space.SetScale(1);
         teleport = tempTeleport;
         //根据是否在相同地图间传送
         if (space.Code == teleport.ToSpace) {
             leader.TeleportTo(teleport.ToCoordinate, (Directions)teleport.ToDirection);
             space.SetScale(spaceScale);
             space.EndEasingMapTo(terrain.GetPositionFromCoordinate(teleport.ToCoordinate));
         } else {
             ChangeSpaceTo(teleport);
         }
     }
 }
 void instance_Leave(object sender, LeaveEventArgs e)
 {
     instance.AddRoles -= AddRoles;
     instance.Leave -= instance_Leave;
     ChangeSpaceTo(teleport = e.Destination);
     LayoutRoot.Children.Remove(instance);
     instance = null;
 }