C # development Wpf/silverlight animation and games series Tutorials (Game Course): (33)

Source: Internet
Author: User
Tags silverlight

C # development Wpf/silverlight animation and game series Tutorials (Game Course): (33) The Magic effect decoration

In this section, I'll take the example of freezing magic to show you how to add beautiful special effects decorations to magic.

After the previous study, whether we have summed up a rule: the need to add additional things, the first thought is the user control; then we first create a user control named Qxdecoration. The next step is to prepare the material. Here I made 3 ice thorns for decoration:

Named 4-0,4-1,4-2, whose naming rules correspond to the magical type set in the previous section, that is, all frost-like magic can be decorated with it. Why do you use 3 sheets? In fact, one is enough, only the effect of each genie is frozen will be the same; by randomly extracting 1 sheets from these 3 sheets for decorative freeze effects will greatly increase the vividness of the picture, in the case of a large number of elves are frozen at the same time to produce a grand sense of momentum; If you can draw a similar ice thorn through the blend, then the vector based decorations will be able to arbitrarily stretch and change, show the effect will be more realistic and appropriate.

When you are ready, the code is simple to implement, first write the configuration into Config.xml:

<decoration code= "4" num= "3" duration= "2" centerx= "M" centery= "></Decoration>"

The next step is to attach the magic effect to the bottom of the victim's foot when the magic triggers the damage frame:

......
Additional effects Decoration
if (magic. Decorationcode!=-1 && canvas. FindName (String. Format ("decoration{0}", enemy. Name) = = = null) {
Loadxelement (String. Format ("decoration{0}", Magic. Decorationcode.tostring ()), Gettreenode (Systemconfig, "decoration", "Code", magic. Decorationcode.tostring ()));
XElement Decorationdata = Getxelement (string. Format ("decoration{0}", Magic. Decorationcode.tostring ()));
Random rm = new Random ();
Qxdecoration decoration = new Qxdecoration () {
Bodysource = GetImage (string. Format ("Decoration/{0}-{1}.png", magic. Decorationcode, RM. Next ((int) decorationdata.attribute ("Num")-1)),
CenterX = (double) Decorationdata.attribute ("CenterX"),
CenterY = (double) Decorationdata.attribute ("CenterY"),
X = enemy. X
Y = enemy. Y
Duration = (double) Decorationdata.attribute ("Duration"),
};
Canvas. Registername (String. Format ("decoration{0}", enemy. Name), decoration);
Canvas. Children.add (decoration);
}
......

The ice in the previous section was just slowing down the object Elf, so in this section I changed it to a freezing effect, similar to paralysis. Therefore, the disappearance of the frozen decoration is divided into two situations: one is removed when the freezing time is 0 o'clock; another is removed after the death of the Frozen Elf, the related logic I write in the source code, here is not listed.

Here's a picture of the effect:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.