const SW_店ボタンOFF = 462;
const CN_街コモン = 16;
const L0TownPic = "pictures/Adv/L0_Town/"; 
Game_Interpreter.prototype.Adv_L0Town_View = function () {
    var _opi = 0;
    this.SetPict(PN_tBackT, AdvPic + "PN_tBackT", 0, 0);
    ViewPicReset();
    this.EventBackCng("Town_Back" , 15);
    this.DelPict(PN_KunrenFree);
    this.DelPict(PN_KunrenFreeTxt);
    this.DelPictSpan(PN_tSelBtn + 0 , PN_tSelBtn + 6);
}
Game_Interpreter.prototype.Adv_L0Town_UIDraw = function () {
    EvCngWait = 5;
    if (L0_NotDrawFlg) {
        this.JN_EventLoad("街選択戻");
        L0_NotDrawFlg = false; return;
    }
    L0_TcPic = []; 
    $gameSystem.L0TownSelecter = [];
    var _opi = 0;
    let _cnt = 0;
    for (var i = 0; i <= $gameSystem.L0TownBtnArr.length - 1; i++) {
        switch ($gameSystem.L0TownBtnArr[i]) {
            case "Btn_Skill":
                if ($gameSwitches.value(SW_店ボタンOFF + 0))
                    continue;
                break;
            case "Btn_GunShop":
                if ($gameSwitches.value(SW_店ボタンOFF + 1))
                    continue;
                break;
            case "Btn_Item":
                if ($gameSwitches.value(SW_店ボタンOFF + 2))
                    continue;
                break;
        }
        $gameSystem.L0TownSelecter.push($gameSystem.L0TownBtnArr[i]);
        this.SetPict(PN_tSelBtn + _cnt, L0TownPic + $gameSystem.L0TownBtnArr[i], L0BtnPos._x - 100, L0BtnPos._y - (_AdvSellSa * _cnt), _opi);
        if (_cnt != L0_Selecter){
            this.MovePict(PN_tSelBtn + _cnt, L0BtnPos._x - 15, true, 3);
        } else {
            this.MovePict(PN_tSelBtn + _cnt, L0BtnPos._x, true, 3);
        }
        L0_TcPic.push(PN_tSelBtn + _cnt);
        _cnt++;
    }
    L0_Selecter = $gameSystem.L0TownSelecter.length - 1; 
    this.SetPictC(PN_AdvSell, AdvPic + "PN_AdvSell", L0BtnPos._x - 15 - 100, L0BtnPos._y - (_AdvSellSa * L0_Selecter) + 35, _opi);
    this.MovePict(PN_AdvSell, L0BtnPos._x - 15, L0BtnPos._y - (_AdvSellSa * L0_Selecter) + 35, 15); 
}
var _拠点Back_flame = 0;
Game_Interpreter.prototype.Adv_L0Town_Update = function () {
    if (_拠点Back_flame >= 1){
        _拠点Back_flame++;
        if(_拠点Back_flame == 5){
            this.Adv_SpineEffect_Close(); 
        }
        if (_拠点Back_flame == 10) {
            _拠点Back_flame = 0;
            this.Adv_L0_Cng(_L0Mode.Base);
            this.Adv_SpineEffect_Open();
        }
        return;
    }
    if (L0_flame == 13) { 
        this.SetCmnEventSc(CN_街コモン); 
    }
    if (L0_flame == 15) { 
        _Ck移動EvName = this.JN_EventLoad("街"); 
    }
    if (L0_flame == 18 && _Ck移動EvName != ""){
        L0_flame--;
        return;
    }
    if (L0_flame == 19){
        this.Adv_L0Town_UIDraw();
    } 
    var _mvFlg = false;
    if (Input.isTriggered('up')) { 
        L0_Selecter++; _mvFlg = true;
        if (L0_Selecter >= $gameSystem.L0TownSelecter.length) L0_Selecter = 0;
    }
    if (Input.isTriggered('down')) { 
        L0_Selecter--; _mvFlg = true;
        if (L0_Selecter < 0) L0_Selecter = $gameSystem.L0TownSelecter.length - 1;
    }
    var _CNo = overPointerCkArr(L0_TcPic);
    if (_CNo != -1) {
        if (L0_Selecter != _CNo - PN_tSelBtn) {
            L0_Selecter = _CNo - PN_tSelBtn;
            _mvFlg = true;
        }
    }
    if (_mvFlg) {
        SoundManager.playCursor();
        for (var i = 0; i <= $gameSystem.L0TownSelecter.length - 1; i++) {
            if (i != L0_Selecter) {
                this.MovePict(PN_tSelBtn + i, L0BtnPos._x - 15, true, 3);
            } else {
                this.MovePict(PN_tSelBtn + i, L0BtnPos._x, true, 3);
            }
        }
        this.MovePict(PN_AdvSell, L0BtnPos._x - 15, L0BtnPos._y - (_AdvSellSa * L0_Selecter) + 35, 3);
    }
    if (L0_flame < 16) return;
    if (Input.isTriggered('ok') || (_CNo != -1) && TouchInput.isTriggered()) { 
        SoundManager.playOk();
        switch ($gameSystem.L0TownSelecter[L0_Selecter]) {
            case "Btn_Kyoten": 
                _拠点Back_flame = 1;
                this.JN_EventLoad("拠点選択");
                break;
            case "Btn_Skill": 
                Adv_Layer = 1; 
                this.Adv_L1_Cng(_L1Mode.スキル);
                break;
            case "Btn_GunShop": 
                Adv_Layer = 1; 
                this.Adv_L1_Cng(_L1Mode.ガン);
                break;
            case "Btn_Item": 
                Adv_Layer = 1; 
                this.Adv_L1_Cng(_L1Mode.アイテム);
                break;
        }
    }
}
Game_Interpreter.prototype._拠点Back_Cancel = function(){
    _拠点Back_flame = 0;
    this.Adv_L0_Back();
}
const L1ItemPic = "pictures/Adv/L1_Item/";
let AdvShop_flame = 0;
Game_Interpreter.prototype.Adv_L1アイテム_View = function () {
    AdvShop_flame = 0;
    this.MovePict(PN_AdvSell, true, true, 10, 0); 
    this.SetPictFIn(PN_l1Back, L1ItemPic + "PN_l1Back", 0, 0, 0, 0, 15);
}
Game_Interpreter.prototype.Adv_L1アイテム_Update = function () {
    AdvShop_flame++;
    if (AdvShop_flame == 5) { 
        this.Adv_L1ShopView(ShopType.アイテム);
    }
    if (AdvShop_flame < 30) return; 
    this.Adv_L1ShopUpdate();
}
const L1GunShopPic = "pictures/Adv/L1_GunShop/";
Game_Interpreter.prototype.Adv_L1ガン_View = function () {
    AdvShop_flame = 0;
    this.MovePict(PN_AdvSell, true, true, 10, 0); 
    this.SetPictFIn(PN_l1Back, L1GunShopPic + "PN_l1Back", 0, 0, 0, 0, 15);
}
Game_Interpreter.prototype.Adv_L1ガン_Update = function () {
    AdvShop_flame++;
    if (AdvShop_flame == 5) { 
        this.Adv_L1ShopView(ShopType.ガン);
    }
    if (AdvShop_flame < 30) return; 
    this.Adv_L1ShopUpdate();
}
const L1SkillPic = "pictures/Adv/L1_Skill/";
Game_Interpreter.prototype.Adv_L1スキル_View = function () {
    AdvShop_flame = 0;
    this.MovePict(PN_AdvSell, true, true, 10, 0); 
    this.SetPictFIn(PN_l1Back, L1SkillPic + "PN_l1Back", 0, 0, 0, 0, 15);
}
Game_Interpreter.prototype.Adv_L1スキル_Update = function () {
    AdvShop_flame++;
    if (AdvShop_flame == 5) { 
        this.Adv_L1SkillView();
    }
    if (AdvShop_flame < 30) return; 
    this.Adv_L1SkillUpdate();
}
