decompiled panorama scripts, lets try it out
This commit is contained in:
75
panorama/scripts/custom_game/shop.js
Normal file
75
panorama/scripts/custom_game/shop.js
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
|
||||
var ShopUnit = -1;
|
||||
|
||||
function Update() {
|
||||
var gold = Players.GetGold(Players.GetLocalPlayer()) + Players.GetLastBuybackTime(Players.GetLocalPlayer());
|
||||
$("#GoldText").text = gold;
|
||||
|
||||
var AbilityList = $("#AbilityList");
|
||||
var max = AbilityList.GetChildCount();
|
||||
for (var i = 0; i < max; i++) {
|
||||
var panel = AbilityList.GetChild(i);
|
||||
panel.SetHasClass("CanBuy", gold >= panel.GetAttributeInt("Gold", 0));
|
||||
}
|
||||
|
||||
$.Schedule(0.2, Update);
|
||||
}
|
||||
|
||||
if (!Players.IsSpectator(Players.GetLocalPlayer())) {
|
||||
Update();
|
||||
} else {
|
||||
$("#ShopContent").DeleteAsync(0.0);
|
||||
$("#BottomBar").DeleteAsync(0.0);
|
||||
}
|
||||
|
||||
// 获取商店单位
|
||||
$.Schedule(5, function () {
|
||||
if (Players.IsSpectator(Players.GetLocalPlayer())) {
|
||||
return;
|
||||
}
|
||||
var unitList = Entities.GetAllEntitiesByClassname("npc_dota_creature");
|
||||
for (var i = 0; i < unitList.length; i++) {
|
||||
if (Entities.GetUnitName(unitList[i]) === "minoriko_shop" &&
|
||||
Entities.IsControllableByPlayer(unitList[i], Players.GetLocalPlayer())) {
|
||||
ShopUnit = unitList[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function setAbilityEvent( panel ) {
|
||||
panel.SetDraggable(true);
|
||||
panel.SetPanelEvent("onmouseover", function () {
|
||||
$.DispatchEvent("DOTAShowAbilityTooltip", panel, panel.abilityname);
|
||||
});
|
||||
panel.SetPanelEvent("onmouseout", function () {
|
||||
$.DispatchEvent("DOTAHideAbilityTooltip");
|
||||
});
|
||||
panel.SetPanelEvent("oncontextmenu", function () {
|
||||
Game.PrepareUnitOrders({
|
||||
OrderType: dotaunitorder_t.DOTA_UNIT_ORDER_CAST_NO_TARGET,
|
||||
UnitIndex: ShopUnit,
|
||||
AbilityIndex: panel.contextEntityIndex,
|
||||
OrderIssuer: PlayerOrderIssuer_t.DOTA_ORDER_ISSUER_PASSED_UNIT_ONLY,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var AbilityList = $("#AbilityList");
|
||||
for (var i = 0; i < 7; i++) {
|
||||
var ability = Entities.GetAbility( ShopUnit, i )
|
||||
if (ability > 0) {
|
||||
// var abilityname = Abilities.GetAbilityName(ability);
|
||||
if (Abilities.IsHidden(ability) || Abilities.IsAutocast(ability)) continue;
|
||||
var panel = $.CreatePanel("DOTAAbilityImage", AbilityList, "");
|
||||
var gold = Abilities.GetSpecialValueFor(ability, "cost") || 0;
|
||||
panel.contextEntityIndex = ability;
|
||||
panel.SetAttributeInt("Gold", gold);
|
||||
setAbilityEvent( panel );
|
||||
|
||||
var label = $.CreatePanel("Label", panel, "");
|
||||
label.text = gold
|
||||
label.AddClass("Gold");
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user