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

Source: Internet
Author: User
Tags implement pow silverlight

C # development Wpf/silverlight animation and games series (Game Course): (30) Great master – the reincarnation of the Magnificent classics

From red and white machines to PS3, from 286 to Pentium n cores; Remember the memory of a child? Play with Playmates. The classics of the past have been translated into ephemeral, are the mythical characters still hovering in your dreams? UO created a new era of online gaming, the virtual world opened the magic gorgeous heart, so I firmly believe that with their own hands to open this magnificent reincarnation!

In the traditional MMORPG game, the type of magic is roughly divided into: Single attack magic, group attack Magic, auxiliary magic, Map magic and so on, which can be subdivided into a single attack with the process (flying arrows), without process (such as lightning), a number of monomer, and so on; group attack magic on more, to the circle of regional group attack as the mainstream, There are Polygon area group attack, shuttle group attack, multi-segment group attack and so on; auxiliary magic is mainly buff addition and reduction, such as adding blood, add defense, add attack, add shields and so on; Map magic is mainly represented by traps, there are other such as transients, etc.

In this section I will explain the most gorgeous and the most easy to implement the circle range of attack magic.

Magic control is the prerequisite to achieve magic, so we first set up a magic control named Qxmagic, and give it some attributes (the specific content to see the source). All of these attributes have a comment here is not known; The key is that each spell also has a lifeline that plays and triggers the attack, because the magic is made up of a series of frames from the generation to the end:

With the magic control, then consider how to implement the function. In the usual MMORPG, we actively cast magic there are two ways: the right mouse button or keyboard shortcuts, the process is actually the same, then this section with the right mouse button cast magic as an example to explain.

First we need to register the right mouse button event for the game form and write it here:

private void Window_MouseRightButtonDown(object sender, MouseButtonEventArgs e) {

 if (Leader.Action == Actions.Death) { return; }

 ……

 Leader.MagicTarget = p;

 //假如点击的地方太远则先跑到施法范围再施法,否则直接施法

 if (Super.InCircle(Leader.X, Leader.Y, p.X, p.Y, Leader.MagicRange)) {

  ChangeDirection(Leader, p);

  DoMagic(Leader);

 } else {

    Leader.IsMagicMove = true;

   double n = Math.Sqrt(Math.Pow(p.Y - Leader.Y, 2) + Math.Pow(p.X - Leader.X, 2));

   double x = p.X - (p.X - Leader.X) * Leader.MagicRange / n;

   double y = p.Y - (p.Y - Leader.Y) * Leader.MagicRange / n;

   MoveTo(Leader, new Point(x, y));

 }

}

Related Article

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.