示例#1
0
        //显示边界警告
        public void DisplayBoundaryWarn(Vector2 pos, BoundaryType type)
        {
            if (type == BoundaryType.Right)
            {
                boundaryWarner.CenterSprite(TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Right)
                {
                    boundaryWarner.Rotate(boundaryWarner.Rotation);
                    boundaryWarner.Rotate(GameBase.Right);
                }
                else
                {
                    boundaryWarner.SetPosition(pos);
                }
            }

            if (type == BoundaryType.Left)
            {
                boundaryWarner.CenterSprite(TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Left)
                {
                    boundaryWarner.Rotate(boundaryWarner.Rotation);
                    boundaryWarner.Rotate(GameBase.Left);
                }
                else
                {
                    boundaryWarner.SetPosition(pos);
                }
            }

            if (type == BoundaryType.Up)
            {
                boundaryWarner.CenterSprite(TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Down)
                {
                    boundaryWarner.Rotate(GameBase.Right);
                    boundaryWarner.Rotate(GameBase.Down);
                }
                else
                {
                    boundaryWarner.SetPosition(pos);
                }
            }

            if (type == BoundaryType.Down)
            {
                boundaryWarner.CenterSprite(TRS.Local.MiddleLeft);
                if (boundaryWarner.Rotation != GameBase.Up)
                {
                    boundaryWarner.Rotate(GameBase.Right);
                    boundaryWarner.Rotate(GameBase.Up);
                }
                else
                {
                    boundaryWarner.SetPosition(pos);
                }
            }
        }
示例#2
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);
 }
示例#3
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;
        }
示例#4
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;
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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);
            }
        }
示例#8
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();
        }