예제 #1
0
        public BPlayer(Node node, BattleScene battleScene) :
            base(node)
        {
            weaponLayer = new Layer();
            this.AddChild(weaponLayer);               //最下层

            this.bScene = battleScene;
            mainship    = new BWarship(this, new Vector2(480, 272), 25, 25,
                                       ContactType.Player, null, null, "Battles//testship.png");
            wingman01 = new BWingman(this, new Vector2(480, 272), 0, 15, 15);
            wingman02 = new BWingman(this, new Vector2(480, 272), 1, 15, 15);

            CameraMoveSpeed = 3.5f;
            mainship.Speed  = CameraMoveSpeed;
            mainship.HP     = 7000;

            //设置武器
            List <BWeapon> weapons = new List <BWeapon>();

            weapons.Add(new BDefenseCannon(200, WeapType.Secondary, WeapRanType.UShortRange, ContactType.PlayerBullet, 0.25f));
            weapons.Add(new BGeneralBomb(120, WeapType.Special, WeapRanType.UShortRange, ContactType.Bomb, 1f));
            weapons.Add(new BDoubleMissile(220, WeapType.Major, WeapRanType.MediumRange, ContactType.PlayerBullet, 2f));

            for (int i = 0; i < weapons.Count; i++)
            {
                weapons[i].ChangeMaster(mainship);
            }

            mainship.Weapon = new BWeaponSystem(this, weapons, weaponLayer);
        }
예제 #2
0
        public BPlayer(Node node,BattleScene battleScene)
            : base(node)
        {
            weaponLayer = new Layer();
            this.AddChild (weaponLayer);  //最下层

            this.bScene = battleScene;
            mainship = new BWarship(this,new Vector2(480,272),25,25,
                                     ContactType.Player, null,null,"Battles//testship.png");
            wingman01 = new BWingman(this,new Vector2(480,272),0,15,15);
            wingman02 = new BWingman(this,new Vector2(480,272),1,15,15);

            CameraMoveSpeed = 3.5f;
            mainship.Speed=CameraMoveSpeed;
            mainship.HP = 7000;

            //设置武器
            List<BWeapon> weapons = new List<BWeapon>();

            weapons.Add(new BDefenseCannon(200,WeapType.Secondary, WeapRanType.UShortRange, ContactType.PlayerBullet,0.25f));
            weapons.Add(new BGeneralBomb(120,WeapType.Special,WeapRanType.UShortRange, ContactType.Bomb,1f));
            weapons.Add(new BDoubleMissile(220, WeapType.Major,WeapRanType.MediumRange, ContactType.PlayerBullet,2f));

            for(int i= 0;i < weapons.Count;i++)
            {
                weapons[i].ChangeMaster(mainship);
            }

            mainship.Weapon = new BWeaponSystem(this,weapons,weaponLayer);
        }
예제 #3
0
        //---------------------

        //选择地图内的 随机位置
        Vector2 SelectFreeTargetPos()
        {
            Vector2 pos = Maths.RndVector() * BattleScene.Heigth;

            BattleScene.SceneSizeLimit(ref pos);

            return(pos);
        }
예제 #4
0
        //不攻击了,没有武器 或者 投降了
        void StopAttck()
        {
            //缓慢惯性移动
            this.SetPosition(this.GetPosition() + NowDirection *
                             inertiaSpeed * 0.15f);

            if (BattleScene.SceneSizeLimit(this.GetPosition()))
            {            //出界就自动回来。
                Vector2 returnDir = Vector2.Zero - this.GetPosition();
                Maths.Normalize(ref returnDir);
                TrackPos(this.GetPosition() + returnDir * 180f);
            }
        }
예제 #5
0
        //选择要去的目标位置.
        void SelectTargetPos()
        {
            if (LockShip != null && TrackAction.IsTracking == false)
            {
                Vector2 targetDir = LockShip.GetPosition() - this.GetPosition();
                targetDir = new Vector2(targetDir.Y, -targetDir.X);
                Maths.Normalize(ref targetDir);

                //根据0~180的随机角度旋转targetDir
                targetDir.TurnTo(targetDir, Maths.Rnd.Next(314) * 0.01f);

                targetDir = targetDir * keepDisFromEnemy + LockShip.GetPosition();
                BattleScene.SceneSizeLimit(ref targetDir);
                TrackPos(targetDir);
            }
        }
예제 #6
0
        //-----------------

        //惯性移动
        void InertiaMove()
        {
            if (TrackAction.IsTracking == false)
            {
                this.SetPosition(this.GetPosition() + NowDirection *
                                 inertiaSpeed);
                if (BattleScene.SceneSizeLimit(this.GetPosition()))
                {                //出界就自动回来。
                    if (LockShip == null)
                    {
                        Vector2 returnDir = Vector2.Zero - this.GetPosition();
                        Maths.Normalize(ref returnDir);
                        TrackPos(this.GetPosition() + returnDir * 180f);
                    }
                }
            }
        }
예제 #7
0
        public BEnemyManager(Node node,BattleScene bScene)
            : base(node)
        {
            this.bScene = bScene;
            weaponLayer = new Layer();
            this.AddChild (weaponLayer);  //最下层

            List<List<BWeapon>> ws = new List<List<BWeapon>>();

            for(int i=0;i<10;i++)
            {
                List<BWeapon> weapons = new List<BWeapon>();
                weapons.Add(new BDefenseCannon(140,WeapType.Secondary,WeapRanType.UShortRange, ContactType.EnemyBullet,0.6f));
                weapons.Add(new BGeneralBomb(0,WeapType.Special,WeapRanType.UShortRange, ContactType.Bomb,1f));
                weapons.Add(new BDoubleMissile(20, WeapType.Major,WeapRanType.MediumRange, ContactType.EnemyBullet,3f));
                ws.Add(weapons);
            }

            for(int i=0;i<10;i++)
            {
                ships.Add(new BEnemyship(this,new Vector2(-200+i*20,0),ws[i],weaponLayer ,"Battles//testship.png"));
            }
        }
예제 #8
0
        public BEnemyManager(Node node, BattleScene bScene) :
            base(node)
        {
            this.bScene = bScene;
            weaponLayer = new Layer();
            this.AddChild(weaponLayer);               //最下层

            List <List <BWeapon> > ws = new List <List <BWeapon> >();

            for (int i = 0; i < 10; i++)
            {
                List <BWeapon> weapons = new List <BWeapon>();
                weapons.Add(new BDefenseCannon(140, WeapType.Secondary, WeapRanType.UShortRange, ContactType.EnemyBullet, 0.6f));
                weapons.Add(new BGeneralBomb(0, WeapType.Special, WeapRanType.UShortRange, ContactType.Bomb, 1f));
                weapons.Add(new BDoubleMissile(20, WeapType.Major, WeapRanType.MediumRange, ContactType.EnemyBullet, 3f));
                ws.Add(weapons);
            }

            for (int i = 0; i < 10; i++)
            {
                ships.Add(new BEnemyship(this, new Vector2(-200 + i * 20, 0), ws[i], weaponLayer, "Battles//testship.png"));
            }
        }