require("Modules/Map/Config/MapConfig") local MapPointConfig = ConfigManager.GetConfig(ConfigName.MapPointConfig) MonsterLiveView = {} function MonsterLiveView:New(gameObj,iconId,scale) local b = {} b.gameObject = poolManager:LoadAsset("UI_MapPoint", PoolManager.AssetType.GameObject) b.gameObject.transform:SetParent(gameObj.transform) b.gameObject.name = "EventPoint" b.gameObject:SetActive(true) b.transform = b.gameObject.transform b.transform.localScale = Vector3.one b.gameObject.transform.localPosition = Vector3.zero Util.GetGameObject(b.gameObject, "shadow"):SetActive(true) b.resPath = "UI_MapPoint" b.livePath = MapFloatingConfig[iconId].name b.iconId = iconId b.live2d = poolManager:LoadLive(MapFloatingConfig[iconId].name, Util.GetTransform(b.gameObject, "root"), MapFloatingConfig[iconId].scale1, MapFloatingConfig[iconId].position) b.skeleton = b.live2d:GetComponent("SkeletonGraphic") self.oldPlayerDirAnimation = 0 self.oldPlayerDiry = 0 setmetatable(b, { __index = MonsterLiveView }) return b end function MonsterLiveView:SetWalkDir(dir) if dir == WALK_DIR.IDLE_FRONT then-- 站立_向前 self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE) elseif dir == WALK_DIR.IDLE_BACK then-- 站立_向后 self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLEBACK) elseif dir == WALK_DIR.IDLE_LEFT then-- 站立_向左 self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE) elseif dir == WALK_DIR.IDLE_RIGHT then-- 站立_向右 self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE) elseif dir == WALK_DIR.RUN_RIGHT then-- 跑_向右 self:SetWalkDirInfo(PLAYER_WALK_DIR.RIGHT) elseif dir == WALK_DIR.RUN_LEFT then-- 跑_向左 self:SetWalkDirInfo(PLAYER_WALK_DIR.LEFT) elseif dir == WALK_DIR.RUN_UP then-- 跑_向上 self:SetWalkDirInfo(PLAYER_WALK_DIR.UP) elseif dir == WALK_DIR.RUN_DOWN then-- 跑_向下 self:SetWalkDirInfo(PLAYER_WALK_DIR.DOWN) end end function MonsterLiveView:SetWalkDirInfo(playerDir) if playerDir and (self.oldPlayerDirAnimation ~= playerDir.animation or self.oldPlayerDiry ~= playerDir.y) then self.skeleton.transform.localEulerAngles = Vector3.New(0, playerDir.y, 0) self.skeleton.AnimationState:SetAnimation(0, playerDir.animation, true) self.oldPlayerDirAnimation = playerDir.animation self.oldPlayerDiry = playerDir.y end end function MonsterLiveView:OnClose() if self.live2d then poolManager:UnLoadLive(self.livePath, self.live2d) end self.live2d = nil if self.gameObject then poolManager:UnLoadAsset(self.resPath, self.gameObject, PoolManager.AssetType.GameObject) self.gameObject = nil end end