|
|
function drawMonsterHpPercent(obj, object)
{
if(!object || object.isDead())
return;
local monsterObject = sq_GetObjectByObjectId(obj, DRAW_MONSTER_ID);
if (!monsterObject) return;
monsterObject = sq_GetCNRDObjectToActiveObject(monsterObject);
if (!monsterObject) return;
local maxhp = monsterObject.getHpMax();
local currhp = monsterObject.getHp();
local hpPercent = (currhp * 100.0 / maxhp).tointeger();
//print("drawMonsterHpPercent: currhp=" + currhp + ", maxhp=" + maxhp + ", hpPercent=" + hpPercent);
drawBloodNum(obj, hpPercent, 537, 77, 2);
}
function drawBloodNum(obj, num, Xpos, Ypos, Justify)
{
if(num < 0)
num = 0;
local str = num.tostring();
local Strin = {
["0"] = 60,
["1"] = 61,
["2"] = 62,
["3"] = 63,
["4"] = 64,
["5"] = 65,
["6"] = 66,
["7"] = 67,
["8"] = 68,
["9"] = 69
}
local NumLeng = str.len();
local Space = 8;
local aniName = "BloodHpPercent";
local AniPath = "map/trainingroom/damage_analyse.ani";
local AniPath2 = "common/monster/blood_hp.ani";
local rate = 1.0;
local rate6 = 0.72;
if(Justify == 0)
Xpos = Xpos
else if(Justify == 1)
Xpos = Xpos - NumLeng*Space;
else if(Justify == 2)
Xpos = Xpos - NumLeng*Space/2;
for(local i = 0; i < NumLeng; i++)
{
local SingleNum = str.slice(i, i + 1);
drawBloodAniUI(obj, aniName, AniPath, rate, rate, 255, 255, 255, 255, Strin[SingleNum], Xpos + i*Space, Ypos);
}
local percentAniName = "TrainTuenPageNum";
drawBloodAniUI(obj, percentAniName, AniPath2, rate6, rate6, 255, 255, 255, 255, 0, Xpos + NumLeng*Space, Ypos);
}
function drawBloodAniUI(obj, aniName, AniPath, Xrate, Yrate, R, G, B, alpha, FramIndex, Xpos, Ypos)
{
local sq_var = obj.getVar();
local AniObj = sq_var.GetAnimationMap(aniName, AniPath);
sq_AnimationProc(AniObj);
AniObj.setImageRate(Xrate, Yrate);
AniObj.setRGBA(R, G, B, alpha);
sq_SetAnimationFrameIndex(AniObj, FramIndex);
sq_drawCurrentFrame(AniObj, Xpos, Ypos, false);
} |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|