PE_kind = 0; PE_index = 0; PE_OldTime = {}; PE_NewTime = {}; PE_TimeCaculate = {}; PE_EventName = 0; PE_index = {}; NUM_MAXPEITEM = 10; --Frame�ƶq ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ function PublicEncounterFrame_OnUpdate(this, elapsedTime) if(this.state==1) then this.RetainTime = this.RetainTime - elapsedTime ; if(this.RetainTime <= 0)then local id = this:GetID(); local iFrame = getglobal("PEFs_Item"..id); iFrame:Hide(); this.state = 0; PEFs_Reset(this); end end if(this.Updateframe == 0)then if(this.RetainTime <= 0) then this.Updateframe = 1; end end end ------------------------------------------------------------------------------------ function POBF_TimeUpdtate(sec) local objC; if( PE_kind == 0 ) then --iKind == 0 ���\��� objC = getglobal("PEF_Info_SuccesCondition_"..PE_index.."_TimeText"); elseif( PE_kind == 1 )then --iKind == 1 ���ѱ�� objC = getglobal("PEF_Info_LoseCondition_"..PE_index.."_TimeText"); end local min , temp_m , temp_s , tempT ; if(sec >=60) then min = math.floor( sec / 60 ) ; sec = sec%60 ; if( min < 10) then temp_m = string.format("%s%d" ,"0",min); else temp_m = string.format("%d" ,min); end if(sec<10) then temp_s = string.format("%s%d" ,":0",sec); else temp_s = string.format("%s%d" ,":",sec); end tempT = string.format("%s%s" ,temp_m ,temp_s); else temp_m = string.format("%s" ,"00"); if(sec<10) then temp_s = string.format("%s%d" ,":0",sec); else temp_s = string.format("%s%d" ,":",sec); end end tempT = string.format("%s%s" ,temp_m ,temp_s); objC:SetText(tempT); end ------------------------------------------------------------------------------------ function PublicEncounterFrame_RetainTime(this) this.state = 1; this.RetainTime = 15; end ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ --[[�ƶq�B�ɶ����ܧ�s�ϥ� this.Name************���W�� this.Doorsill ***********�����e this.iNowValue*********�ɶ��ίu��ƶq this.pkind*************��������@:���\0/����1 this.index*************��󦸧� this.type*************��������G:�ƶq/�ɶ�7 --]] ------------------------------------------------------------------------------------ function PEFs_Clear() local objPH; for i = 1 , 10 do for j = 1 , 10 do objPH = getglobal("PEFs_Item"..i.."_Info_SuccesCondition_"..j); objPH:Hide(); objPH = getglobal("PEFs_Item"..i.."_Info_LoseCondition_"..j); objPH:Hide(); objPH = getglobal("PEFs_Item"..i.."_Info_SuccesCondition_"..j.."_Time"); objPH:Hide(); objPH = getglobal("PEFs_Item"..i.."_Info_SuccesCondition_"..j.."_TimeText"); objPH:Hide(); objPH = getglobal("PEFs_Item"..i.."_Info_LoseCondition_"..j.."_Time"); objPH:Hide(); objPH = getglobal("PEFs_Item"..i.."_Info_LoseCondition_"..j.."_TimeText"); objPH:Hide(); end end end ------------------------------------------------------------------------------------ function PEScoreUpdate() local objPE_T = getglobal("PEF_Info_Score_Text"); local Scorecount = PE_GetPEScore(); objPE_T:SetText(PUBLICENCOUNTER_SCORE..": "..Scorecount); if(not PEF_Info:IsVisible() )then objPH = getglobal("PEF_Button_Text"); objPH:SetText(PUBLICENCOUNTER_SCORE..": "..Scorecount); end local HIGHLIGHT = getglobal("PEF_Info_Score_Highlight"); HIGHLIGHT:Show(); end ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ ------------------------------------------------------------------------****�����s function PEFrame_Button_OnClick(this,key) if ( key == "RBUTTON" and IsShiftKeyDown() ) then elseif( key == "LBUTTON")then local id = this:GetParent():GetParent():GetID(); local objA = getglobal("PEFs_Item"..id.."_Button_Text"); local objB = getglobal("PEFs_Item"..id.."_Info"); if(objB:IsVisible()) then index = PE_index[id] ; local _,_,_,ScorePE , _ , IsScoreShow= PE_GetInfo(index); --����PE_index if( IsScoreShow ) then if(ScorePE) then objA:SetText(PUBLICENCOUNTER_SCORE..": "..ScorePE); else objA:SetText(PUBLICENCOUNTER_SCORE..": 0"); end objA:SetColor( 1, 1, 0 ); objB:Hide(); else local PEName = PE_GetPEName(); --PE�W�� objA:SetText(PEName); objA:SetColor( 0.27,0.79, 0.8 ); objB:Hide(); end else local PEName = PE_GetPEName(); --PE�W�� objA:SetText(PEName); objA:SetColor( 0.27,0.79, 0.8 ); objB:Show(); end this = this:GetParent(); PEFs_Reset(this); end end ------------------------------------------------------------------------****�����s function PEFrame_Button_OnMouseDown(this, key) if ( key == "RBUTTON" and IsShiftKeyDown() ) then local id = this:GetParent():GetParent():GetID(); if(id == 1) then PEFs:StartMoving(); end end end ------------------------------------------------------------------------****�����s function PEFrame_Button_OnMouseUp(this) PEFs:StopMovingOrSizing(); end ------------------------------------------------------------------------------------ function PEFs_Button_OnEnter(this) local id = this:GetParent():GetParent():GetID(); if(id == 1) then GameTooltip:SetOwner(this, "ANCHOR_TOP",0,4); GameTooltip:SetText(PUBLICENCOUNTER_DRAG,0, 0.75, 0.95); GameTooltip:Show(); end end ------------------------------------------------------------------------------------ function PEF_OnEnter(this) local id = this:GetID(); local obj1 = getglobal("PEFs_Item"..id.."_Button"); id = id -1 ; local temp = PE_GetMessage(id); if(temp and temp ~= "") then GameTooltip:SetOwner( obj1, "ANCHOR_TOP",0,0);--65,-30); GameTooltip:SetText(temp); GameTooltip:Show(); end end ---------------------------------------------------------------------------------------------------------- ----------------------**************************************************************---------------------- ----------------------**************************************************************---------------------- ----------------------**************************************************************---------------------- ---------------------------------------------------------------------------------------------------------- function PEFs_OnLoad( this ) this:RegisterEvent( "VARIABLES_LOADED" ); this:RegisterEvent( "PE_INTO" ); --�i�J V this:RegisterEvent( "PE_LEAVE" ); --��} V this:RegisterEvent( "PE_SUCCESS" ); --������Ȧ��\����� V this:RegisterEvent( "PE_FAILED" ); --������ȥ��ѵ���� v this:RegisterEvent( "PE_ACTIVE_PHASE_CHANGE" ); --������ȶ��q�ܴ���, ��s������ܤ��e V this:RegisterEvent( "PE_OBJECTIVE_VALUE_CHANGE" ); --���\�Υ��ѱ�󪺱����ܧ��, ��s������ܤ��e V this:RegisterEvent( "PE_PHASE_SUCCESS" ); --������ȶ��q���\����� this:RegisterEvent( "PE_PHASE_FAILED" ); --������ȶ��q���ѵ���� this:RegisterEvent( "PE_OBJECTIVE_ACHIEVED" ); --������ȶ��q���F����(�L�צ��\�Υ��ѱ��), ��s������ܤ��e this:RegisterEvent( "PE_PLAYER_SCORE" ); this:RegisterEvent( "PE_LeaveAndClose" ); end ------------------------------------------------------------------------------------ function PEFs_OnEvent( this, event ) if( event == "VARIABLES_LOADED") then end if( event == "PE_INTO") then --�i�J if(PEFs:IsVisible()) then PEFs_Reset(this); else PEFs:Show(); end end if(event == "PE_LEAVE")then --��}or���� PEFs_Reset(this); end if( event == "PE_OBJECTIVE_VALUE_CHANGE") then --���\�Υ��ѱ�󪺱����ܧ�� local OBname = arg1; local Doorsill = arg2; local iNowValue = arg3; local pkind = arg4; local index = arg5; local ptype = arg6; local iframe = arg7; if( ptype == 7 )then iNowValue= math.floor(iNowValue/1000); local obj ; if( pkind == 0 ) then obj = getglobal("PEFs_Item"..iframe.."_Info_SuccesCondition_"..index); elseif( pkind == 1 ) then obj = getglobal("PEFs_Item"..iframe.."_Info_LoseCondition_"..index); end obj.PE_TimeCaculate = 1 ; obj.PE_OldTime = iNowValue; obj.PE_NewTime = iNowValue - 1; end PEFs_Reset(this); local Highlight; if(iframe and ptype ~= 7 ) then if( pkind == 0 ) then Highlight = getglobal("PEFs_Item"..iframe.."_Info_SuccesCondition_"..index.."_Highlight"); Highlight:Show(); elseif( pkind == 1 ) then Highlight = getglobal("PEFs_Item"..iframe.."_Info_LoseCondition_"..index.."_Highlight"); Highlight:Show(); end end end if( event == "PE_PLAYER_SCORE") then --�n����� local k , score; k = arg1; score = arg2; local obj1,obj2; local obj = getglobal("PEFs_Item"..k.."_Info"); if(obj:IsVisible()) then obj1 = getglobal("PEFs_Item"..k.."_Info_Score_Text"); obj1:SetText(PUBLICENCOUNTER_SCORE..": "..score); obj2 = getglobal("PEFs_Item"..k.."_Info_Score_Highlight"); obj2:Show(); else obj1 = getglobal("PEFs_Item"..k.."_Button_Text"); obj1:SetText(PUBLICENCOUNTER_SCORE..": "..score); end end if( event == "PE_ACTIVE_PHASE_CHANGE") then --������ȶ��q�ܴ��� PEFs_Reset(this); end if( event == "PE_PHASE_SUCCESS") then --���q���\ PEFs_Reset(this); end if( event == "PE_PHASE_FAILED") then --���q���� PEFs_Reset(this); end if( event == "PE_OBJECTIVE_ACHIEVED") then --������ȶ��q���F���� this.state = 0; PEFs_Reset(this); end if( event == "PE_SUCCESS" or event == "PE_FAILED") then --������Ȧ��\�Υ��ѵ��� local Index = arg1; if( Index >=1 and Index <= 10) then local obj = getglobal("PEFs_Item"..Index); --[[l local ObjSN = getglobal("PEFs_Item"..Index.."_Info"); local objSC = getglobal("PEFs_Item"..Index.."_Info_Score"); objSC:ClearAllAnchors(); objSC:SetAnchor("TOPLEFT", "BOTTOMLEFT", ObjSN , 0, -35); ]]-- PublicEncounterFrame_RetainTime(obj); end end if( event == "PE_LeaveAndClose" ) then PEFs:Hide(); end end ------------------------------------------------------------------------------------ function PEFs_OnShow( this ) PEFs_Reset(this); end ------------------------------------------------------------------------------------ function PEFs_Reset(this) PEFs_Clear(); PE_index = {}; local numPE = PE_GetPEIndex(-1); -- ��o�ثe�ϰ�PE���ƶq if( numPE == 0 ) then PEFs:Hide(); else PEFs:Show(); local j; for i = 1, numPE , 1 do local index = PE_GetPEIndex(i); if(index ~= nil ) then table.insert( PE_index , index ); local PEFrame = getglobal("PEFs_Item"..i); PEFrame:Show(); local Ysize = PEFs_SetDetail(PEFrame, index ); if( i ~= 1 ) then j = i - 1; local PEFrame_old = getglobal("PEFs_Item"..j); PEFrame:Show(); PEFrame:ClearAllAnchors(); local obj = getglobal("PEFs_Item"..j.."_Info"); if( obj:IsVisible()) then PEFrame:SetAnchor("TOPLEFT", "BOTTOMLEFT", PEFrame_old , 0, Ysize); else PEFrame:SetAnchor("TOPLEFT", "BOTTOMLEFT", PEFrame_old , 0, 16); end end end end end if( numPE < NUM_MAXPEITEM ) then for i = numPE+1, NUM_MAXPEITEM, 1 do PEFrame = getglobal("PEFs_Item"..i); PEFrame:Hide(); end end end ------------------------------------------------------------------------------------ function PEFs_SetDetail(PEFrame, index ) local namePE,messagePE,namePH,ScorePE,Count , IsScoreVisible= PE_GetInfo(index); --����PE_index local objPE,objPH,objScore; objPE = getglobal(PEFrame:GetName().."_Info"); if(objPE:IsVisible() ) then objPE = getglobal(PEFrame:GetName().."_Button_Text"); objPE:SetText(namePE); objPE:SetColor( 0.27,0.79, 0.8 ); else if(IsScoreVisible and ScorePE) then objPE = getglobal(PEFrame:GetName().."_Button_Text"); objPE:SetText(PUBLICENCOUNTER_SCORE..": "..ScorePE); else objPE = getglobal(PEFrame:GetName().."_Button_Text"); objPE:SetText(PUBLICENCOUNTER_SCORE..": 0"); end objPE:SetColor( 1, 1, 0 ); end objPH = getglobal(PEFrame:GetName().."_Info_PH_Text"); objPH:SetText(namePH); objScore = getglobal(PEFrame:GetName().."_Info_Score".."_Text"); if(ScorePE) then objScore:SetText(PUBLICENCOUNTER_SCORE..": "..ScorePE); else objScore:SetText(PUBLICENCOUNTER_SCORE..": 0"); end local objPOB; local m,n,k,i; local temp; m = 1; n = 1; k = 0; if(Count and Count ~= 0 and Count <= 20 ) then for i = 1, Count , 1 do -- ��Ƽg�J local namePOB , itype , ikind , nowvalue, doolsill = PE_GetPOBInfo( index , i-1 ); if(doolsill) then if( ikind == 0 ) then objPOB = getglobal(PEFrame:GetName().."_Info_SuccesCondition_"..m); m = m + 1 ; k = k + 1 ; else--if( ikind == 1) then objPOB = getglobal(PEFrame:GetName().."_Info_LoseCondition_"..n); n = n + 1 ; k = k + 1 ; end objPOB:Show(); if(itype ~= 7) then temp = namePOB.." ("..nowvalue.."/"..doolsill..")"; local objT_ = getglobal(objPOB:GetName().."_TimeText"); objT_:Hide(); objT_ = getglobal(objPOB:GetName().."_Time"); objT_:Hide(); elseif(itype == 7) then nowvalue= math.floor(nowvalue/1000); nowvalue = nowvalue - 1 ; local tempTime = PE_Time(nowvalue); local objT_ = getglobal(objPOB:GetName().."_TimeText"); objT_:Show(); objT_:SetText(tempTime); objT_ = getglobal(objPOB:GetName().."_Time"); objT_:Show(); temp = namePOB; end objPOB = getglobal(objPOB:GetName().."_Text"); objPOB:SetText(temp); end end end objPH = getglobal(PEFrame:GetName().."_Info_PH"); objScore = getglobal(PEFrame:GetName().."_Info_Score"); local objSC_1, objSC_old,objFC_1, objFC_old; local j; for i = 1, m-1 , 1 do -- ��m�վ� objSC_1 = getglobal(PEFrame:GetName().."_Info_SuccesCondition_"..i); objSC_1:Show(); objSC_1:ClearAllAnchors(); if( i == 1 ) then objSC_1:SetAnchor("TOPLEFT", "BOTTOMLEFT", objPH , 0, 7); else j = i - 1; --objSC_old = getglobal(PEFrame:GetName().."_SuccesCondition_"..j); objSC_old = getglobal(PEFrame:GetName().."_Info_SuccesCondition_"..j); objSC_1:SetAnchor("TOPLEFT", "BOTTOMLEFT", objSC_old , 0, 7); end end for i = 1, n-1 , 1 do -- ��m�վ� objFC_1 = getglobal(PEFrame:GetName().."_Info_LoseCondition_"..i); objFC_1:Show(); objFC_1:ClearAllAnchors(); if( m > 1) then objSC_1 = getglobal(PEFrame:GetName().."_Info_SuccesCondition_"..i); if( i == 1 ) then objFC_1:SetAnchor("TOPLEFT", "BOTTOMLEFT", objSC_1 , 0, 7); -- 0 -35 else j = i - 1; objFC_old = getglobal(PEFrame:GetName().."_Info_LoseCondition_"..j); objFC_1:SetAnchor("TOPLEFT", "BOTTOMLEFT", objFC_old , 0, 7); end elseif( m == 1 )then if( i == 1 ) then objFC_1:SetAnchor("TOPLEFT", "BOTTOMLEFT", objPH , 0, 7); else j = i - 1; objFC_old = getglobal(PEFrame:GetName().."_Info_LoseCondition_"..j); objFC_1:SetAnchor("TOPLEFT", "BOTTOMLEFT", objFC_old , 0, 7); end end end if( IsScoreVisible )then objScore:Show(); objScore:ClearAllAnchors(); if( m == 1 and n == 1) then --�L��� objScore:SetAnchor("TOPLEFT", "BOTTOMLEFT", objPH , 0, 7); elseif(m ~= 1 and n == 1) then -- �����\��� �L���� objSC_1 = getglobal(PEFrame:GetName().."_Info_SuccesCondition_"..m-1); objScore:SetAnchor("TOPLEFT", "BOTTOMLEFT", objSC_1 , 0, 7); elseif( n ~= 1) then -- �����ѱ�� objFC_1 = getglobal(PEFrame:GetName().."_Info_LoseCondition_"..n-1); objScore:SetAnchor("TOPLEFT", "BOTTOMLEFT", objFC_1 , 0, 7); end else objScore:Hide(); end --�p��frame���j�p,�M��^�� local Ysize; Ysize = k; Ysize = Ysize * 17 + 40; return Ysize ; end ------------------------------------------------------------------------------------ function PE_Time(sec) local min ; local tempT,temp_m,temp_s; if( sec > 0) then --sec = sec - 1 ; if(sec >=60) then min = math.floor( sec / 60 ) ; sec = sec%60 ; if( min < 10) then temp_m = string.format("%s%d" ,"0",min); else temp_m = string.format("%d" ,min); end if(sec<10) then temp_s = string.format("%s%d" ,":0",sec); else temp_s = string.format("%s%d" ,":",sec); end tempT = string.format("%s%s" ,temp_m ,temp_s); else temp_m = string.format("%s" ,"00"); if(sec<10) then temp_s = string.format("%s%d" ,":0",sec); else temp_s = string.format("%s%d" ,":",sec); end end tempT = string.format("%s%s" ,temp_m ,temp_s); else tempT = string.format("%s","00:00"); end return tempT; end ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ SuccesCondition_1_Highlight LoseCondition_1 function PE_Icon_HighlightOnUpdate(this,elapsedTime) local _HightLight = getglobal(this:GetName().."_Highlight"); if ( _HightLight.alphaValue == nil ) then _HightLight.alphaValue = 0; end if(_HightLight.playCount == nil)then _HightLight.playCount = 0; end if ( not _HightLight.state ) then _HightLight.alphaValue = _HightLight.alphaValue + elapsedTime * 1; if ( _HightLight.alphaValue > 2 ) then _HightLight.alphaValue = 1; _HightLight.state = 1; end else _HightLight.alphaValue = _HightLight.alphaValue - elapsedTime * 1; if ( _HightLight.alphaValue < 0 ) then _HightLight.alphaValue = 0; _HightLight.state = nil; _HightLight.playCount = _HightLight.playCount + 1; end end _HightLight:SetAlpha(_HightLight.alphaValue); if( _HightLight.playCount >= 3 )then _HightLight:Hide(); _HightLight.playCount = 0; end -- -- -- -- -- -- -- �p�� -- -- -- -- -- -- -- -- -- -- -- -- -- -- if(this.PE_TimeCaculate == 1) then this.PE_OldTime = this.PE_OldTime - elapsedTime; if( this.PE_OldTime <= this.PE_NewTime ) then local temp = PE_Time( this.PE_OldTime ); local obj = getglobal(this:GetName().."_TimeText"); obj:SetText(temp); if(this.PE_NewTime <= 10) then obj:SetColor(1,0,0); else obj:SetColor(1,1,1); end if( this.PE_NewTime >=1 ) then this.PE_NewTime = this.PE_NewTime - 1 ; end end if(this.PE_OldTime < 0) then this.PE_TimeCaculate = 0; end end end ------------------------------------------------------------------------------------ function PE_Icon_OnEnter(this) local ID1 = this:GetID(); --PEFs_Item1_Info_SuccesCondition_"ID1" local ID2 = this:GetParent():GetParent():GetID(); --PEFs_Item"ID2"_Info_SuccesCondition_"ID1" local id = this:GetID(); local obj1 = getglobal("PEFs_Item"..id.."_Button"); id = id -1 ; local temp; if( ID1 < 11 ) then temp = POB_GetMessage(PE_GetPEIndex(ID2) , ID1 , 0 ); else temp = POB_GetMessage(PE_GetPEIndex(ID2) , ID1 - 10 , 1 ); end if( temp and temp ~="") then GameTooltip:SetOwner( this, "ANCHOR_RIGHT", 0, 0 ); GameTooltip:SetText(temp); end end ------------------------------------------------------------------------------------ function PH_Icon_OnEnter(this) local id = this:GetParent():GetParent():GetID(); local temp = POB_GetMessage(PE_GetPEIndex(id) , 0 , 2 ); if(temp and temp ~="") then GameTooltip:SetOwner( this, "ANCHOR_RIGHT", 0, 0 ); GameTooltip:SetText(temp); end end ------------------------------------------------------------------------------------