/
domahes
/
Arcade
Обзор
Документация
Войти
/
domahes
/
Arcade
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
js/window/WSkill.js
325 строк
11 KB
domahes
Initial commit with game files
01 июн 2026, 09:31
01 июн 2026, 09:31
0f50ffb
Код
Авторство
О чём код?
/** * Created by YewMoon on 2019/3/1. * Interface·Skill * @param ui */ function WSkill(ui){ //==================================== Private Attributes =================================== var _sf = this; var tempObj = null; var tempKeyObj = null; var tempSelect = 0; var tempSelectKey = 0; var nullKeyObj = null; //==================================== Public Attributes =================================== this.uiId = 2; //skills data this.skillData = []; //skill details data this.detailsData = []; //shortcut key list this.keyList = []; //current selected skill this.selectIndex = 0; //index in userSkill of current skill this.selectUserSkillIndex = 0; //current selected key this.selectKeyIndex = 0; //show select-box this.callPage = false; //==================================== Public Function =================================== /** * Execute on Initialization */ this.init = function (){ var isPc = IsPC(); setKeyList(isPc); for(var i = 0; i<RV.GameData.actor.skill.length; i++){ var id = RV.GameData.actor.skill[i]; var cof = RV.NowSet.findSkillId(id); var key = " "; var index = -1; for(var k in RV.GameData.userSkill){ if(RV.GameData.userSkill[parseInt(k)] == id){ if(isPc){ var tempName = RC.Key["skill" + (parseInt(k) + 1)]; key = RC.CodeToSting(tempName); }else{ key = parseInt(i + 1); } index = parseInt(k); break; } } var tempSkill = { data : cof, key : key, index :index, icon : "Icon/"+ cof.icon, name : cof.name }; var power = " "; var element = " "; var elementSub = " "; power = cof.pow == 0 ? " " : "\\n" +"Power : "+ Math.abs(cof.pow); element = cof.mainAttribute == 0 ? " " : "\\n" +"Element : " + RV.NowSet.findAttributeId(cof.mainAttribute).name; elementSub = cof.otherAttribute == 0 ? " " : "\\n" +"Secondary Element : " + RV.NowSet.findAttributeId(cof.otherAttribute).name; var tempMsg = "Cost MP : " + cof.useMp + "\\n" + "CD(Sec.) : " + cof.cd + power + element + elementSub + "\\n" + "\\n" +cof.msg; var tempDetails = { name : cof.name, msg : tempMsg }; _sf.skillData.push(tempSkill); _sf.detailsData.push(tempDetails); } if(RV.GameData.actor.skill.length >0){ tempObj = _sf.skillData[0]; }else{ _sf.detailsData = []; _sf.skillData.push({key: " ",name : " No Skills",icon: "System/null.png"}) } }; /** * Execute After Initialization */ this.initAfter = function (){ flashChoose(_sf.chooseBox,true); flashChoose(_sf.chooseKey,false); }; /** * update skill select * @param ctrl | selected skill control * @param obj | data of key */ this.updateSkill = function(ctrl,obj){ if(_sf.skillData.length <= 0)return; tempSelect = _sf.selectIndex = ctrl.ctrlIndex; tempSelectKey = _sf.selectKeyIndex = 0; tempKeyObj = nullKeyObj; if(obj != tempObj){ RV.GameSet.playSelectSE(); tempObj = obj; _sf.chooseBox.x = ctrl.x; _sf.chooseBox.y = ctrl.y; _sf.textDetails.obj = _sf.detailsData[_sf.selectIndex]; _sf.callPage = false; }else{ _sf.showShortcut(ctrl,obj); updateFlash(); } }; /** * show key select-box * @param ctrl | selected skill control * @param obj | data of control */ this.showShortcut = function(ctrl,obj){ _sf.callPage = true; _sf.backKey.width = (40 + 2) * _sf.keyList.length + 2 * 4; _sf.chooseBox.actionLoop = false; RV.GameSet.playEnterSE(); _sf.backKey.x = ctrl.x + ctrl.width + _sf.viewportSkill.x - 12; _sf.backKey.y = ctrl.y + _sf.viewportSkill.y + _sf.viewportSkill.oy; _sf.buttonKeyList.x = _sf.backKey.x + 4; _sf.buttonKeyList.y = _sf.backKey.y + 10; _sf.chooseKey.x = _sf.buttonKeyList.x; _sf.chooseKey.y = _sf.buttonKeyList.y; _sf.selectUserSkillIndex = obj.index; }; /** * update shortcut key select * @param ctrl | selected key * @param obj | data of key */ this.updateKey = function(ctrl,obj){ tempSelectKey = _sf.selectKeyIndex = ctrl.ctrlIndex; if(obj != tempKeyObj){ tempKeyObj = obj; RV.GameSet.playSelectSE(); _sf.chooseKey.x = ctrl.x; _sf.chooseKey.y = ctrl.y; }else{ RV.GameSet.playEquipSE(); selectKey(ctrl,obj); tempSelectKey = _sf.selectKeyIndex = 0; } }; /** * update this interface */ this.update = function(){ if(_sf.viewportSkill.oy > 0){ this.callPage = false; } if(_sf.callPage == false){ updateBagKey(); }else{ updateShortcutKey(); } if(IInput.isKeyDown(RC.Key.cancel)){ if(_sf.callPage == false){ _sf.closeUI(); }else{ _sf.callPage = false; } } }; /** * dispose this interface */ this.dispose = function(){ RV.GameSet.playCancelSE(); LUI.DisposeCtrl(_sf.ctrlItems); }; //==================================== Private Function =================================== /** * update PC Key */ function updateBagKey(){ //Move down if(IInput.isKeyDown(RC.Key.down)){//Move down tempSelect = _sf.selectIndex + 1; } //Move up if(IInput.isKeyDown(RC.Key.up)){//Move up tempSelect = _sf.selectIndex - 1; } if(tempSelect < 0){ tempSelect = _sf.skillData.length - 1; } if(tempSelect > _sf.skillData.length - 1){ tempSelect = 0; } if(_sf.selectIndex != tempSelect){ _sf.updateSkill(_sf.skillBag.ctrlItems[tempSelect],_sf.skillBag.ctrlItems[tempSelect].obj); var tx = _sf.chooseBox.x + _sf.viewportSkill.ox + _sf.viewportSkill.x; var ty = _sf.chooseBox.y + _sf.viewportSkill.oy + _sf.viewportSkill.y; var rect = new IRect(tx , ty , tx + 2,ty + _sf.chooseBox.height); if(!_sf.viewportSkill.GetRect().intersects(rect)){ _sf.viewportSkill.oy = (_sf.chooseBox.y - (_sf.viewportSkill.height / 2) - _sf.chooseBox.height) * -1; if(_sf.viewportSkill.oy > 0) _sf.viewportSkill.oy = 0; } } if(IInput.isKeyDown(RC.Key.ok)){ _sf.updateSkill(_sf.skillBag.ctrlItems[_sf.selectIndex],_sf.skillBag.ctrlItems[_sf.selectIndex].obj); } } /** * select shortcut key */ function updateShortcutKey(){ if(IInput.isKeyDown(RC.Key.right)){ tempSelectKey = _sf.selectKeyIndex + 1; } if(IInput.isKeyDown(RC.Key.left)){ tempSelectKey = _sf.selectKeyIndex - 1; } if(tempSelectKey < 0){ tempSelectKey = _sf.keyList.length - 1; } if(tempSelectKey > _sf.keyList.length - 1){ tempSelectKey = 0; } if(_sf.selectKeyIndex != tempSelectKey){ _sf.updateKey(_sf.buttonKeyList.ctrlItems[tempSelectKey],_sf.buttonKeyList.ctrlItems[tempSelectKey].obj); } if(IInput.isKeyDown(RC.Key.ok)){ _sf.updateKey(_sf.buttonKeyList.ctrlItems[_sf.selectKeyIndex],_sf.buttonKeyList.ctrlItems[_sf.selectKeyIndex].obj); } } /** * set shortcut key * @param ctrl | key control * @param obj | data of key */ function selectKey (ctrl,obj){ var tempCtrl = _sf.skillBag.ctrlItems[_sf.selectIndex]; if(ctrl.ctrlIndex == 0){ RV.GameData.userSkill[_sf.selectUserSkillIndex] = 0; _sf.skillData[_sf.selectIndex].key = " "; LUI.setText(tempCtrl.textKey," "); }else{ RV.GameData.userSkill[ctrl.ctrlIndex - 1] = 0; for(var i = 0; i< RV.NowSet.setAll.maxSkills; i++){ if(RV.GameData.userSkill[i] == _sf.skillData[_sf.selectIndex].data.id){ RV.GameData.userSkill[i] = 0; } } unload(obj.name); RV.GameData.userSkill[ctrl.ctrlIndex - 1] = _sf.skillData[_sf.selectIndex].data.id; _sf.skillData[_sf.selectIndex].key = obj.name; _sf.skillBag.ctrlItems[_sf.selectIndex].obj.index = _sf.skillData[_sf.selectIndex].index = ctrl.ctrlIndex - 1; tempCtrl.textKey.data.isAutoUpdate = false; LUI.setText(tempCtrl.textKey,"\\s[14]" + obj.name); tempCtrl.textKey.x = tempCtrl.shortcutKey.x + (tempCtrl.shortcutKey.width - tempCtrl.textKey.width) / 2; tempCtrl.textKey.data.isAutoUpdate = true; } _sf.callPage = false; updateFlash(); } /** * unload skill * @param name | select shortcut key */ function unload(name){ for(var i = 0; i< _sf.skillBag.ctrlItems.length; i++){ if(name != " " && _sf.skillBag.ctrlItems[i].obj.key == name){ _sf.skillData[i].key = " "; _sf.skillData[i].index = -1; } } } /** * flash chooseBox * @param choose | choose box * @param bool | flash or not */ function flashChoose(choose,bool){ choose.actionLoop = bool; choose.addAction(action.fade,0.6,20); choose.addAction(action.wait,20); choose.addAction(action.fade,1,20); choose.addAction(action.wait,20); } /** * activate chooseBox */ function updateFlash(){ if(_sf.callPage == false){ _sf.chooseBox.actionLoop = true; _sf.chooseKey.actionLoop = false; }else{ _sf.chooseBox.actionLoop = false; _sf.chooseKey.actionLoop = true; } } /** * set keyList */ function setKeyList(bool){ nullKeyObj = {code : -1,name : "None"}; _sf.keyList.push(nullKeyObj); var pc = bool; for(var i = 0; i < RV.NowSet.setAll.maxSkills; i ++){ var tempKey = null; var tempKeyList = null; if(pc){ tempKey = RC.Key["skill" + (i + 1)]; tempKeyList = { code : tempKey, name : RC.CodeToSting(tempKey) }; }else{ tempKey = i + 1; tempKeyList = { code : 0, name : tempKey }; } _sf.keyList.push(tempKeyList); } } }