//随机发射射程够的武器
        public void RndShoot(float dis)
        {
            //有武器,且射程够就发射
            if (IsHaveMajorWeapon() &&
                BWeapon.GetRangeSquaredByType(majorWeapons[0].WeaponRangeType) > dis)
            {
                if (Maths.Rnd.Next(1, 3) == 2)
                {
                    ShootMajorWeapon(0);
                }
            }

            if (IsHaveSecondaryWeapon() &&
                BWeapon.GetRangeSquaredByType(secondaryWeapons[0].WeaponRangeType) > dis)
            {
                //if(Maths.Rnd.Next(1,3) == 2)
                ShootSecondaryWeapon(0);
            }

            if (IsHaveSpecialWeapon() &&
                BWeapon.GetRangeSquaredByType(specialWeapons[0].WeaponRangeType) > dis)
            {
                if (Maths.Rnd.Next(1, 4) == 2)
                {
                    ShootSpecialWeapons(0);
                }
            }
        }
        //选择与敌人的距离
        void ChooseDisFormEnemy()
        {
            WeapRanType mostfarW = this.Weapon.GetMostFarRange();

            //武器用完了^……
            if (mostfarW == WeapRanType.None)
            {
                IsHaveWeapon = false;
                return;
            }

            float maxWRange = BWeapon.GetRangeByType(mostfarW);
            //随机抖动值
            float rnd = Maths.Rnd.Next(70, 150);

            if (maxWRange < lockRadius)
            {
                keepDisFromEnemy = maxWRange - rnd;
            }
            else
            {
                keepDisFromEnemy = lockRadius - rnd;
            }

            if (keepDisFromEnemy < 40)
            {
                keepDisFromEnemy = 40;
            }
        }
Exemple #3
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);
 }
Exemple #4
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);
        }