ArrowComponent = ArrowComponent or BaseClass(BaseItem) function ArrowComponent:__init(parent_wnd) self.base_file = "common" self.layout_file = "ArrowComponent" self.arrowType = 1 self:Load() end function ArrowComponent:__delete() self:StopAnim() end function ArrowComponent:Load_callback() self.arrow = self:GetChild("Arrow") self:InitEvent() if self.need_refreshData then self:ShowArrow(self.type, self.pos, self.layer, self.show_type) end end function ArrowComponent:InitEvent() end function ArrowComponent:SetArrowType( arrowType ) self.arrowType = arrowType if self.is_loaded then self:SetArrowImg() end end function ArrowComponent:SetArrowImg( ) if self.arrowType == 1 then lua_resM:setImageSprite(self, self.arrow:GetComponent("Image"), "mainui_asset", "main_ui_tip", true) elseif self.arrowType == 2 then lua_resM:setImageSprite(self, self.arrow:GetComponent("Image"), "mainui_asset", "main_ui_tip2", true) --lua_resM:setImageSprite(self, self.arrow:GetComponent("Image"), "mainui_asset", "main_ui_tip2", true) elseif self.arrowType == 3 then lua_resM:setImageSprite(self, self.arrow:GetComponent("Image"), "mainui_asset", "main_ui_tip", true) --lua_resM:setImageSprite(self, self.arrow:GetComponent("Image"), "mainui_asset", "main_ui_tip3", true) end end --type --显示箭头 1 右 2 左 3 下 4 上 5左斜下 6右斜下 7左斜上 8右斜上 function ArrowComponent:ShowArrow(itype, pos, layer, show_type) self.type = itype self.pos = pos self.layer = layer self.show_type = show_type if self.is_loaded then self.need_refreshData = false if self.type == 1 then self.arrow.localRotation = Quaternion.Euler(0,0,0) elseif self.type == 2 then self.arrow.localRotation = Quaternion.Euler(0,0,180) elseif self.type == 3 then self.arrow.localRotation = Quaternion.Euler(0,0,270) elseif self.type == 4 then self.arrow.localRotation = Quaternion.Euler(0,0,90) elseif self.type == 5 then self.arrow.localRotation = Quaternion.Euler(0,0,225) elseif self.type == 6 then self.arrow.localRotation = Quaternion.Euler(0,0,325) elseif self.type == 7 then self.arrow.localRotation = Quaternion.Euler(0,0,135) elseif self.type == 8 then self.arrow.localRotation = Quaternion.Euler(0,0,45) else self.arrow.localRotation = Quaternion.Euler(0,0,0) end self:SetArrowImg() self:SetPosition(self.pos.x,self.pos.y) self:SetLayer(self.layer) self:StopAnim() self:StartAnim() else self.need_refreshData = true end end function ArrowComponent:GetAnimEndPos(i_type) local pos = Vector3(0,0,0) if self.arrowType == 2 then if i_type == 1 or i_type == 2 then pos = Vector3(-10, 0, 0 ) elseif i_type == 3 or i_type == 4 then pos = Vector3(0, -10 ,0) elseif i_type == 5 or i_type == 8 then pos = Vector3(-10, -10, 0) elseif i_type == 6 or i_type == 7 then pos = Vector3(-10, 10, 0) end else if i_type == 1 or i_type == 2 then pos = Vector3(-15, 0, 0 ) elseif i_type == 3 or i_type == 4 then pos = Vector3(0, -15 ,0) elseif i_type == 5 or i_type == 8 then pos = Vector3(-15, -15, 0) elseif i_type == 6 or i_type == 7 then pos = Vector3(-15, 15, 0) end end return pos end function ArrowComponent:StartAnim() self:SetVisible(true) self.arrow.localPosition = Vector3(0,0,0) if self.twenn_id == nil then local function onCompleted() self:ArrowAnimation() end self.tween_id = TweenLite.to(self, self.arrow,TweenLite.UiAnimationType.POS, self:GetAnimEndPos(self.type) ,0.6,onCompleted,TweenFunc.EASE_IN_OUT) end end function ArrowComponent:ArrowAnimation() local call_fun = function () local function onCompleted() self:ArrowAnimation() end self.tween_id3 =TweenLite.to(self, self.arrow,TweenLite.UiAnimationType.POS, self:GetAnimEndPos(self.type) ,0.6,onCompleted,TweenFunc.EASE_IN_OUT) end self.tween_id2 =TweenLite.to(self, self.arrow,TweenLite.UiAnimationType.POS,self:GetAnimEndPos(), 0.6, call_fun, TweenFunc.EASE_IN_OUT) end function ArrowComponent:StopAnim() if self.tween_id then TweenLite.Stop(self.tween_id) self.tween_id = nil end if self.tween_id2 then TweenLite.Stop(self.tween_id2) self.tween_id2 = nil end if self.tween_id3 then TweenLite.Stop(self.tween_id3) self.tween_id3 = nil end end function ArrowComponent:Hide() self:SetVisible(false) self:StopAnim() end function ArrowComponent:SetLayer(layer) if self.transform and layer then --self.transform.gameObject:GetComponent("Canvas").sortingOrder = layer end end