protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.NavigationMode == NavigationMode.New) { //主题list添加 themes = new List <Theme>(); themes.Add(new Theme() { Name = "红色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 223, 0, 36)) }); themes.Add(new Theme() { Name = "绿色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 0, 128, 0)) }); themes.Add(new Theme() { Name = "黄色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 0)) }); themes.Add(new Theme() { Name = "蓝色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255)) }); themes.Add(new Theme() { Name = "深蓝", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 139)) }); themes.Add(new Theme() { Name = "钢蓝", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 176, 196, 222)) }); themes.Add(new Theme() { Name = "淡蓝", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 135, 206, 250)) }); themes.Add(new Theme() { Name = "黑色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)) }); themes.Add(new Theme() { Name = "橘色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 233, 113, 24)) }); themes.Add(new Theme() { Name = "土褐", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 85, 107, 47)) }); themes.Add(new Theme() { Name = "深绿", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 0, 100, 0)) }); themes.Add(new Theme() { Name = "绿黄", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 173, 255, 47)) }); themes.Add(new Theme() { Name = "金色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 255, 215, 0)) }); themes.Add(new Theme() { Name = "米色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 107, 142, 35)) }); themes.Add(new Theme() { Name = "橄榄", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 128, 128, 0)) }); themes.Add(new Theme() { Name = "卡其", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 240, 230, 140)) }); themes.Add(new Theme() { Name = "橙色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 255, 165, 0)) }); themes.Add(new Theme() { Name = "深橙", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 255, 140, 0)) }); themes.Add(new Theme() { Name = "暗灰", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 105, 105, 105)) }); themes.Add(new Theme() { Name = "灰色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 128, 128, 128)) }); themes.Add(new Theme() { Name = "深灰", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 169, 169, 169)) }); themes.Add(new Theme() { Name = "银白", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 192, 192, 192)) }); themes.Add(new Theme() { Name = "白烟", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 245, 245, 245)) }); themes.Add(new Theme() { Name = "栗色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 128, 0, 0)) }); themes.Add(new Theme() { Name = "白色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)) }); themes.Add(new Theme() { Name = "紫色", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 128, 0, 128)) }); themes.Add(new Theme() { Name = "中紫", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 147, 112, 219)) }); themes.Add(new Theme() { Name = "洋红", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 255, 0, 255)) }); themes.Add(new Theme() { Name = "粉红", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 255, 192, 203)) }); themes.Add(new Theme() { Name = "浅粉", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 255, 182, 193)) }); themes.Add(new Theme() { Name = "洋红", ThemeBackground = new SolidColorBrush(Color.FromArgb(255, 255, 0, 255)) }); lvTheme.ItemsSource = themes; lvTheme.Tapped += lvTheme_Tapped; lvThemeBackGround.ItemsSource = themes; lvThemeBackGround.Tapped += lvThemeBackGround_Tapped; //folder = ApplicationData.Current.LocalFolder; //StorageFile file = await folder.CreateFileAsync("1.xml"); //Stream stremReader = await folder.OpenStreamForReadAsync("1.xml"); //Stream streamWriter = await folder.OpenStreamForWriteAsync("1.xml", CreationCollisionOption.FailIfExists); setting = ApplicationData.Current.LocalSettings; if (!setting.Values.ContainsKey("score")) { setting.Values["score"] = "0"; } score = Convert.ToInt32((string)setting.Values["score"]); JiRu.Text = "最高记录:" + score.ToString() + "步"; //folder = await StorageFolder.GetFolderFromPathAsync(Package.Current.InstalledLocation.Path + @"\DataModel"); //file = await folder.GetFileAsync("1.xml"); ////file = await folder.CreateFileAsync("1.xml", CreationCollisionOption.ReplaceExisting);//.GetFileAsync("1.xml"); //streamWriter = await file.OpenStreamForWriteAsync(); //streamReader = await file.OpenStreamForReadAsync(); //xdoc2 = XDocument.Load(streamReader); //root2 = xdoc2.Root; //JiRu.Text = "最高记录:" + Convert.ToInt32(root2.Element("score").Attribute("sco").Value) + "步"; map = new Map(); allBlocks = new List <Block>(); allTags = new List <string>(); allBlockRectangles = new List <BlockRectangle>(); smallMans = new Block[10]; allSmallMans = new List <SmallMan>(); allTapRectangle = new List <BlockRectangle>(); allManPhoto = new List <SmallMan>(); //添加小人及背景色 for (int i = 0; i < 8; i++) { SmallMan smallman = new SmallMan(i); gridMansPhoto.Children.Add(smallman); Grid.SetColumn(smallman, i); allManPhoto.Add(smallman); smallman.Tag = (1000 + i).ToString();//这个可能用不到因为没有绑定到block;但先写上万一有用呢; smallman.Tapped += smallman_Tapped; } for (int i = 0; i < 10; i++) { //外层代码添加GridControlLeftRight到12个Rectangles.用来接收tapped事件控制左右走小人; BlockRectangle recTapped = new BlockRectangle(); recTapped.Opacity = 0; GridControlLeftRight.Children.Add(recTapped); Grid.SetColumn(recTapped, i); recTapped.Tag = i.ToString(); recTapped.Tapped += recTapped_Tapped; allTapRectangle.Add(recTapped); for (int j = 0; j < 3; j++) { BlockRectangle rectangle = new BlockRectangle(); GridMap.Children.Add(rectangle); Grid.SetRow(rectangle, j); Grid.SetColumn(rectangle, i); rectangle.DataContext = map[i, j]; rectangle.Tag = i.ToString() + j.ToString(); allTags.Add(rectangle.Tag);//allTags这个list似乎并没有用到。。。 allBlockRectangles.Add(rectangle); //rectangle.Tapped += rectangle_Tapped; SmallMan smallMan = new SmallMan(); GridSmallMan.Children.Add(smallMan); Grid.SetRow(smallMan, j); Grid.SetColumn(smallMan, i); smallMan.DataContext = map[i, j]; smallMan.Tag = i.ToString() + j.ToString(); allSmallMans.Add(smallMan); allBlocks.Add(map[i, j]);//初始化所有的格格list;或者不用这个。而转用smallManlist; } } } }
/// <summary> /// 最后一次改于20140608下午运行正常。。。未写小人下落登场动画 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void GameOverBtn_Click(object sender, RoutedEventArgs e) { GridJianBianDonHua.Visibility = Visibility.Visible; sbJianBianDonHua0.Begin(); //中线显示出来; CenterRec.Visibility = Visibility.Visible; //关于8个小矮人的判断动画; if (firstMan != null) { firstMan.StartSmall(); firstMan = null; //开始游戏了,把firstman变小,并且变成null以免影响到下一次的判断; } lvTheme.Visibility = Visibility.Collapsed; //开始游戏了。把左右彩条隐藏了; lvThemeBackGround.Visibility = Visibility.Collapsed; foreach (Block item in allBlocks) { item.IsVisSmallMan = false; } //这里写地图2里的小人被隐藏; foreach (Block item in allBlocks2) { item.IsVisSmallMan = false; } GameOverGrid.Visibility = Visibility.Collapsed; if (GameOverBtn.Label.ToString() == "开始学习") { GameOverBtn.Label = "再走一圈"; } if (visBlocks != null) { foreach (Block item in visBlocks)//将没显示的黑块再次变黑 { item.IsVis = true; } } //这里写地图2里隐藏格格再次变黑; if (visBlocks2 != null) { foreach (Block item in visBlocks2)//将没显示的黑块再次变黑 { item.IsVis = true; } } level = 1;//关卡计数器; //sw.Start();//秒表开始计时功能现在先不用随后如果想用反注释一下; //把所有的格子放到底端去; foreach (BlockRectangle item in allBlockRectangles) { item.Start0To1500(); } //这里写地图2里所有的格子放到底端去; foreach (BlockRectangle item in allBlockRectangles2) { item.Start0To1500(); } //二:生成uplists放到顶端 //2.1得到新一关的visBlocks。。。//将新一关的visBlocks设置为不可见。 visBlocks = map.EasyBlock(); await Task.Delay(1);//修复系统Bug; //这里写地图2获取到简单难度的隐藏格; visBlocks2 = map2.EasyBlock(); foreach (Block item in visBlocks) { item.IsVis = false; } //这里写地图2的所有获取到的隐藏格隐藏遍历隐藏起来; foreach (Block item in visBlocks2) { item.IsVis = false; } //2.2获取随机要压下来的Blocks//然后从1500放到-1500准备下一步的操作 BlockUplists = map.UpBlocks(visBlocks); foreach (Block itemBlock in BlockUplists) { BlockRectangle b1 = allBlockRectangles.First(retangle => retangle.Tag == itemBlock.Tag); b1.Start1500ToFu1500(); } //这里写地图2里随机获取要压下来的Blocks然后从顶放到底准备下一步的操作; BlockUplists2 = map2.UpBlocks(visBlocks2); foreach (Block itemBlock in BlockUplists2) { BlockRectangle b1 = allBlockRectangles2.First(retangle => retangle.Tag == itemBlock.Tag); b1.Start1500ToFu1500(); } //获取allblocks减去要压下来的blocks。。。得到FuBlockUplists; foreach (Block item in BlockUplists) { FuBlockUplists = allBlocks; FuBlockUplists.Remove(item); } //这里写地图2//获取allblocks2减去要压下来的blocks。。。得到FuBlockUplists2; foreach (Block item in BlockUplists2) { FuBlockUplists2 = allBlocks2; FuBlockUplists2.Remove(item); } await Task.Delay(100); //小人可以移动到的9个小人数组初始化 for (int i = 0; i < 5; i++) { smallMans[i] = map[i, map.smallManY[i]]; } //小人初始化;//初始化前先写一个下落的动画;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; smallMans[2].IsVisSmallMan = true; //这里写地图2小人可以移动到的5个小人数组初始化 for (int i = 0; i < 5; i++) { smallMans2[i] = map2[i, map2.smallManY[i]]; } smallMans2[2].IsVisSmallMan = true; //将-1500处的uplists放下到300处//将1500处的FuBlockUplists放到0 foreach (Block item in BlockUplists) { BlockRectangle b1 = allBlockRectangles.First(retangle => retangle.Tag == item.Tag); b1.StartFu1500ToFu300(); } foreach (Block item in FuBlockUplists) { BlockRectangle b1 = allBlockRectangles.First(retangle => retangle.Tag == item.Tag); b1.Start1500To0(); } //这里写地图2//将-1500处的uplists2放下到300处//将1500处的FuBlockUplists2放到0 foreach (Block item in BlockUplists2) { BlockRectangle b1 = allBlockRectangles2.First(retangle => retangle.Tag == item.Tag); b1.StartFu1500ToFu300(); } foreach (Block item in FuBlockUplists2) { BlockRectangle b1 = allBlockRectangles2.First(retangle => retangle.Tag == item.Tag); b1.Start1500To0(); } //把Uplists加回到allBlocks; foreach (Block item in BlockUplists) { allBlocks.Add(item); } //这里地图2把Uplists2加回到allBlocks2; foreach (Block item in BlockUplists2) { allBlocks2.Add(item); } FromFu1500ToFu300.Begin(); From1500To0.Begin(); }
/// <summary> /// 最后一次改于20140608下午运行正常。。。未写小人下落登场动画;;;;;;;;;;;;;;;;;;;;;;;;;; /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void GameOverBtn_Click(object sender, RoutedEventArgs e) { if (firstMan != null) { firstMan.StartSmall(); firstMan = null; //开始游戏了,把firstman变小,并且变成null以免影响到下一次的判断; } lvTheme.Visibility = Visibility.Collapsed; //开始游戏了。把左右彩条隐藏了; lvThemeBackGround.Visibility = Visibility.Collapsed; //GameOverScore.DataContext = sw; //txtbScore.DataContext = sw; //这里添加了所有小人被挂的语句·············································· foreach (Block item in allBlocks) { item.IsVisSmallMan = false; } GameOverGrid.Visibility = Visibility.Collapsed; if (GameOverBtn.Label.ToString() == "开始学习") { GameOverBtn.Label = "再走一圈"; } //所有黑块变黑。。。小人变没。。。 if (visBlocks != null) { foreach (Block item in visBlocks)//将没显示的黑块再次变黑 { item.IsVis = true; } } level = 1; //秒表开始计时; sw.Start(); //把所有的格子放到底端去; foreach (BlockRectangle item in allBlockRectangles) { item.Start0To1500(); } //二:生成uplists放到顶端 //2.1得到新一关的visBlocks。。。//将新一关的visBlocks设置为不可见。 if (level <= 4) { visBlocks = map.EasyBlock(); } else if (level <= 10) { visBlocks = map.MediumBlock(); } else { visBlocks = map.HardBlock(); } foreach (Block item in visBlocks) { item.IsVis = false; } //2.2获取随机要压下来的Blocks//然后从1500放到-1500准备下一步的操作 BlockUplists = map.UpBlocks(visBlocks); foreach (Block itemBlock in BlockUplists) { BlockRectangle b1 = allBlockRectangles.First(retangle => retangle.Tag == itemBlock.Tag); b1.Start1500ToFu1500(); } //获取allblocks减去要压下来的blocks。。。得到FuBlockUplists; foreach (Block item in BlockUplists) { FuBlockUplists = allBlocks; FuBlockUplists.Remove(item); } await Task.Delay(100); //小人可以移动到的12个小人数组初始化 for (int i = 0; i < 10; i++) { smallMans[i] = map[i, map.smallManY[i]]; } //小人初始化;//初始化前先写一个下落的动画;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; smallMans[4].IsVisSmallMan = true; //将-1500处的uplists放下到300处//将1500处的FuBlockUplists放到0 foreach (Block item in BlockUplists) { BlockRectangle b1 = allBlockRectangles.First(retangle => retangle.Tag == item.Tag); b1.StartFu1500ToFu300(); } foreach (Block item in FuBlockUplists) { BlockRectangle b1 = allBlockRectangles.First(retangle => retangle.Tag == item.Tag); b1.Start1500To0(); } //把Uplists加回到allBlocks; foreach (Block item in BlockUplists) { allBlocks.Add(item); } FromFu1500ToFu300.Begin(); From1500To0.Begin(); }