const RD_MassSizeX = 89;
const RD_MassSizeY = 67;
Game_Interpreter.prototype.RD_MapMassDraw = function (_XFlg, _Mint) {
    _XFlg = typeof _XFlg !== 'undefined' ? _XFlg : true;
    _Mint = typeof _Mint !== 'undefined' ? _Mint : 0;
    let _SetX = 327 + 501;
    let _SetY = 256;
    let _Ev_X = RDMapPosX + 578;
    let _Ev_Y = RDMapPosY - 5;
    if (RD_LeftStartFlg) {
        _SetX -= (6 * RD_MassSizeX);
        _Ev_X -= (6 * RD_MassSizeX);
    }
    this.RD_MassPicDel();   
    this.RD_EventPicDel();  
    for (let i = 0; i <= RD_DMapArr.length - 2; i++) {
        for (let j = 1; j <= RD_DMapArr[i].length - 2; j++) {
            if (RD_DMapArr[i][j] == null) continue; 
            let _CkMass = RD_DMapArr[i][j];
            let _MassPic = CkMass_MassPicGet(_CkMass);
            let _EvPic = CkMass_EvPicGet(_CkMass, j);
            let _SPicNo = PN_rdMapMass + (i * 5) + (j - 1);
            let _SEvPicNo = PN_rdMapEv + (i * 5) + (j - 1);
            let _opi = 255;
            let _CSetX = _SetX - (i * RD_MassSizeX);
            if (RD_LeftStartFlg) _CSetX = _SetX + (i * RD_MassSizeX);
            let _CSetY = _SetY + ((j - 1) * RD_MassSizeY);
            if (_MassPic == null) _MassPic = "";
            if (_MassPic != "") { 
                this.SetSpriteC(_SPicNo, RdnPicPath + "Ms/" + _MassPic, _CSetX, _CSetY, _opi);
            }
            let _SPicX = _Ev_X - (i * RD_MassSizeX);
            if (RD_LeftStartFlg) _SPicX = _Ev_X + (i * RD_MassSizeX);
            let _SPicY = _Ev_Y + ((j - 1) * RD_MassSizeY) + 62;
            if (_EvPic != "") {
                this.SetSpriteBC(_SEvPicNo, RdnPicPath + "Ev/" + _EvPic, _SPicX, _SPicY, _opi);
            }
        }
    }
    if (_Mint != 0) {
        if (_XFlg) {
            let _mvXcnt = (RD_DMapArr.length - 1);
            for (let i = 1; i <= RD_DMapArr[_mvXcnt].length - 2; i++) { 
                if (RD_DMapArr[_mvXcnt][i] == null) continue; 
                let _CkMass = RD_DMapArr[_mvXcnt][i];
                let _MassPic = CkMass_MassPicGet(_CkMass);
                let _EvPic = CkMass_EvPicGet(_CkMass, i);
                let _CSetX = _SetX - (_mvXcnt * RD_MassSizeX);
                if (RD_LeftStartFlg) _CSetX = _SetX + (_mvXcnt * RD_MassSizeX);
                let _CSetY = _SetY + ((i - 1) * RD_MassSizeY);
                this.SetSpriteC(PN_rdMapMassView + i, RdnPicPath + "Ms/" + _MassPic, _CSetX, _CSetY, 0);
                let _SPicX = _Ev_X - (_mvXcnt * RD_MassSizeX);
                if (RD_LeftStartFlg) _SPicX = _Ev_X + (_mvXcnt * RD_MassSizeX);
                let _SPicY = _Ev_Y + ((i - 1) * RD_MassSizeY) + 62;
                if (_EvPic != "") {
                    this.SetSpriteBC(PN_rdMapEvView + i, RdnPicPath + "Ev/" + _EvPic, _SPicX, _SPicY, 0);
                }
            }
        } else {
            let _mvYcnt = 0;
            if (_Mint < 0) _mvYcnt = RD_DMapArr[0].length - 1;
            for (let i = 0; i <= RD_DMapArr.length - 2; i++) { 
                if (RD_DMapArr[i][_mvYcnt] == null) continue; 
                let _CkMass = RD_DMapArr[i][_mvYcnt];
                let _MassPic = CkMass_MassPicGet(_CkMass);
                let _EvPic = CkMass_EvPicGet(_CkMass, _mvYcnt);
                let _CSetX = _SetX - (i * RD_MassSizeX);
                if (RD_LeftStartFlg) _CSetX = _SetX + (i * RD_MassSizeX);
                let _CSetY = _SetY + ((_mvYcnt - 1) * RD_MassSizeY);
                this.SetSpriteC(PN_rdMapMassView + i, RdnPicPath + "Ms/" + _MassPic, _CSetX, _CSetY, 0);
                let _SPicX = _Ev_X - (i * RD_MassSizeX);
                if (RD_LeftStartFlg) _SPicX = _Ev_X + (i * RD_MassSizeX);
                let _SPicY = _Ev_Y + ((_mvYcnt - 1) * RD_MassSizeY) + 62;
                if (_EvPic != "") {
                    this.SetSpriteBC(PN_rdMapEvView + i, RdnPicPath + "Ev/" + _EvPic, _SPicX, _SPicY, 0);
                }
            }
        }
        for (let i = PN_RootPic; i <= PN_RootPic + 6; i++) { 
            this.DelSprite(i);
        }
        let _rdMoveX = 0;
        let _rdMoveY = 0;
        if (_XFlg) {
            _rdMoveX = RD_MassSizeX;
            if (RD_LeftStartFlg) _rdMoveX = -RD_MassSizeX;
        } else {
            if (_Mint < 0) {
                _rdMoveY = -RD_MassSizeY;
            } else {
                _rdMoveY = +RD_MassSizeY;
            }
        }
        for (let i = 0; i <= RD_DMapArr.length - 2; i++) {
            for (let j = 1; j <= RD_DMapArr[i].length - 2; j++) {
                if (RD_DMapArr[i][j] == null) continue;
                let _SPicNo = PN_rdMapMass + (i * 5) + (j - 1);
                let _SEvPicNo = PN_rdMapEv + (i * 5) + (j - 1);
                let _EvMoveSkip = false;
                let _opi = 255;
                if (_XFlg) {
                    if (i == 0) _opi = 0;
                } else {
                    if (_Mint < 0) {
                        if (j == 1) _opi = 0;
                    } else {
                        if (j == RD_DMapArr[i].length - 2) _opi = 0;
                    }
                    let _CkMass = RD_DMapArr[i][j];
                    if (_CkMass != null) {
                        if (_CkMass.putData != null) {
                            switch (_CkMass.putData.type) {
                                case "ライン":
                                    _EvMoveSkip = true;
                                    break;
                            }
                        }
                    }
                }
                this.MoveSpriteAdd(_SPicNo, _rdMoveX, _rdMoveY, 15, _opi);
                if (!_EvMoveSkip) {
                    this.MoveSpriteAdd(_SEvPicNo, _rdMoveX, _rdMoveY, 15, _opi);
                }
            }
        }
        for (let i = 0; i <= 7 - 1; i++) {
            this.MoveSpriteAdd(PN_rdMapMassView + i, _rdMoveX, _rdMoveY, 15, 255);
            this.MoveSpriteAdd(PN_rdMapEvView + i, _rdMoveX, _rdMoveY, 15, 255);
        }
    }
}
Game_Interpreter.prototype.RD_MapHPDraw = function () {
    D_Text_Cng_font = "Makinas";
    this.SetSprite(PN_rbStateWin + 0, RdnPicPath + "Win_HpWin", 1102, 700);
    let _SetHpStr = $gameActors._data[1]._hp + " / " + $gameActors._data[1].mhp;
    this.SpriteStrC(PN_rbStateWin + 1, _SetHpStr, 35, 1300, 732, 255);
    D_Text_Cng_font = "";
}
Game_Interpreter.prototype.RD_UIView = function () {
    this.SetSprite(PN_rbMapName + 0, RdnPicPath + "Win_MapName", -258, 9);
    D_Text_Cng_font = "Makinas";
    this.SpriteStr(PN_rbMapName + 1, $gameSystem.RD_BaseData.name, 28, -258 + 30, 31, 0);
    this.MoveSprite(PN_rbMapName + 0, 0, true, 15);
    this.MoveSprite(PN_rbMapName + 1, 30, true, 15);
    this.MoveSprite(PN_BDeckBtn, true, true, 15);
    this.MoveSprite(PN_DFuti, true, true, 15);
    D_Text_Cng_font = "";
}
