WEB开发网
开发学院图形图像Flash silverlight2 游戏 1 你能坚持多少秒 阅读

silverlight2 游戏 1 你能坚持多少秒

 2009-05-15 12:08:26 来源:WEB开发网   
核心提示: Enemy.xaml.cs 1using System; 2using System.Collections.Generic; 3using System.Linq; 4using System.Net; 5using System.Windows; 6using System.Windo

Enemy.xaml.cs

  1using System;
  2using System.Collections.Generic;
  3using System.Linq;
  4using System.Net;
  5using System.Windows;
  6using System.Windows.Controls;
  7using System.Windows.Documents;
  8using System.Windows.Input;
  9using System.Windows.Media;
 10using System.Windows.Media.Animation;
 11using System.Windows.Shapes;
 12
 13namespace Movebox
 14{
 15    public partial class Enemy : UserControl
 16    {
 17        //容器宽度高度
 18        public int ContainerWidth { get; set; }
 19        public int ContainerHeight { get; set; }
 20
 21        public Enemy()
 22        {
 23            InitializeComponent();
 24            this.Speed = 1.001;
 25
 26        }
 27
 28        public double X
 29        {
 30            set
 31            {
 32                rectangle_enemy1_point.X = value;
 33            }
 34            get { return rectangle_enemy1_point.X; }
 35        }
 36
 37        public double Y
 38        {
 39            set
 40            {
 41                rectangle_enemy1_point.Y=value;
 42            }
 43            get { return rectangle_enemy1_point.Y; }
 44        }
 45
 46        /**//// <summary>
 47        /// 设置尺寸
 48        /// </summary>
 49        /// <param name="_w">宽</param>
 50        /// <param name="_h">高</param>
 51        public void Dimension(double _w, double _h)
 52        {
 53            this.Width = _w;
 54            this.Height = _h;
 55            rectangle_enemy1.Width = _w;
 56            rectangle_enemy1.Height = _h;
 57        }
 58
 59        public double Speed { get; set; }
 60
 61        private bool hDirect=true;
 62        private bool wDirect=true;
 63
 64        public bool Move
 65        {
 66            set
 67            {
 68                if (value)
 69                {
 70                    if (this.Y <= 0) hDirect = true;
 71
 72                    if (hDirect && (this.Y < (ContainerHeight - this.Height)))
 73                    {
 74                        this.Y += Speed * 3;
 75                       
 76                    }
 77                    else
 78                    {
 79                        this.Y -= Speed * 3;
 80                        hDirect = false;
 81                       
 82                    }
 83
 84                    if (this.X <= 0) wDirect = true;
 85
 86                    if (wDirect && (this.X < (ContainerWidth - this.Width)))
 87                    {
 88                        this.X += Speed * 5;
 89
 90                    }
 91                    else
 92                    {
 93                        this.X -= Speed*5;
 94                        wDirect = false;
 95
 96                    }
 97
 98                }
 99               
100            }
101        }
102
103      
104    }
105}
106

上一页  1 2 3 4 5  下一页

Tags:silverlight 游戏 坚持

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接