Esempio n. 1
0
 public RandomShooter(Barragebatch x, LinkedList <Bullet> mBullet, Vector2 position, Sprite target)
     : base(x.iGunID, position, x.iGunStartTime, x.iGunEndTime - x.iGunStartTime, x.iBindingID)
 {
     ran                = new Random();
     localBullet        = mBullet;
     this.x             = x;
     this.target        = target;
     this.isAbsolutePos = x.bIsAbsolute;
     //调用初始化函数,初始化除了事件以外的所有成员变量
     Initialize(0);
     //处理发射器事件以及子弹事件
     this.bulletEvent     = new List <BarrageEvent>();
     this.myEvent         = new List <BarrageEvent>();
     this.myEventReader   = new EventReader();
     this.currentEvent    = new List <BarrageEvent>();
     this.relativeBinding = x.bRelativeBinding;
     //处理子弹事件
     if (bulletData.bulletEvent.Length != 0)
     {
         bulletEvent = myEventReader.ReadEvent(bulletData.bulletEvent);
     }
     if (x.strGunEvent.Length != 0)
     {
         myEvent = myEventReader.ReadEvent(x.strGunEvent);
     }
 }
Esempio n. 2
0
        public BarrageHelper(string barrageScriptMenu)
        {
            myBarrageData = new List <List <Barragebatch> >();
            StreamReader myReader   = new StreamReader(barrageScriptMenu + "barraset.dat");
            string       readString = myReader.ReadToEnd();

            barrageName = readString.Split(",".ToCharArray());
            foreach (string bname in barrageName)
            {
                myBarrageData.Add(Barragebatch.ReadScript(barrageScriptMenu + bname + ".mbg"));
            }
            myReader.Close();
        }
Esempio n. 3
0
        EventReader myEventReader;        //事件读取器

        public LaserShooter(Barragebatch x, LinkedList <Bullet> myLaser, Vector2 position, Sprite target) :
            base(x.iGunID, position, x.iGunStartTime, x.iGunEndTime - x.iGunStartTime, x.iBindingID)
        {
            this.x           = x;
            this.target      = target;
            this.localBullet = myLaser;
            Initialize(0);
            this.isAbsolutePos = x.bIsAbsolute;
            //处理发射器事件以及子弹事件
            this.myEventReader   = new EventReader();
            this.myEvent         = new List <BarrageEvent>();
            this.currentEvent    = new List <BarrageEvent>();
            this.relativeBinding = x.bRelativeBinding;
            //处理子弹事件
            if (x.strBulletEvent.Length != 0)
            {
                myEvent = myEventReader.ReadEvent(x.strBulletEvent);
            }
        }
Esempio n. 4
0
        ////////////////////////////////////////////////////////////////////
        //方法:ReadScript,静态方法,读取弹幕脚本                        //
        //输入:弹幕脚本的相对路径strRelativePath(相对于主程序所处目录) //
        //输出:弹幕类Barragebatch的对象数组                              //
        //返回:成功返回true,否则返回false                               //
        ////////////////////////////////////////////////////////////////////
        static public List <Barragebatch> ReadScript(string strRelativePath)
        {
            List <Barragebatch> bgTarget = new List <Barragebatch>();

            try
            {
                string strFileData; //用于储存文件数据
                int    iStrPos = 0; //记录最后读取的字符串的位置
                string strTemp;     //文件翻译中间变量


                System.IO.StreamReader objReader =
                    new System.IO.StreamReader(strRelativePath);

                //一次性读取弹幕脚本,避免对文件反复操作
                strFileData = objReader.ReadToEnd();
                objReader.Close();

                //发射器坐标是否为绝对位置
                Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                sbIsAbsolute = Convert.ToBoolean(strTemp);

                //十字光标X、Y
                Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                siCrossX = Convert.ToInt32(strTemp);
                Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                siCrossY = Convert.ToInt32(strTemp);

                //设计时弹幕测试当前帧,无需记录
                Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);

                //未知
                Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);

                //循环起始帧
                Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                siCycleStart = Convert.ToInt32(strTemp);

                //总帧数
                Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                siFrameNum = Convert.ToInt32(strTemp);

                //发射器数,开始循环读取各发射器参数
                Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                int iGunNum = Convert.ToInt32(strTemp);

                for (int i = 0; i < iGunNum; i++)
                {
                    Barragebatch bgTemp = new Barragebatch();//发射器赋值中间变量
                    bgTemp.bIsAbsolute = Barragebatch.sbIsAbsolute;
                    bgTemp.iCrossX     = Barragebatch.siCrossX;
                    bgTemp.iCrossY     = Barragebatch.siCrossY;
                    bgTemp.iCycleStart = Barragebatch.siCycleStart;
                    bgTemp.iFrameNum   = Barragebatch.siFrameNum;
                    //发射器ID
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iGunID = Convert.ToInt32(strTemp);

                    //发射器类型
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.eGunType = (eGT)Convert.ToInt32(strTemp);

                    //发射器X、Y
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iGunPosX  = Convert.ToInt32(strTemp);
                    bgTemp.iGunPosX -= bgTemp.iCrossX;
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iGunPosY  = Convert.ToInt32(strTemp);
                    bgTemp.iGunPosY -= bgTemp.iCrossY;

                    //发射器X2、Y2
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iGunPosX2  = Convert.ToInt32(strTemp) + 30;
                    bgTemp.iGunPosX2 -= 263;
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iGunPosY2 = Convert.ToInt32(strTemp) + 50;

                    //未知*2
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);

                    //子弹及发射器事件描述
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.strBulletEvent = strTemp;
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.strGunEvent = strTemp;

                    //(发)射角
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.fFireAngle = (float)Convert.ToDouble(strTemp);

                    //未知
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);

                    //位置半径或激光宽度
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    if (bgTemp.eGunType == eGT.LASER)
                    {
                        bgTemp.fLaserWidth = Convert.ToInt32(strTemp);
                    }
                    else
                    {
                        bgTemp.fLocationRadius = (float)Convert.ToDouble(strTemp);
                    }

                    //半径增速
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.fRadiusAcc = (float)Convert.ToDouble(strTemp);

                    //未知
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);

                    //子弹生成位置
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.eBulletCreatePos = (int)Convert.ToInt32(strTemp);

                    //是否有拖影效果或指向力场中心
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    if (bgTemp.eGunType == eGT.FORCE)
                    {
                        bgTemp.bForceCenter = Convert.ToBoolean(strTemp);
                    }
                    else
                    {
                        bgTemp.bShadow = Convert.ToBoolean(strTemp);
                    }

                    //周期
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iCycleTime = Convert.ToInt32(strTemp);

                    //发射器起始、终止时间
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iGunStartTime = Convert.ToInt32(strTemp);
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iGunEndTime = Convert.ToInt32(strTemp);

                    //未知
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);

                    //子弹生命
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iBulletLife = Convert.ToInt32(strTemp);

                    //是否出屏消除
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.bKillOutBullet = Convert.ToBoolean(strTemp);

                    //随机发射器随机半径或激光长度
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    if (bgTemp.eGunType == eGT.RANDOM)
                    {
                        bgTemp.fRandomRadius = (float)Convert.ToDouble(strTemp);
                    }
                    else
                    {
                        bgTemp.fLaserLength = (float)Convert.ToDouble(strTemp);
                    }

                    //子弹头朝向角度
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iBulletHeadAngle = (int)Convert.ToDouble(strTemp);

                    //子弹头朝向方式
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.eBulletToward = (directionType)Convert.ToInt32(strTemp);

                    //未知*2
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);

                    //加角或激光射角
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    if (bgTemp.eGunType == eGT.LASER)
                    {
                        bgTemp.fLaserFireAngle = (float)Convert.ToDouble(strTemp);
                    }
                    else
                    {
                        bgTemp.iBulletAccAngle = Convert.ToInt32(strTemp);
                    }

                    //子弹加速度
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.fBulletAcc = (float)Convert.ToDouble(strTemp);

                    //子弹速度
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.fBulletSpeed = (float)Convert.ToDouble(strTemp);

                    //未知
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);

                    //随机发射器的随机半长
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.fRandomHalfLength = (float)Convert.ToDouble(strTemp);

                    //随机发射器的随机半高
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.fRandomHalfHeight = (float)Convert.ToDouble(strTemp);

                    //发射器发射的角度范围,用于多向/激光发射器
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iGunAngleRange = Convert.ToInt32(strTemp);

                    //发射器的发射条数,用于多向/激光发射器
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iFireNumber = Convert.ToInt32(strTemp);

                    //未知*25
                    for (int j = 0; j < 25; j++)
                    {
                        Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    }

                    //遮罩更改值,根据类型可能为int
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.fMaskValue = (float)Convert.ToDouble(strTemp);

                    //遮罩起始帧
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iMaskStartTime = Convert.ToInt32(strTemp);

                    //遮罩半高
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iMaskHalfHeight = Convert.ToInt32(strTemp);

                    //遮罩半长
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iMaskHalfLength = Convert.ToInt32(strTemp);

                    //遮罩生命
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iMaskLife = Convert.ToInt32(strTemp);

                    //未知
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);

                    //遮罩类型
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.eMaskType = (eMT)Convert.ToInt32(strTemp);

                    //遮罩更改后的子弹图案编号
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iMaskBulletType = Convert.ToInt32(strTemp);

                    //反射板倾角
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iReflexAngle = Convert.ToInt32(strTemp) * 45;

                    //反射板起始帧
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iReflexStartTime = Convert.ToInt32(strTemp);

                    //反射板生命
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iReflexLife = Convert.ToInt32(strTemp);

                    //未知
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);

                    //反射板长
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iReflexLength = Convert.ToInt32(strTemp);

                    //子弹是否只碰撞一次
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.bReflexOnce = Convert.ToBoolean(strTemp);

                    //反射后子弹类型编号
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iReflexBulletType = Convert.ToInt32(strTemp);

                    //力场半长
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iForceHalfLength = Convert.ToInt32(strTemp);

                    //力场半高
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iForceHalfHeight = Convert.ToInt32(strTemp);

                    //力场起始帧
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iForceStartTime = Convert.ToInt32(strTemp);

                    //力场生命
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iForceLife = Convert.ToInt32(strTemp);

                    //力场大小
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.fForceStrength = (float)Convert.ToDouble(strTemp);

                    //力场方向
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iForceDirection = Convert.ToInt32(strTemp);

                    //是否为自机狙
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.bSelfSnipe = Convert.ToBoolean(strTemp);

                    //子弹类型
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iBulletType = Convert.ToInt32(strTemp);

                    //随机发射器的随机参数类型
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.eRandomValue = (eRV)Convert.ToInt32(strTemp);

                    //随机发射器的随机范围
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.fRandomRange = (float)Convert.ToDouble(strTemp);

                    //子弹类型2,参数可能无用
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iBulletType2 = Convert.ToInt32(strTemp);

                    //是否改变反射后的子弹类型
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.bReflexChangeType = Convert.ToBoolean(Convert.ToInt32(strTemp));

                    //是否有高光效果
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.bHighLight = Convert.ToBoolean(strTemp);

                    //发射器事件循环帧数
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iGunEventCycleTime = Convert.ToInt32(strTemp);

                    //绑定发射器ID
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iBindingID = Convert.ToInt32(strTemp);

                    //是否为相对绑定
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.bRelativeBinding = Convert.ToBoolean(strTemp);

                    //子弹事件循环帧
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.iBulletEventCycleTime = Convert.ToInt32(strTemp);

                    //是否响应反射板
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.bReflex = Convert.ToBoolean(strTemp);

                    //是否响应遮罩
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.bMask = Convert.ToBoolean(strTemp);

                    //是否响应力场
                    Barragebatch._PreTranslate(out strTemp, ref strFileData, ref iStrPos);
                    bgTemp.bForce = Convert.ToBoolean(strTemp);

                    //将当前发射器数据载入数组
                    bgTarget.Add(bgTemp);
                }//end of for
                return(bgTarget);
            }
            catch (Exception e)
            {
                System.Console.Error.WriteLine(e.Message);
                return(null);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 载入弹幕组件
        /// </summary>
        void LoadBarrageComponent()
        {
            BarrageComponent bc;

            startFrame = barrage[0].iCycleStart;
            totalFrame = barrage[0].iFrameNum;
            Barragebatch x = new Barragebatch();

            for (int i = 0; i < barrage.Count; i++)
            {
                Vector2 position;
                x = (Barragebatch)barrage[i];
                if (barrage[0].bIsAbsolute)
                {
                    position = new Vector2(x.iGunPosX2, x.iGunPosY2);
                }
                else
                {
                    position = new Vector2(x.iGunPosX, x.iGunPosY);
                }
                if ((int)x.eGunType <= 5)//属于发射器
                {
                    LinkedList <Bullet> eBullet = new LinkedList <Bullet>();
                    switch (x.eGunType)
                    {
                    case Barragebatch.eGT.MULTI:
                        bc = new MultiShooter(x, eBullet, position, target);
                        break;

                    case Barragebatch.eGT.DIRECT:
                        bc = new DirectShooter(x, eBullet, position, target);
                        break;

                    case Barragebatch.eGT.LASER:
                        bc = new LaserShooter(x, eBullet, position, target);
                        break;

                    case Barragebatch.eGT.RANDOM:
                        bc = new RandomShooter(x, eBullet, position, target);
                        break;

                    default:
                        bc = new DefaultBarrageComponent();//一般请不要使用这个类
                        break;
                    }
                    if (x.bHighLight)
                    {
                        highLightBullet.Add(eBullet);
                    }
                    else
                    {
                        normalBullet.Add(eBullet);
                    }
                }
                else
                {
                    switch (x.eGunType)
                    {
                    case Barragebatch.eGT.REFLEX:
                        bc = new ReflexShooter(x.iGunID, highLightBullet, normalBullet, new Vector2(x.iGunPosX2, x.iGunPosY2), x.iReflexAngle,
                                               x.iReflexStartTime, x.iReflexLife, x.iReflexLength, x.bReflexOnce, x.bReflexChangeType, x.iReflexBulletType);
                        break;

                    case Barragebatch.eGT.FORCE:
                        bc = new ForceShooter(x.iGunID, highLightBullet, normalBullet, new Vector2(x.iGunPosX2, x.iGunPosY2), x.iForceStartTime,
                                              x.iForceLife, x.iForceHalfLength, x.iForceHalfHeight, x.fForceStrength, x.iForceDirection, x.bForceCenter);
                        break;

                    case Barragebatch.eGT.MASK:
                        bc = new MaskShooter(x.iGunID, highLightBullet, normalBullet, new Vector2(x.iGunPosX2, x.iGunPosY2), x.iMaskStartTime,
                                             x.iMaskLife, x.iMaskHalfLength, x.iMaskHalfHeight, x.fMaskValue, x.eMaskType, x.iMaskBulletType);
                        break;

                    default:
                        bc = new DefaultBarrageComponent();    //一般请不要使用这个类
                        break;
                    }
                }
                if (!x.bIsAbsolute)
                {
                    bc.BindSprite(owner);
                }
                myBarrage.Add(bc);
            }

            //检测绑定子弹
            foreach (BarrageComponent ba in myBarrage)
            {
                if (ba.bindingID != -1)
                {
                    for (int i = 0; i < myBarrage.Count; i++)
                    {
                        if (ba.bindingID == myBarrage[i].ID)
                        {
                            ba.setBindingBullet(myBarrage[i].getLocalBullet());
                        }
                    }
                }
            }
        }