local prop_Id=1106022000000000--尖叫鸭
function GameClient:OnStart()
printLog("[GameClient:OnStart]")
self.Time = TimerManager:GetTimeSeconds()
System:BindNotify(NetMsg.SeverLog, self.OnSeverLog, self)
local player_Id=Character:GetLocalPlayerId()
Character:AddProp(player_Id,prop_Id)
--备注:如果对API的使用存在疑惑,可以将鼠标悬浮在API上查看提示,也可以查询API手册,我们为每个API都提供了用例。
Events.ON_CHARACTER_ENTER_SIGNAL_BOX,
function (playerId, signalBoxId) --playerId = 玩家id, signalBoxId = 信号触发盒id
printLog("ON_CHARACTER_ENTER_SIGNAL_BOX", playerId, signalBoxId)
if signalBoxId== box_trigger then
local monster=Creature:SpawnCreatureBySceneID(monster_id, Engine.Vector(0, 0, 100), Engine.Vector(0, 0, 0))
Creature:CreatureSwitchBehaviorToFollowPlayer(monster, player_Id, 9999, 5, 20)
TimerManager:AddLoopTimer(delay_time,
Character:AddProp(player_Id,prop_Id)
Events.ON_BEFORE_CREATURE_TAKING_DAMAGE,
function (creatureId, killer, damage) -- creatureId = 生物ID, killer = 发出伤害的ID, damage = 伤害的数值
local pos = Creature:GetPosition(creatureId)
local effectId = Particle:PlayAtPosition(effect_type_id, pos, effect_size, true, 1)
local socre_string='当前分数为'..tostring(socre)
UI:SetText({ui_socre},socre_string)
function GameClient:OnUpdate()
local currentTime = TimerManager:GetTimeSeconds()
local delta = currentTime - self.Time -- 与上一次更新时的时间间隔,单位是秒
local lastSentTime = self.lastSentTime or 0 --上一次发送消息的时间
if lastSentTime > 10 then
local count = self.lastSentCount or 1
self.lastSentCount = count + 1
System:SendToServer(NetMsg.ClientReq, msg)
self.lastSentTime = lastSentTime + delta