Пример #1
0
 void CreateSubMagic(RoleBase caster,RoleBase startTarget, RoleBase endTarget, Space space, MagicArgs args)
 {
     AnimationBase animation = new AnimationBase() { Code = args.ResCode, Z = startTarget.Z + 1 };
     double offsetStartY = (startTarget.State == States.Riding ? (startTarget.Profession == Professions.Taoist ? 130 : 110) : 60) * args.Scale;
     double offsetEndY = (endTarget.State == States.Riding ? 100 : 50) * args.Scale;
     Point from = new Point(startTarget.Position.X, startTarget.Position.Y - offsetStartY);
     Point to = new Point(endTarget.Position.X, endTarget.Position.Y - offsetEndY);
     RotateTransform rotateTransform = new RotateTransform() {
         CenterX = animation.Center.X,
         CenterY = animation.Center.Y,
         Angle = GlobalMethod.GetAngle(to.Y - from.Y, to.X - from.X)
     };
     ScaleTransform scaleTransform = new ScaleTransform() {
         CenterX = animation.Center.X,
         CenterY = animation.Center.Y,
         ScaleX = (GlobalMethod.GetDistance(startTarget.Position, endTarget.Position) / Convert.ToInt32(args.Tag)),
         ScaleY = args.Scale
     };
     TransformGroup transformGroup = new TransformGroup();
     transformGroup.Children.Add(scaleTransform);
     transformGroup.Children.Add(rotateTransform);
     animation.RenderTransform = transformGroup;
     animation.Position = from;
     space.AddUIElement(animation);
     EventHandler handler = null;
     animation.End += handler = delegate {
         animation.End -= handler;
         space.RemoveAnimation(animation);
     };
     animation.HeartStart();
 }
Пример #2
0
 /// <summary>
 /// 添加动画
 /// </summary>
 /// <param name="animation">动画对象</param>
 public void AddAnimation(AnimationBase animation)
 {
     animationList.Add(animation);
     space.Children.Add(animation);
     //ID不为0的动画则拥有阴影,且位置设定为障碍
     if (animation.ID != 0) {
         AddShadow(animation.ID, ShadowTypes.Simple);
         SetShadowVisibleTo(animation);
         SetShadowPositionTo(animation);
         Point coordinate = terrain.GetCoordinateFromPosition(animation.Position);
         terrain.Matrix[(int)coordinate.X, (int)coordinate.Y] = 0;
     }
     animation.HeartStart();
 }
Пример #3
0
 void CreateAnimation(AnimationBase animation, int code, Point position)
 {
     animation.Code = code;
     animation.Position = position;
     EventHandler handler = null;
     animation.Disposed += handler = delegate {
         animation.Disposed -= handler;
         this.Children.Remove(animation);
     };
     this.Children.Add(animation);
     animation.HeartStart();
 }
Пример #4
0
        void queueDownloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            this.Width = Application.Current.Host.Content.ActualWidth;
            this.Height = Application.Current.Host.Content.ActualHeight;

            ImageButton faceList = new ImageButton() {
                TotalWidth = 162,
                TotalHeight = 27,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/18.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(42),
                TextStyle = Application.Current.Resources["TextStyle5"] as Style,
                TextHasEffect = false,
                TextBrush = new SolidColorBrush(Colors.Black),
            };
            this.Children.Add(faceList);
            Canvas.SetLeft(faceList, 15);
            Canvas.SetTop(faceList, 85);

            for (int i = 0; i < roleMax; i++) {
                roleList[i] = new ImageButton() {
                    Tag = "",
                    TotalWidth = 168,
                    TotalHeight = 54,
                    Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/4.png", UriType.Web), Stretch = Stretch.None },
                    TextStyle = Application.Current.Resources["TextStyle6"] as Style,
                    TextHasEffect = true,
                    TextEffectColor = Colors.Red,
                    TextBrush = new SolidColorBrush(Colors.White),
                    TextHoverBrush = new SolidColorBrush(Colors.Yellow),
                };
                this.Children.Add(roleList[i]);
                Canvas.SetLeft(roleList[i], 10);
                Canvas.SetTop(roleList[i], 120 + 56 * i);
                Canvas.SetZIndex(roleList[i], 3);
                roleList[0].Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/20.png", UriType.Web) };
                roleList[i].Click += (s1, e1) => {
                    ImageButton obj = s1 as ImageButton;
                    if (obj.Tag.ToString().Equals("")) { return; }
                    for (int j = 0; j <= roleList.GetUpperBound(0); j++) {
                        roleList[j].TextBrush = new SolidColorBrush(Colors.White);
                        roleList[j].Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/4.png", UriType.Web), };
                    }
                    obj.TextBrush = new SolidColorBrush(Color.FromArgb(255, 172, 255, 140));
                    obj.Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/20.png", UriType.Web), };

                    LoginManager.RoleName = obj.Tag.ToString();
                    ChangeRole(roles.Single(X => X.RoleName == LoginManager.RoleName));
                };
            }
            roleList[0].TextBrush = new SolidColorBrush(Color.FromArgb(255, 172, 255, 140));

            aura = new AnimationBase() { Code = 71, Loop = true, IsHitTestVisible = false, Position =new Point(258,380)  };
            this.Children.Add(aura);
            aura.HeartStart();

            this.Children.Add(roleModel);
            Canvas.SetLeft(roleModel, 220);
            Canvas.SetTop(roleModel, 100);

            Image roleData = new Image() { Source = GlobalMethod.GetImage("UI/19.png", UriType.Web), };
            this.Children.Add(roleData);
            Canvas.SetLeft(roleData, 582);
            Canvas.SetTop(roleData, 40);

            this.Children.Add(avatar);
            Canvas.SetLeft(avatar, 654);
            Canvas.SetTop(avatar, 70);

            TextBlock text0 = new TextBlock() { Text = GetLanguagePackContent(43), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text1 = new TextBlock() { Text = GetLanguagePackContent(44), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text2 = new TextBlock() { Text = GetLanguagePackContent(45), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text3 = new TextBlock() { Text = GetLanguagePackContent(46), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text4 = new TextBlock() { Text = GetLanguagePackContent(47), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text5 = new TextBlock() { Text = GetLanguagePackContent(48), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text6 = new TextBlock() { Text = GetLanguagePackContent(49), Style = Application.Current.Resources["TextStyle7"] as Style };
            this.Children.Add(text0); Canvas.SetLeft(text0, 680); Canvas.SetTop(text0, 158);
            this.Children.Add(text1); Canvas.SetLeft(text1, 645); Canvas.SetTop(text1, 192);
            this.Children.Add(text2); Canvas.SetLeft(text2, 714); Canvas.SetTop(text2, 192);
            this.Children.Add(text3); Canvas.SetLeft(text3, 680); Canvas.SetTop(text3, 226);
            this.Children.Add(text4); Canvas.SetLeft(text4, 680); Canvas.SetTop(text4, 258);
            this.Children.Add(text5); Canvas.SetLeft(text5, 670); Canvas.SetTop(text5, 292);
            this.Children.Add(text6); Canvas.SetLeft(text6, 658); Canvas.SetTop(text6, 326);

            Grid grid0 = new Grid() { Width = 130 }; this.Children.Add(grid0); Canvas.SetLeft(grid0, 626); Canvas.SetTop(grid0, 173);
            Grid grid1 = new Grid() { Width = 60 }; this.Children.Add(grid1); Canvas.SetLeft(grid1, 626); Canvas.SetTop(grid1, 207);
            Grid grid2 = new Grid() { Width = 60 }; this.Children.Add(grid2); Canvas.SetLeft(grid2, 694); Canvas.SetTop(grid2, 207);
            Grid grid3 = new Grid() { Width = 130 }; this.Children.Add(grid3); Canvas.SetLeft(grid3, 626); Canvas.SetTop(grid3, 241);
            Grid grid4 = new Grid() { Width = 130 }; this.Children.Add(grid4); Canvas.SetLeft(grid4, 626); Canvas.SetTop(grid4, 273);
            Grid grid5 = new Grid() { Width = 130 }; this.Children.Add(grid5); Canvas.SetLeft(grid5, 626); Canvas.SetTop(grid5, 307);
            Grid grid6 = new Grid() { Width = 130 }; this.Children.Add(grid6); Canvas.SetLeft(grid6, 626); Canvas.SetTop(grid6, 341);
            roleName = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            occupation = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            level = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            experience = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            map = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            time = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            ip = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            grid0.Children.Add(roleName);
            grid1.Children.Add(occupation);
            grid2.Children.Add(level);
            grid3.Children.Add(experience);
            grid4.Children.Add(map);
            grid5.Children.Add(time);
            grid6.Children.Add(ip);

            ImageButton startGame = new ImageButton() {
                TotalWidth = 80,
                TotalHeight = 25,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/3.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(50),
                TextStyle = Application.Current.Resources["TextStyle1"] as Style,
                TextHasEffect = true,
                TextEffectColor = Colors.Black,
                TextBrush = new SolidColorBrush(Color.FromArgb(255, 48, 83, 96)),
                TextHoverBrush = new SolidColorBrush(Colors.White),
            };
            startGame.Click += (s1, e1) => {
                Dispose(this,null);
                if (GameStart != null) { GameStart(this, e1); }
            };
            ImageButton cannel = new ImageButton() {
                TotalWidth = 80,
                TotalHeight = 25,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/3.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(51),
                TextStyle = Application.Current.Resources["TextStyle1"] as Style,
                TextHasEffect = true,
                TextEffectColor = Colors.Black,
                TextBrush = new SolidColorBrush(Color.FromArgb(255, 48, 83, 96)),
                TextHoverBrush = new SolidColorBrush(Colors.White),
            };
            cannel.Click += (s1, e1) => {
                Dispose(this, null);
                if (Cannel != null) { Cannel(this, e1); }
            };
            ImageButton newRole = new ImageButton() {
                TotalWidth = 80,
                TotalHeight = 25,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/3.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(52),
                TextStyle = Application.Current.Resources["TextStyle1"] as Style,
                TextHasEffect = true,
                TextEffectColor = Colors.Black,
                TextBrush = new SolidColorBrush(Color.FromArgb(255, 48, 83, 96)),
                TextHoverBrush = new SolidColorBrush(Colors.White),
            };
            newRole.Click += (s1, e1) => {
                LoginManager.loading.Show();
                WCFServiceClient wcf1 = new WCFServiceClient();
                wcf1.GetUserRoleNumAsync(LoginManager.UserName);
                wcf1.GetUserRoleNumCompleted += (s2, e2) => {
                    if (e2.Result == 6) {
                        LoginManager.loginTip.Show(GetLanguagePackContent(53), LoginTipMode.TipOnly);
                        LoginManager.loading.Hide();
                    } else {
                        Dispose(this, null);
                        if (CreateRole != null) { CreateRole(this, e1); }
                    }
                    wcf1.CloseAsync();
                };
            };
            delRole = new ImageButton() {
                TotalWidth = 80,
                TotalHeight = 25,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/3.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(54),
                TextStyle = Application.Current.Resources["TextStyle1"] as Style,
                TextHasEffect = true,
                TextEffectColor = Colors.Black,
                TextBrush = new SolidColorBrush(Color.FromArgb(255, 48, 83, 96)),
                TextHoverBrush = new SolidColorBrush(Colors.White),
            };
            delRole.Click += (s1, e1) => {
                if (roles.Count() == 0) { return; }
                LoginManager.loginTip.Show(GetLanguagePackContent(59), LoginTipMode.ConfirmOrCannel);
                LoginManager.loginTip.OK += new MouseButtonEventHandler(dialog_OK);
            };
            this.Children.Add(startGame); Canvas.SetLeft(startGame, 650); Canvas.SetTop(startGame, 380);
            this.Children.Add(cannel); Canvas.SetLeft(cannel, 650); Canvas.SetTop(cannel, 415);
            this.Children.Add(newRole); Canvas.SetLeft(newRole, 650); Canvas.SetTop(newRole, 450);
            this.Children.Add(delRole); Canvas.SetLeft(delRole, 650); Canvas.SetTop(delRole, 485);

            base.OnResourceReady(this, e);
            LoadRoles(LoginManager.UserName);
        }
Пример #5
0
 /// <summary>
 /// 添加特效
 /// </summary>
 /// <param name="animation">特效动画</param>
 /// <param name="type">特效类型</param>
 public void AddEffect(AnimationBase animation, EffectTypes type)
 {
     RemoveEffect(type);
     effects.Add(type, animation);
     this.Children.Add(animation);
     animation.HeartStart();
 }
Пример #6
0
 public Bullet(BulletDatas bulletData)
 {
     switch (bulletType = bulletData.Type) {
         case BulletTypes.Common:
             this.Source = GlobalMethod.GetImage(string.Format("Bullet/{0}.png", bulletData.Code), UriType.Project);
             Offset = new Point(Source.PixelWidth, Source.PixelHeight / 2);
             break;
         case BulletTypes.Animation:
             AnimationBase animation = new AnimationBase() { Code = bulletData.Code, Loop = bulletData.Loop };
             animation.HeartStart();
             this.Children.Add(animation);
             Offset = new Point(animation.Center.X * 2, animation.Center.Y);
             break;
     }
 }
Пример #7
0
        void queueDownloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            this.Width = 910;
            this.Height = 590;

            ImageButton faceList = new ImageButton() {
                TotalWidth = 162,
                TotalHeight = 27,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/18.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(25),
                TextStyle = Application.Current.Resources["TextStyle5"] as Style,
                TextHasEffect = false,
                TextBrush = new SolidColorBrush(Colors.Black),
            };
            this.Children.Add(faceList);
            Canvas.SetLeft(faceList, 0);
            Canvas.SetTop(faceList, 85);

            avatarSelector = new AnimationBase() { Code = 70, Loop = true, Z = 10, IsHitTestVisible = false };
            this.Children.Add(avatarSelector);
            avatarSelector.HeartStart();

            for (int i = 0; i <= avatar.GetUpperBound(0); i++) {
                avatar[i] = new ImageButton() {
                    Code = i,
                    TotalWidth = 74,
                    TotalHeight = 74,
                    BodyHasEffect = true,
                    BodyEffectColor = Colors.Blue,
                };
                this.Children.Add(avatar[i]);
                Canvas.SetLeft(avatar[i], 40);
                Canvas.SetTop(avatar[i], 130 + i * 85);
                Canvas.SetZIndex(avatar[i], 3);
                avatar[i].MouseLeftButtonDown += (s1, e1) => {
                    ImageButton obj =s1 as ImageButton;
                    faceCode = obj.Code;
                    avatarSelector.Visibility = Visibility.Visible;
                    avatarSelector.IsVisible = true;
                    avatarSelector.Position = obj.Position;
                };
            }
            ShowSexFace(Sex.male);
            avatarSelector.Position = avatar[0].Position;

            light = new AnimationBase { Code = 72, Loop = true, Z = 4, IsHitTestVisible = false };
            this.Children.Add(light);
            light.HeartStart();
            light.Position = new Point(190, 75);

            this.Children.Add(maleModel);
            Canvas.SetLeft(maleModel, 80);
            Canvas.SetTop(maleModel, 120);
            maleModel.MouseLeftButtonDown += (s1, e1) => {
                //waiting.Show(); Canvas.SetLeft(waiting, -400); Canvas.SetTop(waiting, 100);
                ShowSexFace(Sex.male);
                ShowRoleModel(profession, Sex.male);
                light.Position = new Point(190, 75);
            };
            this.Children.Add(femaleModel);
            Canvas.SetLeft(femaleModel, 270);
            Canvas.SetTop(femaleModel, 120);
            ShowRoleModel(profession, Sex.male);
            femaleModel.MouseLeftButtonDown += (s1, e1) => {
                //waiting.Show(); Canvas.SetLeft(waiting, -200); Canvas.SetTop(waiting, 100);
                ShowSexFace(Sex.female);
                ShowRoleModel(profession, Sex.female);
                light.Position = new Point(385, 75);
            };

            for (int i = 0; i <= professionSelector.GetUpperBound(0); i++) {
                professionSelector[i] = new ImageButton() {
                    Tag = i,
                    TotalWidth = 153,
                    TotalHeight = 32,
                    Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/5.png", UriType.Web), Stretch = Stretch.None },
                    TextStyle = Application.Current.Resources["TextStyle3"] as Style,
                    TextHasEffect = true,
                    TextEffectColor = Colors.Red,
                    TextBrush = new SolidColorBrush(Colors.White),
                    TextHoverBrush = new SolidColorBrush(Colors.Yellow),
                    Z  = 3,
                };
                this.Children.Add(professionSelector[i]);
                professionSelector[i].Position = new Point(600, 70 + 50 * i);
                professionSelector[0].Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/9.png", UriType.Web) };
                professionSelector[i].Click += (s1, e1) => {
                    for (int j = 0; j <= professionSelector.GetUpperBound(0); j++) {
                        professionSelector[j].Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/5.png", UriType.Web) };
                    }
                    ImageButton obj = s1 as ImageButton;
                    obj.Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/9.png", UriType.Web) };
                    ShowRoleModel((Professions)obj.Tag, sex);
                };
            }
            professionSelector[0].Text = GetLanguagePackContent(28);
            professionSelector[1].Text = GetLanguagePackContent(27);
            professionSelector[2].Text = GetLanguagePackContent(26);
            professionSelector[3].Text = GetLanguagePackContent(29);

            Image descriptionHead = new Image() { Source = GlobalMethod.GetImage("UI/6.png", UriType.Web) };
            Grid descriptionBody = new Grid() {
                Width = 221,
                Height = 220,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/7.png", UriType.Web) }
            };
            descriptionBody.Children.Add(description);
            Image descriptionFoot = new Image() { Source = GlobalMethod.GetImage("UI/8.png", UriType.Web) };
            this.Children.Add(descriptionHead);
            this.Children.Add(descriptionFoot);
            this.Children.Add(descriptionBody);
            Canvas.SetLeft(descriptionHead, 570);
            Canvas.SetTop(descriptionHead, 280);
            Canvas.SetLeft(descriptionBody, 570);
            Canvas.SetTop(descriptionBody, 285);
            Canvas.SetLeft(descriptionFoot, 570);
            Canvas.SetTop(descriptionFoot, 455);

            TextBlock text0 = new TextBlock() { Text = GetLanguagePackContent(30), Foreground = new SolidColorBrush(Colors.White), FontSize = 18, FontWeight = FontWeights.SemiBold };
            this.Children.Add(text0);
            Canvas.SetLeft(text0, 200);
            Canvas.SetTop(text0, 545);
            TextBox roleName = new TextBox() { Width = 240, Background = new SolidColorBrush(Color.FromArgb(255, 57, 57, 57)), Style = Application.Current.Resources["TextStyle2"] as Style };
            this.Children.Add(roleName);
            Canvas.SetLeft(roleName, 285);
            Canvas.SetTop(roleName, 548);

            ImageButton createRole = new ImageButton() {
                TotalWidth = 80,
                TotalHeight = 25,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/3.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(31),
                TextStyle = Application.Current.Resources["TextStyle1"] as Style,
                TextHasEffect = true,
                TextEffectColor = Colors.Black,
                TextBrush = new SolidColorBrush(Color.FromArgb(255, 48, 83, 96)),
                TextHoverBrush = new SolidColorBrush(Colors.White),
            };
            this.Children.Add(createRole);
            Canvas.SetLeft(createRole, 550);
            Canvas.SetTop(createRole, 547);
            //创建角色
            createRole.MouseLeftButtonDown += (s1, e1) => {
                if (roleName.Text.Trim().Equals("") || roleName.Text.Trim().Length > 20) { LoginManager.loginTip.Show(GetLanguagePackContent(40), LoginTipMode.TipOnly); return; }
                LoginManager.loading.Show();
                WCFServiceClient wcfServiceClient = new WCFServiceClient();
                wcfServiceClient.CheckRoleExistAsync(roleName.Text.Trim());
                wcfServiceClient.CheckRoleExistCompleted += (s2, e2) => {
                    if (e2.Result == 0) {
                        wcfServiceClient.InsertRoleAsync(LoginManager.UserName, roleName.Text.Trim(), (byte)faceCode, (byte)sex, (byte)profession, 1, 0, 1, Application.Current.Host.InitParams["ClientIP"], "");
                        wcfServiceClient.InsertRoleCompleted += (s3, e3) => {
                            LoginManager.loading.Hide();
                            if (e3.Result != 0) {
                                LoginManager.loginTip.Show(string.Format("{0} {1}", roleName.Text.Trim(), GetLanguagePackContent(58)), LoginTipMode.TipOnly);
                                MouseButtonEventHandler handler = null;
                                LoginManager.loginTip.OK += handler = delegate {
                                    LoginManager.loginTip.OK -= handler;
                                    Dispose(this, null);
                                    if (RoleCreated != null) { RoleCreated(this, null); }
                                };
                                e1.Handled = true;
                            } else {
                                LoginManager.loginTip.Show(GetLanguagePackContent(38), LoginTipMode.TipOnly);
                            }
                        };
                    } else {
                        LoginManager.loading.Hide();
                        LoginManager.loginTip.Show(GetLanguagePackContent(39), LoginTipMode.TipOnly);
                    }
                    wcfServiceClient.CloseAsync();
                };
            };
            ImageButton cannel = new ImageButton() {
                TotalWidth = 80,
                TotalHeight = 25,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/3.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(51),
                TextStyle = Application.Current.Resources["TextStyle1"] as Style,
                TextHasEffect = true,
                TextEffectColor = Colors.Black,
                TextBrush = new SolidColorBrush(Color.FromArgb(255, 48, 83, 96)),
                TextHoverBrush = new SolidColorBrush(Colors.White),
            };
            this.Children.Add(cannel);
            Canvas.SetLeft(cannel, 650);
            Canvas.SetTop(cannel, 547);
            cannel.Click += (s1, e1) => {
                Dispose(this, null);
                if (Cannel != null) {  Cannel(this, e1); }
            };
            base.OnResourceReady(this, e);
        }
Пример #8
0
 /// <summary>
 /// 切换角色模型
 /// </summary>
 void ShowRoleModel(Professions profession, Sex sex)
 {
     if (this.profession == profession && this.sex == sex) { return; }
     this.profession = profession;
     this.sex = sex;
     roleAnimation.End -= roleAnimation_End;
     roleAnimation.Dispose(roleAnimation, null);
     switch (profession) {
         case Professions.Warrior:
             description.Text = GlobalMethod.GetParagraphText(GetLanguagePackContent(34), '|', "\r\t\t");
             if (sex == Sex.male) {
                 roleAnimation = new AnimationBase() { Code = 73, Loop = true, Z = 1, };
                 maleModel.Content = roleAnimation;
                 roleAnimation.HeartStart();
                 maleModel.IsHitTestVisible = false;
                 femaleModel.Content = new Image() { Source = GlobalMethod.GetImage("UI/11.png", UriType.Web), Stretch = Stretch.None };
                 Canvas.SetZIndex(femaleModel, 2);
                 femaleModel.IsHitTestVisible = true;
             } else {
                 maleModel.Content = new Image() { Source = GlobalMethod.GetImage("UI/10.png", UriType.Web), Stretch = Stretch.None };
                 Canvas.SetZIndex(maleModel, 2);
                 maleModel.IsHitTestVisible = true;
                 roleAnimation = new AnimationBase() { Code = 74, Loop = true, Z = 1, };
                 femaleModel.Content = roleAnimation;
                 roleAnimation.HeartStart();
                 femaleModel.IsHitTestVisible = false;
             }
             break;
         case Professions.Assassin:
             description.Text = GlobalMethod.GetParagraphText(GetLanguagePackContent(35), '|', "\r\t\t");
             if (sex == Sex.male) {
                 roleAnimation = new AnimationBase() { Code = 75, Loop = true, Z = 1, };
                 maleModel.Content = roleAnimation;
                 roleAnimation.HeartStart();
                 maleModel.IsHitTestVisible = false;
                 femaleModel.Content = new Image() { Source = GlobalMethod.GetImage("UI/13.png", UriType.Web), Stretch = Stretch.None };
                 Canvas.SetZIndex(femaleModel, 2);
                 femaleModel.IsHitTestVisible = true;
             } else {
                 maleModel.Content = new Image() { Source = GlobalMethod.GetImage("UI/12.png", UriType.Web), Stretch = Stretch.None };
                 Canvas.SetZIndex(maleModel, 2);
                 maleModel.IsHitTestVisible = true;
                 roleAnimation = new AnimationBase() { Code = 76, Loop = true, Z = 1, };
                 femaleModel.Content = roleAnimation;
                 roleAnimation.HeartStart();
                 femaleModel.IsHitTestVisible = false;
             }
             break;
         case Professions.Archer:
             description.Text = GlobalMethod.GetParagraphText(GetLanguagePackContent(36), '|', "\r\t\t");
             if (sex == Sex.male) {
                 roleAnimation = new AnimationBase() { Code = 77, Loop = true, Z = 1, };
                 maleModel.Content = roleAnimation;
                 roleAnimation.HeartStart();
                 maleModel.IsHitTestVisible = false;
                 femaleModel.Content = new Image() { Source = GlobalMethod.GetImage("UI/15.png", UriType.Web), Stretch = Stretch.None };
                 Canvas.SetZIndex(femaleModel, 2);
                 femaleModel.IsHitTestVisible = true;
             } else {
                 maleModel.Content = new Image() { Source = GlobalMethod.GetImage("UI/14.png", UriType.Web), Stretch = Stretch.None };
                 Canvas.SetZIndex(maleModel, 2);
                 maleModel.IsHitTestVisible = true;
                 roleAnimation = new AnimationBase() { Code = 78, Loop = true, Z = 1, };
                 femaleModel.Content = roleAnimation;
                 roleAnimation.HeartStart();
                 femaleModel.IsHitTestVisible = false;
             }
             break;
         case Professions.Taoist:
             description.Text = GlobalMethod.GetParagraphText(GetLanguagePackContent(37), '|', "\r\t\t");
             if (sex == Sex.male) {
                 roleAnimation = new AnimationBase() { Code = 79, Loop = true, Z = 1, };
                 maleModel.Content = roleAnimation;
                 roleAnimation.HeartStart();
                 maleModel.IsHitTestVisible = false;
                 femaleModel.Content = new Image() { Source = GlobalMethod.GetImage("UI/17.png", UriType.Web), Stretch = Stretch.None };
                 Canvas.SetZIndex(femaleModel, 2);
                 femaleModel.IsHitTestVisible = true;
             } else {
                 maleModel.Content = new Image() { Source = GlobalMethod.GetImage("UI/16.png", UriType.Web), Stretch = Stretch.None };
                 Canvas.SetZIndex(maleModel, 2);
                 maleModel.IsHitTestVisible = true;
                 roleAnimation = new AnimationBase() { Code = 80, Loop = true, Z = 1, };
                 femaleModel.Content = roleAnimation;
                 roleAnimation.HeartStart();
                 femaleModel.IsHitTestVisible = false;
             }
             break;
     }
     roleAnimation.End += new System.EventHandler(roleAnimation_End);
 }
Пример #9
0
 void CreateSubMagic(RoleBase caster, Space space, MagicArgs args, int index)
 {
     AnimationBase animation = new AnimationBase() { Code = args.ResCode,  Z = targets[index].Z + 1, Effect = shiftHue };
     double offsetStartY = (caster.State == States.Riding ? (caster.Profession == Professions.Taoist ? 130 : 110) : 60) * caster.Scale;
     double offsetEndY = (targets[index].State == States.Riding ? 100 : 50) * caster.Scale;
     Point from = index == 0 ? new Point(args.Position.X, args.Position.Y - offsetStartY) : temp;
     Point to = new Point(targets[index].Position.X, targets[index].Position.Y - offsetEndY);
     temp = to;
     RotateTransform rotateTransform = new RotateTransform() {
         CenterX = animation.Center.X,
         CenterY = animation.Center.Y,
         Angle = GlobalMethod.GetAngle(to.Y - from.Y, to.X - from.X)
     };
     ScaleTransform scaleTransform = new ScaleTransform() {
         CenterX = animation.Center.X,
         CenterY = animation.Center.Y,
         ScaleX = (GlobalMethod.GetDistance(index == 0 ? args.Position : targets[index - 1].Position, targets[index].Position) / 440), //440为其实体宽度,这里用了硬编码
         ScaleY = caster.Scale
     };
     TransformGroup transformGroup = new TransformGroup();
     transformGroup.Children.Add(scaleTransform);
     transformGroup.Children.Add(rotateTransform);
     animation.RenderTransform = transformGroup;
     animation.Position = from;
     space.AddUIElement(animation);
     EventHandler handler = null;
     animation.End += handler = delegate {
         animation.End -= handler;
         space.RemoveAnimation(animation);
         if (index == targets.Count) { targets.Clear(); }
     };
     animation.HeartStart();
 }