示例#1
0
 /// <summary>
 /// 游戏初始化
 /// </summary>
 /// <param name="heroCode">玩家角色代号</param>
 public void GameInit(int heroCode)
 {
     this.heroCode = heroCode;
     progressTip.Source = GlobalMethod.GetImage("UI/GameInit.png", UriType.Project);
     step = 0; stepNum = 8; partProgress = 1; //总共7步骤,前面6步都是单文件
     UpdateProgressInfo("加载角色配置");
     //下载角色配置
     ParallelDownloader downloader = new ParallelDownloader();
     downloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
     downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(roleInfo_OpenReadCompleted);
     downloader.OpenReadAsync(GlobalMethod.WebPath("Role/Info.xml"), DownloadPriority.Highest, heroCode, false, 0);
 }
 void queueDownloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     QueueParallelDownloader queueDownloader = sender as QueueParallelDownloader;
     queueDownloader.DownloadCompleted -= queueDownloader_OpenReadCompleted;
     Canvas body = new Canvas() {
         Width = 255,
         Height = 200,
         Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/105.png", UriType.Web) }
     };
     RadioButton[] languages = new RadioButton[5];
     languages[0] = new RadioButton() {
         Tag = "zh-cn",
         Content = new TextBlock() {
             Text = "简体中文",
             Style = Application.Current.Resources["TextStyle0"] as Style,
             TextWrapping = TextWrapping.Wrap,
             Foreground = new SolidColorBrush(Color.FromArgb(255, 239, 255, 208)),
         },
         FontSize = 14,
         GroupName = "Language",
         IsChecked = true,
     };
     languages[1] = new RadioButton() {
         Tag = "zh-tw",
         Content = new TextBlock() {
             Text = "繁體中文",
             Style = Application.Current.Resources["TextStyle0"] as Style,
             TextWrapping = TextWrapping.Wrap,
             Foreground = new SolidColorBrush(Color.FromArgb(255, 239, 255, 208)),
         },
         FontSize = 14,
         GroupName = "Language",
     };
     languages[2] = new RadioButton() {
         Tag = "us",
         Content = new TextBlock() {
             Text = "English",
             Style = Application.Current.Resources["TextStyle0"] as Style,
             TextWrapping = TextWrapping.Wrap,
             Foreground = new SolidColorBrush(Color.FromArgb(255, 239, 255, 208)),
         },
         FontSize = 14,
         GroupName = "Language"
     };
     languages[3] = new RadioButton() {
         Tag = "jp",
         Content = new TextBlock() {
             Text = "日本語",
             Style = Application.Current.Resources["TextStyle0"] as Style,
             TextWrapping = TextWrapping.Wrap,
             Foreground = new SolidColorBrush(Color.FromArgb(255, 239, 255, 208)),
         },
         FontSize = 14,
         GroupName = "Language"
     };
     languages[4] = new RadioButton() {
         Tag = "kr",
         Content = new TextBlock() {
             Text = "한국의",
             Style = Application.Current.Resources["TextStyle0"] as Style,
             TextWrapping = TextWrapping.Wrap,
             Foreground = new SolidColorBrush(Color.FromArgb(255, 239, 255, 208)),
         },
         FontSize = 14,
         GroupName = "Language"
     };
     for (int i = 0; i <= languages.GetUpperBound(0); i++) {
         body.Children.Add(languages[i]);
         Canvas.SetLeft(languages[i], 86); Canvas.SetTop(languages[i], -5 + i * 35);
     }
     ImageButton closer = new ImageButton() {
         TotalWidth = 93,
         TotalHeight = 27,
         Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/106.png", UriType.Web), Stretch = Stretch.None },
         Text = "提交(OK)",
         TextStyle = Application.Current.Resources["TextStyle1"] as Style,
         TextSize = 14,
         TextHasEffect = true,
         TextEffectColor = Colors.Black,
         TextBrush = new SolidColorBrush(Colors.LightGray),
         TextHoverBrush = new SolidColorBrush(Colors.White),
     };
     body.Children.Add(closer); Canvas.SetLeft(closer, 73); Canvas.SetTop(closer, 167);
     MouseButtonEventHandler handler0 = null;
     closer.Click += handler0 = delegate {
         closer.Click -= handler0;
         for (int i = 0; i <= languages.GetUpperBound(0); i++) {
             if (languages[i].IsChecked.Value) {
                 ParallelDownloader downloader = new ParallelDownloader();
                 OpenReadCompletedEventHandler handler = null;
                 downloader.OpenReadCompleted += handler = (s2, e2) => {
                     downloader.OpenReadCompleted -= handler;
                     Infos["Language"] = XElement.Load(e2.Result as Stream);
                     if (Submit != null) { Submit(this, null); }
                 };
                 downloader.OpenReadAsync(string.Format(GlobalMethod.WebPath("Language/{0}.xml"), languages[i].Tag.ToString()), DownloadPriority.Highest, null, false, 0);
                 break;
             }
         }
     };
     StyleBox styleBox = new StyleBox() {
         HeadHeight = 60,
         BodyHeight = 200,
         FootHeight = 15,
         NorthCenterWidth = 75,
         CenterWidth = 255,
         CenterEdgeWidth = 30,
         SouthCenterWidth = 229,
         NorthEdgeImageSource = GlobalMethod.GetImage("UI/100.png", UriType.Web),
         NorthImageSource = GlobalMethod.GetImage("UI/101.png", UriType.Web),
         CenterEdgeImageSource = GlobalMethod.GetImage("UI/102.png", UriType.Web),
         SouthEdgeImageSource = GlobalMethod.GetImage("UI/103.png", UriType.Web),
         SouthImageSource = GlobalMethod.GetImage("UI/104.png", UriType.Web),
         CenterContent = body,
     };
     styleBox.HeadText.Foreground = new SolidColorBrush(Colors.White);
     styleBox.HeadText.Text = "选 择 语 言";
     styleBox.HeadText.FontSize = 14;
     styleBox.HeadText.Margin = new Thickness(0, -20, 0, 0);
     Body = styleBox;
     base.OnResourceReady(this, e);
 }
示例#3
0
 void spaceInfo_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     step++;
     ParallelDownloader downloader = sender as ParallelDownloader;
     downloader.DownloadProgressChanged -= webClient_DownloadProgressChanged;
     downloader.OpenReadCompleted -= spaceInfo_OpenReadCompleted;
     string key = string.Format("Space{0}", e.UserState);
     if (!ObjectBase.Infos.ContainsKey(key)) { ObjectBase.Infos.Add(key, XElement.Load(e.Result as Stream)); }
     //下载缩略地图
     UpdateProgressInfo("加载Mini地图");
     downloader = new ParallelDownloader();
     downloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
     downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(miniMap_OpenReadCompleted);
     downloader.OpenReadAsync(GlobalMethod.WebPath(string.Format("Space/{0}/Thumbnail.jpg", e.UserState)), DownloadPriority.Highest, e.UserState, false, 0);
 }
示例#4
0
 void weaponModel_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     step++;
     ParallelDownloader downloader = sender as ParallelDownloader;
     downloader.DownloadProgressChanged -= webClient_DownloadProgressChanged;
     downloader.OpenReadCompleted -= weaponModel_OpenReadCompleted;
     Weapon.Res.Add(string.Format("Weapon{0}", (int)e.UserState), new StreamResourceInfo(e.Result as Stream, "application/binary"));
     //(测试)下载玩家角色乘具模型
     UpdateProgressInfo("加载坐骑模型");
     int rideModel = (int)ObjectBase.Infos["Role"].DescendantsAndSelf("Roles").Elements().Single(X => X.Attribute("Code").Value == heroCode.ToString()).DescendantsAndSelf("EntityLayer").Single().Attribute("RideModel");
     downloader = new ParallelDownloader();
     downloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
     downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(rideModel_OpenReadCompleted);
     downloader.OpenReadAsync(string.Format("Ride{0}.xap", rideModel), DownloadPriority.Highest, rideModel, false, 0);
 }
示例#5
0
 void rideModel_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     step++;
     ParallelDownloader downloader = sender as ParallelDownloader;
     downloader.DownloadProgressChanged -= webClient_DownloadProgressChanged;
     downloader.OpenReadCompleted -= rideModel_OpenReadCompleted;
     Ride.Res.Add(string.Format("Ride{0}", (int)e.UserState), new StreamResourceInfo(e.Result as Stream, "application/binary"));
     //下载所有魔法的配置
     UpdateProgressInfo("加载魔法配置");
     downloader = new ParallelDownloader();
     downloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
     downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(magicInfo_OpenReadCompleted);
     downloader.OpenReadAsync(GlobalMethod.WebPath("Magic/Info.xml"), DownloadPriority.Highest, null, false, 0);
 }
示例#6
0
 void roleInfo_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     step++;
     ParallelDownloader downloader = sender as ParallelDownloader;
     downloader.DownloadProgressChanged -= webClient_DownloadProgressChanged;
     downloader.OpenReadCompleted -= roleInfo_OpenReadCompleted;
     ObjectBase.Infos.Add("Role", XElement.Load(e.Result as Stream));
     //下载NPC信息
     UpdateProgressInfo("加载NPC与任务信息");
     downloader = new ParallelDownloader();
     downloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
     downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(npcInfo_OpenReadCompleted);
     downloader.OpenReadAsync(GlobalMethod.WebPath("Role/NPC.xml"), DownloadPriority.Highest, e.UserState, false, 0);
 }
示例#7
0
 void monsterInfo_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     step++;
     ParallelDownloader downloader = sender as ParallelDownloader;
     downloader.DownloadProgressChanged -= webClient_DownloadProgressChanged;
     downloader.OpenReadCompleted -= monsterInfo_OpenReadCompleted;
     ObjectBase.Infos.Add("Monster", XElement.Load(e.Result as Stream));
     //(测试)下载玩家角色铠甲(身体部分)模型
     UpdateProgressInfo("加载铠甲模型");
     int armorModel = (int)ObjectBase.Infos["Role"].DescendantsAndSelf("Roles").Elements().Single(X => X.Attribute("Code").Value == e.UserState.ToString()).DescendantsAndSelf("EntityLayer").Single().Attribute("ArmorModel");
     downloader = new ParallelDownloader();
     downloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
     downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(armorModel_OpenReadCompleted);
     downloader.OpenReadAsync(string.Format("Armor{0}.xap", armorModel), DownloadPriority.Highest, armorModel, false, 0);
 }
示例#8
0
 /// <summary>
 /// 空间初始化
 /// </summary>
 /// <param name="spaceCode">空间代号</param>
 public void spaceInit(int spaceCode)
 {
     this.spaceCode = spaceCode;
     progressTip.Source = GlobalMethod.GetImage("UI/SpaceInit.png", UriType.Project);
     step = 0; stepNum = 3; partProgress = 1;
     progressBar.Width = 0;
     UpdateProgressInfo(string.Format("加载{0}号场景配置", spaceCode));
     //首先下载该空间配置
     ParallelDownloader downloader = new ParallelDownloader();
     downloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
     downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(spaceInfo_OpenReadCompleted);
     downloader.OpenReadAsync(GlobalMethod.WebPath(string.Format("Space/{0}/Info.xml", spaceCode)), DownloadPriority.Highest, spaceCode, false, 0);
 }
 public void Run()
 {
     this.Children.Add(loading = new Loading() { Z = 999999 });
     loading.Show();
     this.Width = Application.Current.Host.Content.ActualWidth;
     this.Height = Application.Current.Host.Content.ActualHeight;
     this.Children.Add(music = new MediaPlayer() { Loop = true, Uri = "Login" }); music.Play();
     this.Children.Add(head = new EntityObject() { Source = GlobalMethod.GetImage("UI/LoginBack.jpg", UriType.Project), Stretch = Stretch.Fill, IsVisible = false, Z = 6, });
     this.Children.Add(backgroundFirst = new LoginBackground());
     this.Children.Add(backgroundSecond = new LoginBackground());
     this.Children.Add(foot = new EntityObject() { Source = GlobalMethod.GetImage("UI/LoginBack.jpg", UriType.Project), Stretch = Stretch.Fill, IsVisible = false, Z = 6, });
     LoginBackground.Interval = 110000;
     backgroundFirst.Run(BackgourndIndex.First, 0, -(Application.Current.IsRunningOutOfBrowser ? 2172 : backgroundFirst.RealWidth));
     backgroundSecond.Run(BackgourndIndex.Second, backgroundSecond.RealWidth - 1, -(Application.Current.IsRunningOutOfBrowser ? 2172 : backgroundFirst.RealWidth));
     //下载动画信息包
     ParallelDownloader downloader = new ParallelDownloader();
     downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(animationInfo_OpenReadCompleted);
     downloader.OpenReadAsync(GlobalMethod.WebPath("Animation/Info.xml"), DownloadPriority.Highest, null, false, 0);
 }
示例#10
0
 void animationInfo_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     ParallelDownloader downloader = sender as ParallelDownloader;
     downloader.OpenReadCompleted -= animationInfo_OpenReadCompleted;
     Infos.Add("Animation", XElement.Load(e.Result as Stream));
     backgroundFirst.DisplayAnimation();
     backgroundSecond.DisplayAnimation();
     RunCloud();
     //下载Login各界面配置
     downloader = new ParallelDownloader();
     downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(configInfo_OpenReadCompleted);
     downloader.OpenReadAsync(GlobalMethod.WebPath("Login/Info.xml"), DownloadPriority.Highest, null, false, 0);
 }
示例#11
0
 /// <summary>
 /// 根据中心点矩阵范X*Y围铺设地图地砖
 /// </summary>
 /// <param name="center">中心点(通常为主角/英雄位置)</param>
 /// <param name="force">是否强制铺设(针对场景切换后角色所处地块不变)</param>
 public void LayingMap(Point center, bool force)
 {
     Point2D newTile = new Point2D((int)((center.X + offset.X) / tileSize.X), (int)((center.Y + offset.Y) / tileSize.Y));
     if (force || newTile.X != lastTile.X || newTile.Y != lastTile.Y) {
         lastTile = newTile;
         //根据主角当前位置来加载周边屏幕分辨率下的地砖
         int startX, startY, endX, endY;
         if (newTile.X == 0) {
             startX = 0; endX = tileRange.X * 2;
         } else if (newTile.X == tileLimit.X) {
             startX = tileLimit.X - tileRange.X * 2; endX = tileLimit.X;
         } else {
             startX = newTile.X - tileRange.X; endX = newTile.X + tileRange.X;
         }
         if (startX < 0) { startX = 0; }
         if (endX > tileLimit.X) { endX = tileLimit.X; }
         if (newTile.Y == 0) {
             startY = 0; endY = tileRange.Y * 2;
         } else if (newTile.Y == tileLimit.Y) {
             startY = tileLimit.Y - tileRange.Y * 2; endY = tileLimit.Y;
         } else {
             startY = newTile.Y - tileRange.Y; endY = newTile.Y + tileRange.Y;
         }
         if (startY < 0) { startY = 0; } //越界处理
         if (endY > tileLimit.Y) { endY = tileLimit.Y; } //越界处理
         int index = 0;
         //取回已经超出主角周围N块范围的地砖(x,y初始为-1,第一次加载N块)
         tile[] tempTiles = tileList.Where(c => c.X < startX || c.X > endX || c.Y < startY || c.Y > endY).ToArray();
         for (int x = startX; x <= endX; x++) {
             for (int y = startY; y <= endY; y++) {
                 //N点位中假如已经有该点位的地砖在则检查下一个
                 if (tileList.Where(c => c.X == x && c.Y == y).Count() > 0) {
                     continue;
                 } else {
                     //将超出范围的地砖填充到新的位置上,并重置它们的x,y点位坐标值
                     tempTiles[index].Code = Code;
                     tempTiles[index].X = x;
                     tempTiles[index].Y = y;
                     //下载实际图片
                     OpenReadCompletedEventHandler handler = null;
                     ParallelDownloader downloader = new ParallelDownloader();
                     downloader.OpenReadCompleted += handler = (s, e) => {
                         (s as ParallelDownloader).OpenReadCompleted -= handler;
                         string[] args = e.UserState.ToString().Split('_');
                         int tempIndex = Convert.ToInt32(args[0]), tempX = Convert.ToInt32(args[1]), tempY = Convert.ToInt32(args[2]);
                         if (tempTiles[tempIndex].Code == Code && tempTiles[tempIndex].X == tempX && tempTiles[tempIndex].Y == tempY) {
                             tiles[tempTiles[tempIndex].Num].Source = GlobalMethod.GetImage(string.Format("Space/{0}/Map/{1}_{2}.jpg", Code, tempX, tempY),UriType.Web);
                             Canvas.SetLeft(tiles[tempTiles[tempIndex].Num], tempX * tileSize.X);
                             Canvas.SetTop(tiles[tempTiles[tempIndex].Num], tempY * tileSize.Y);
                         }
                     };
                     downloader.OpenReadAsync(GlobalMethod.WebPath(string.Format("Space/{0}/Map/{1}_{2}.jpg", Code, x, y)), DownloadPriority.Highest, string.Format("{0}_{1}_{2}", index, x, y), true, 3000);
                     index++;
                 }
             }
         }
         //按区域显示/隐藏动画和遮挡
         SetAnimationVisibleTo(leader);
         SetMaskVisibleTo(leader);
     }
 }