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].scale, 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(MONSTER_WALK_DIR.IDLE,true) elseif dir == WALK_DIR.IDLE_BACK then-- 站立_向后 self:SetWalkDirInfo(MONSTER_WALK_DIR.IDLEBACK,true) elseif dir == WALK_DIR.IDLE_LEFT then-- 站立_向左 self:SetWalkDirInfo(MONSTER_WALK_DIR.LEFT,true) elseif dir == WALK_DIR.IDLE_RIGHT then-- 站立_向右 self:SetWalkDirInfo(MONSTER_WALK_DIR.RIGHT,true) elseif dir == WALK_DIR.RUN_RIGHT then-- 跑_向右 self:SetWalkDirInfo(MONSTER_WALK_DIR.RUN_RIGHT,true) elseif dir == WALK_DIR.RUN_LEFT then-- 跑_向左 self:SetWalkDirInfo(MONSTER_WALK_DIR.RUN_LEFT,true) elseif dir == WALK_DIR.RUN_UP then-- 跑_向上 self:SetWalkDirInfo(MONSTER_WALK_DIR.RUN_UP,true) elseif dir == WALK_DIR.RUN_DOWN then-- 跑_向下 self:SetWalkDirInfo(MONSTER_WALK_DIR.RUN_DOWN,true) elseif dir == WALK_DIR.DEAD_LEFT then-- 死亡 左 self:SetWalkDirInfo(MONSTER_WALK_DIR.DEAD_LEFT,false) elseif dir == WALK_DIR.DEAD_RIGHT then-- 死亡 右、 self:SetWalkDirInfo(MONSTER_WALK_DIR.DEAD_RIGHT,false) elseif dir == WALK_DIR.DEAD_BACK then-- 死亡 后 self:SetWalkDirInfo(MONSTER_WALK_DIR.DEAD_BACK,false) elseif dir == WALK_DIR.DEAD_FRONT then-- 死亡 前 self:SetWalkDirInfo(MONSTER_WALK_DIR.DEAD_FRONT,false) end end function MonsterLiveView:SetWalkDirInfo(playerDir,isLoop) 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, isLoop) 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