Beispiel #1
0
        /// <summary>
        /// 同Draw,但精灵不显示
        /// </summary>
        /// <returns>
        /// 创建的精灵
        /// </returns>
        /// <param name='name'>
        /// 精灵名称
        /// </param>
        /// <param name='path'>
        /// 纹理地址
        /// </param>
        /// <param name='vector'>
        /// 精灵坐标
        /// </param>
        /// <param name='cutImage'>
        /// 切分的块数
        /// </param>
        /// <param name='showPiece'>
        /// 显示的图片部分坐标
        /// </param>
        public SpriteX LoadImage(Layer layer, string name, string path, Vector2 vector, Vector2i cutImage, Vector2i showPiece)
        {
            SpriteX sprite = DrawImage(layer, name, path, vector, cutImage, showPiece);

            sprite.Visible = false;
            return(sprite);
        }
        public DrawBoundBox(Node node)
            : base(node)
        {
            SpriteX p;
            //			for(int i=0; i<4;i++)
            //			{
            //				p = new SpriteX(this,"Battles//primitive.png",
            //				                new Vector2(-9999,-9999));
            //				p.CenterSprite(TRS.Local.Center);
            //				p.Color = new Vector4(37 / 255f, 255 / 255f, 28 / 255f, 255f / 255f);
            //				p.Scale =new Vector2(0.7f,0.7f);
            //				aabbPoints.Add(p);
            //			}

            //			for(int i=0; i<4;i++)
            //			{
            //				p = new SpriteX(this,"Battles//primitive.png",
            //				                new Vector2(-9999,-9999));
            //				p.CenterSprite(TRS.Local.Center);
            //				p.Scale =new Vector2(0.7f,0.7f);
            //				p.Color = new Vector4(227 / 255f, 64 / 255f, 255 / 255f, 255f / 255f);
            //				obbPoints.Add(p);
            //			}
            //
            for(int i=0; i<8;i++)
            {
                p = new SpriteX("Battles//primitive.png",
                                new Vector2(-9999,-9999));
                p.ChangeFather(this);
                p.CenterSprite(TRS.Local.Center);
                p.Scale =new Vector2(0.7f,0.7f);
                p.Color = new Vector4(52 / 255f, 150 / 255f, 255 / 255f, 255f / 255f);
                circlePoints.Add(p);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 同Draw,但精灵不显示
        /// </summary>
        /// <returns>
        /// 创建的精灵
        /// </returns>
        /// <param name='name'>
        /// 精灵名称
        /// </param>
        /// <param name='path'>
        /// 纹理地址
        /// </param>
        /// <param name='vector'>
        /// 精灵坐标
        /// </param>
        public SpriteX LoadImage(Layer layer, string name, string path, Vector2 vector)
        {
            SpriteX sprite = DrawImage(layer, name, path, vector);

            sprite.Visible = false;
            return(sprite);
        }
Beispiel #4
0
        /// <summary>
        /// 绘制一个新的精灵,可设置精灵坐标以及进行切分
        /// </summary>
        /// <returns>
        /// 创建的精灵
        /// </returns>
        /// <param name='name'>
        /// 精灵名称
        /// </param>
        /// <param name='path'>
        /// 纹理地址
        /// </param>
        /// <param name='vector'>
        /// 精灵坐标
        /// </param>
        /// <param name='cutImage'>
        /// 切分的块数
        /// </param>
        /// <param name='showPiece'>
        /// 显示的图片部分坐标
        /// </param>
        public SpriteX DrawImage(Layer layer, string name, string path, Vector2 vector, Vector2i cutImage, Vector2i showPiece)
        {
            var sprite = new SpriteX(layer, path, vector, cutImage, showPiece);

            sprite.Name = name;
            spriteDictionary.Add(name, sprite);
            return(sprite);
        }
Beispiel #5
0
        /// <summary>
        /// 绘制一个新的精灵,可设置坐标及显示部分
        /// </summary>
        /// <returns>
        /// 创建的精灵
        /// </returns>
        /// <param name='name'>
        /// 精灵名称
        /// </param>
        /// <param name='path'>
        /// 纹理地址
        /// </param>
        /// <param name='vector'>
        /// 精灵坐标
        /// </param>
        /// <param name='rectangle'>
        /// 表示显示起始坐标及结束坐标的矩形
        /// </param>
        public SpriteX DrawImage(Layer layer, string name, string path, Vector2 vector, BoundBox rectangle)
        {
            var sprite = new SpriteX(layer, path, vector, rectangle);

            sprite.Name = name;
            spriteDictionary.Add(name, sprite);
            return(sprite);
        }
Beispiel #6
0
 public MenuBGObject(Node node)
     : base(node)
 {
     var vector = new Vector2(30,-300);
     Image = new SpriteX(this,"PlanetMenu/Menu_BG.png",vector);
     Image.Color.A = 0;
     Image.RunAction(new TintBy(new Vector4(0f,0f,0f,1f),1f));
     Image.Moveby(new Vector2(0,320),1f);
 }
Beispiel #7
0
 public BBullet(Node node,Vector2 pos,Vector2 Dir,float Speed,
     float w, float h,WeapRanType wrt, ContactType ctype,float att, string path)
     : base(node,0,0,pos,w,h,ctype,null,null)
 {
     this.Att =att;
     this. Speed = Speed;
     this.Dir = Dir;
     body =new SpriteX(path,pos);
     body.ChangeFather(this);
     body.CenterSprite(TRS.Local.Center);
     body.Color = new Vector4(12/255f,255/255f,98/255f,255f/255f);
     maxShootDis = BWeapon.GetRangeByType(wrt);
 }
Beispiel #8
0
        /// <summary>
        /// 构造一个宇宙舰基对象,不会碰撞的
        /// </summary>
        public BWarship(Node node,Vector2 pos,string path)
            : base(node,1,1)
        {
            body = new SpriteX(path,pos);
            body.ChangeFather(this);
            body.CenterSprite(TRS.Local.Center);

                Speed=8f;
                MaxRotSpeed = 0.02f;
                RotSpeed =MaxRotSpeed;
                RotSpeedInc = 0.002f;
            this.Body.Scale = allWarshipScale;
        }
Beispiel #9
0
        public BTracker(SpriteX sprite, ref float moveSpeed, float RotSpeed,
                        float RotSpeedInc)
        {
            currentTarget = sprite.GetPosition();
            newTarget     = sprite.GetPosition();

            Speed            = moveSpeed;
            this.sprite      = sprite;
            IsTracking       = false;
            IsReached        = false;
            this.MaxRotSpeed = RotSpeed;
            this.RotSpeed    = RotSpeed;
            this.RotSpeedInc = RotSpeedInc;
        }
Beispiel #10
0
        public BTracker(SpriteX  sprite,ref float moveSpeed,float RotSpeed,
            float RotSpeedInc)
        {
            currentTarget = sprite.GetPosition();
            newTarget = sprite.GetPosition();

            Speed = moveSpeed ;
            this.sprite =sprite;
            IsTracking = false;
            IsReached  = false;
            this.MaxRotSpeed = RotSpeed;
            this.RotSpeed = RotSpeed;
            this.RotSpeedInc = RotSpeedInc;
        }
Beispiel #11
0
        /// <summary>
        /// 构造一个宇宙舰基对象,会碰撞的
        /// </summary>
        public BWarship(Node node,Vector2 pos,float width,float height,
            ContactType ctype,ContactDeal td,ContactDeal bd,string path)
            : base(node,0,0,pos,width,height,ctype,td,bd)
        {
            body = new SpriteX(this,path,pos);
            body.CenterSprite(TRS.Local.Center);
            HP = 100;

                Speed=8f;
                MaxRotSpeed = 0.02f;
                RotSpeed =MaxRotSpeed;
                RotSpeedInc = 0.002f;
            this.Body.Scale = allWarshipScale;
        }
Beispiel #12
0
        public BBomb(Node node, Vector2 pos, Vector2 Dir, float Speed,
            float w, float h, WeapRanType wrt,float startBomb,  float NoContactTime,ContactType ctype, float att, string path)
            : base(node,0,0,pos,w,h,ctype,null,null)
        {
            this.Att =att;

            this.NoContactTime = NoContactTime;
            this. Speed = Speed;
            this.Dir = Dir;
            body =new SpriteX(path,pos);
            body.ChangeFather(this);
            body.CenterSprite (TRS.Local.Center);

            //
            body.Scale = new Vector2 (12f, 12f);
            body.Color = new Vector4(220/255f,82/255f,98/255f,255f/255f);
            //base.drawBoundBox = new DrawBoundBox(this);
        }
Beispiel #13
0
        public BMissile(Node node,Vector2 pos,BWarship target,float Speed,float rots,float rotsInc,
            float w, float h, WeapRanType wrt, ContactType ctype,float att, string path)
            : base(node,0,0,pos,w,h,ctype,null,null)
        {
            this.Att =att;
            this. Speed = Speed;
            this.target = target;

            body = new SpriteX(path,pos);
            body.ChangeFather(this);
            body.CenterSprite(TRS.Local.Center);
            body.Scale = new Vector2(0.4f,0.4f);

            tracker =new BTracker(body,ref this.Speed,rots,rotsInc);
            tracker.SetTarger(target.GetPosition());

            body.Color = BWarship.ColorID;
            maxShootDis = BWeapon.GetRangeByType(wrt);
        }
Beispiel #14
0
        public BattleMap(Node node)
            : base(node)
        {
            background = new SpriteX("Battles//background.png",new Vector2(-100,-100));
            background.ChangeFather(this);
            boundaryWarner = new SpriteX("Battles//BoundaryWarning.png",NoDisplayPos);
            boundaryWarner.ChangeFather(this);
            boundaryWarner.CenterSprite(TRS.Local.Center);

            Vector2 pos;
            SpriteX x;
            for(int i=0;i<starCount;i++)
            {
                pos = new Vector2(Maths.Rnd.Next((int)(-BattleScene.Width*0.5f-100),(int)(BattleScene.Width*0.5f+100)),
                                  Maths.Rnd.Next((int)(-BattleScene.Heigth*0.5f-100),(int)(BattleScene.Heigth*0.5f+100)));
                 x = new SpriteX("Battles//star.png",pos);
                x.ChangeFather(this);
                x.CenterSprite(TRS.Local.Center);
            }
        }
Beispiel #15
0
        public DrawBoundBox(Node node)
            : base(node)
        {
            SpriteX p;

//			for(int i=0; i<4;i++)
//			{
//				p = new SpriteX(this,"Battles//primitive.png",
//				                new Vector2(-9999,-9999));
//				p.CenterSprite(TRS.Local.Center);
//				p.Color = new Vector4(37 / 255f, 255 / 255f, 28 / 255f, 255f / 255f);
//				p.Scale =new Vector2(0.7f,0.7f);
//				aabbPoints.Add(p);
//			}

//			for(int i=0; i<4;i++)
//			{
//				p = new SpriteX(this,"Battles//primitive.png",
//				                new Vector2(-9999,-9999));
//				p.CenterSprite(TRS.Local.Center);
//				p.Scale =new Vector2(0.7f,0.7f);
//				p.Color = new Vector4(227 / 255f, 64 / 255f, 255 / 255f, 255f / 255f);
//				obbPoints.Add(p);
//			}
//
            for (int i = 0; i < 8; i++)
            {
                p = new SpriteX("Battles//primitive.png",
                                new Vector2(-9999, -9999));
                p.ChangeFather(this);
                p.CenterSprite(TRS.Local.Center);
                p.Scale = new Vector2(0.7f, 0.7f);
                p.Color = new Vector4(52 / 255f, 150 / 255f, 255 / 255f, 255f / 255f);
                circlePoints.Add(p);
            }
        }
Beispiel #16
0
        public override void Start()
        {
            //先加载资源
            GameData.LoadTextureInfo("Battles//background.png");
            GameData.LoadTextureInfo("Battles//BoundaryWarning.png");
            GameData.LoadTextureInfo("Battles//primitive.png");
            GameData.LoadTextureInfo("Battles//star.png");
            GameData.LoadTextureInfo("Battles//test.png");
            GameData.LoadTextureInfo("Battles//testship.png");
            GameData.LoadTextureInfo("Battles//testwingman.png");

            bacgroundBack = new Layer ();
            bacground = new Layer ();
            middle = new Layer ();
            front = new Layer ();

            this.AddChild (bacgroundBack);//最下层
            this.AddChild (bacground);
            this.AddChild (middle);
            this.AddChild (front);

            LeftLimit = - Width * 0.5f;
            RightLimit = Width * 0.5f;
            UpLimit = - Heigth * 0.5f;
            DownLimit = Heigth * 0.5f;

            map = new BattleMap(bacgroundBack);
            enemy = new BEnemyManager(middle,this);
            player = new BPlayer(middle,this);
            otherSprites = new SpriteX (this, "Battles//test.png", new Vector2 (0, 0));
            otherSprites.CenterSprite (TRS.Local.Center);

            //锁定
            player.SetCanLockEnemys(enemy.GetAllWarships());
            enemy.SetCanLockEnemys(player.GetAllWarships());

            base.Start ();
        }
Beispiel #17
0
        //Draw指令

        /// <summary>
        /// 绘制一个新的精灵,默认在左上角
        /// </summary>
        /// <returns>
        /// 创建的精灵
        /// </returns>
        /// <param name='name'>
        /// 精灵名称
        /// </param>
        /// <param name='path'>
        /// 纹理地址
        /// </param>
        public SpriteX DrawImage(Layer layer, string name, string path)
        {
            SpriteX sprite = DrawImage(layer, name, path, Vector2.Zero);

            return(sprite);
        }
Beispiel #18
0
        /// <summary>
        /// 绘制一个新的精灵,可设置精灵坐标
        /// </summary>
        /// <returns>
        /// 创建的精灵
        /// </returns>
        /// <param name='name'>
        /// 精灵名称
        /// </param>
        /// <param name='path'>
        /// 纹理地址
        /// </param>
        /// <param name='vector'>
        /// 精灵坐标
        /// </param>
        public SpriteX DrawImage(Layer layer, string name, string path, Vector2 vector)
        {
            SpriteX sprite = DrawImage(layer, name, path, vector, new Vector2i(1, 1), new Vector2i(1, 1));

            return(sprite);
        }
Beispiel #19
0
 public MenuButton(Node node,string path,SelectTodo selectTodo,int num)
     : base(node)
 {
     Num = num;
     this.selectTodo = selectTodo;
     var vector = new Vector2(0,90 + Num * 60);
     Image = new SpriteX(this,path,vector,new Vector2i(1,2),new Vector2i(1,1));
     Image.Color.A = 0;
     ShowTime = new Ticker(0.65f + Num*0.12f);
 }
Beispiel #20
0
 /// <summary>
 /// 绘制一个新的精灵,可设置精灵坐标以及进行切分
 /// </summary>
 /// <returns>
 /// 创建的精灵
 /// </returns>
 /// <param name='name'>
 /// 精灵名称
 /// </param>
 /// <param name='path'>
 /// 纹理地址
 /// </param>
 /// <param name='vector'>
 /// 精灵坐标
 /// </param>
 /// <param name='cutImage'>
 /// 切分的块数
 /// </param>
 /// <param name='showPiece'>
 /// 显示的图片部分坐标
 /// </param>
 public SpriteX DrawImage(Layer layer,string name,string path,Vector2 vector,Vector2i cutImage,Vector2i showPiece)
 {
     var sprite = new SpriteX(layer,path,vector,cutImage,showPiece);
     sprite.Name = name;
     spriteDictionary.Add(name,sprite);
     return sprite;
 }
Beispiel #21
0
 public Player(Node node,float CreatTime,float DieTime)
     : base(node,CreatTime,DieTime)
 {
     hero = new SpriteX(this,"hero2.png",new Vector2(200f,200f),new Vector2i(20,5),new Vector2i(1,1));
 }
Beispiel #22
0
 public TitleButton(Node node)
     : base(node)
 {
     Image = new SpriteX(this,"MainMenu/Menu_Title.png",new Vector2(247,96));
 }
Beispiel #23
0
 public MainMenuButton(Node node,string path,Vector2 vector2,SelectTodo selectTodo)
     : base(node)
 {
     this.selectTodo = selectTodo;
     Image = new SpriteX(this,path,vector2,new Vector2i(1,2),new Vector2i(1,1));
 }
Beispiel #24
0
 public TextBG()
 {
     image = new SpriteX(this,"AVG/TextBox.png",new Vector2(179,364));
 }
Beispiel #25
0
 /// <summary>
 /// 绘制一个新的精灵,可设置坐标及显示部分
 /// </summary>
 /// <returns>
 /// 创建的精灵
 /// </returns>
 /// <param name='name'>
 /// 精灵名称
 /// </param>
 /// <param name='path'>
 /// 纹理地址
 /// </param>
 /// <param name='vector'>
 /// 精灵坐标
 /// </param>
 /// <param name='rectangle'>
 /// 表示显示起始坐标及结束坐标的矩形
 /// </param>
 public SpriteX DrawImage(Layer layer,string name,string path,Vector2 vector,BoundBox rectangle)
 {
     var sprite = new SpriteX(layer,path,vector,rectangle);
     sprite.Name = name;
     spriteDictionary.Add(name,sprite);
     return sprite;
 }
Beispiel #26
0
 private void AddBackground(string Name)
 {
     if(Name != "")
         backGroundPic = new SpriteX(BackGround,"BG/" + Name,Vector2.Zero);
     else
         backGroundPic = new SpriteX(BackGround,"BG/Default.png",Vector2.Zero);
 }
Beispiel #27
0
 public Player(Node node, float CreatTime, float DieTime) : base(node, CreatTime, DieTime)
 {
     hero = new SpriteX(this, "hero2.png", new Vector2(200f, 200f), new Vector2i(20, 5), new Vector2i(1, 1));
 }