Back to Home

ESO Lua File v100032

ingame/leveluprewards/leveluprewards_base.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
ZO_LEVEL_UP_REWARDS_BACKGROUND_TEXTURE_WIDTH = 512
ZO_LEVEL_UP_REWARDS_BACKGROUND_TEXTURE_HEIGHT = 256
ZO_LEVEL_UP_REWARDS_BACKGROUND_USED_TEXTURE_WIDTH = 448
ZO_LEVEL_UP_REWARDS_BACKGROUND_USED_TEXTURE_HEIGHT = 138
ZO_LEVEL_UP_REWARDS_ART_RIGHT_TEXTURE_COORD = ZO_LEVEL_UP_REWARDS_BACKGROUND_USED_TEXTURE_WIDTH / ZO_LEVEL_UP_REWARDS_BACKGROUND_TEXTURE_WIDTH
ZO_LEVEL_UP_REWARDS_ART_BOTTOM_TEXTURE_COORD = ZO_LEVEL_UP_REWARDS_BACKGROUND_USED_TEXTURE_HEIGHT / ZO_LEVEL_UP_REWARDS_BACKGROUND_TEXTURE_HEIGHT
ZO_LEVEL_UP_REWARDS_ART_REWARDS_SPACING = 10
    self.frameTexture = self:GetNamedChild("Frame")
    self.artTexture = self:GetNamedChild("Art")
    self.titleControl = self:GetNamedChild("Title")
    local maskControl = self:GetNamedChild("Mask")
    self.maskControl = maskControl
    
    local layerAnimation = ZO_TextureLayerRevealAnimation:New(maskControl)
    local animationTimeline = layerAnimation:GetAnimationTimeline()
    animationTimeline:SetPlaybackType(ANIMATION_PLAYBACK_LOOP, LOOP_INDEFINITELY)
    self.layerAnimation = layerAnimation
    local function ParticleSystemFactory(pool)
        local particleSystem = ZO_ControlParticleSystem:New(ZO_BentArcParticle_Control)
        particleSystem:SetParentControl(maskControl)
        particleSystem:SetParticleParameter("AnchorRelativePoint", TOPLEFT)
        return particleSystem
    end
    local function ParticleSystemReset(particleSystem, pool)
        particleSystem:Stop()
    end
    self.particleSystemPool = ZO_ObjectPool:New(ParticleSystemFactory, ParticleSystemReset)
    maskControl:SetHandler("OnEffectivelyShown", function()
        if layerAnimation:HasLayers() then
            animationTimeline:PlayFromStart()
        end
        for _, particleSystem in pairs(self.particleSystemPool:GetActiveObjects()) do
            particleSystem:Start()
        end
    end)
    maskControl:SetHandler("OnEffectivelyHidden", function()
        animationTimeline:Stop()
        for _, particleSystem in pairs(self.particleSystemPool:GetActiveObjects()) do
            particleSystem:Stop()
        end
    end)
end
    self.rewardsContainer = self:GetNamedChild("Rewards")
end
    local levelBackground = GetLevelUpBackground(level)
    self.artTexture:SetTexture(levelBackground)
    local layerAnimation = self.layerAnimation
    layerAnimation:RemoveAllLayers()
     local numTextureLayerRevealAnimations = GetNumLevelUpTextureLayerRevealAnimations(level)
     for i = 1, numTextureLayerRevealAnimations do
          local animationId = GetLevelUpTextureLayerRevealAnimation(level, i)
          local layer = layerAnimation:AddLayer()
          layer:SetTexture(GetTextureLayerRevealAnimationTexture(animationId))
          layer:SetTextureCoords(0, ZO_LEVEL_UP_REWARDS_ART_RIGHT_TEXTURE_COORD, 0, ZO_LEVEL_UP_REWARDS_ART_BOTTOM_TEXTURE_COORD)
          layer:SetTextureBlendMode(GetTextureLayerRevealAnimationBlendMode(animationId))
          for gradientIndex = 1, 2 do
               local x, y, normalizedDistance = GetTextureLayerRevealAnimationWindowFadeGradientInfo(animationId, gradientIndex)
               if normalizedDistance > 0 then
                    layer:SetWindowFadeGradient(gradientIndex, x, y, normalizedDistance)
               end
          end
     end
    layerAnimation:Commit()
     if layerAnimation:HasLayers() then
        local minDurationMS = GetLevelUpTextureLayerRevealAnimationsMinDuration(level)
        layerAnimation:GetAnimationTimeline():SetMinDuration(minDurationMS)
        if not self.maskControl:IsHidden() then
              layerAnimation:GetAnimationTimeline():PlayFromStart()
         end
    end
    self.particleSystemPool:ReleaseAllObjects()
    local numParticleEffects = GetNumLevelUpGuiParticleEffects(level)
    local maskWidth, maskHeight = self.maskControl:GetDimensions()
    for i = 1, numParticleEffects do
        local particleSystem = self.particleSystemPool:AcquireObject()
        local texture, normalizedVelocityMin, normalizedVelocityMax, durationMinS, durationMaxS, particlesPerSecond, startScaleMin, startScaleMax, endScaleMin, endScaleMax, startAlpha,
            endAlpha, r, g, b, normalizedStartPoint1X, normalizedStartPoint1Y, normalizedStartPoint2X, normalizedStartPoint2Y, angleRadians = GetLevelUpGuiParticleEffectInfo(level, i)
        
        local startPoint1X = normalizedStartPoint1X * maskWidth
        local startPoint1Y = normalizedStartPoint1Y * maskHeight
        local startPoint2X = normalizedStartPoint2X * maskWidth
        local startPoint2Y = normalizedStartPoint2Y * maskHeight
        local velocityMin, velocityMax
        local percentageOfUnitCircle = angleRadians / (2 * math.pi)
        if (percentageOfUnitCircle > 1/8 and percentageOfUnitCircle < 3/8) or (percentageOfUnitCircle > 5/8 and percentageOfUnitCircle < 7/8) then
            --Points more in the Y direction than the X, normalize the particle velocity against height
            velocityMin = normalizedVelocityMin * maskHeight
            velocityMax = normalizedVelocityMax * maskHeight
        else
            --Points more in the X direction than the Y, normalize the particle velocity against width
            velocityMin = normalizedVelocityMin * maskWidth
            velocityMax = normalizedVelocityMax * maskWidth
        end 
        particleSystem:SetParticlesPerSecond(particlesPerSecond)
        particleSystem:SetParticleParameter("Texture", texture)
        particleSystem:SetParticleParameter("BentArcElevationStartRadians", angleRadians)
        particleSystem:SetParticleParameter("BentArcElevationChangeRadians", 0)
        particleSystem:SetParticleParameter("BentArcAzimuthStartRadians", 0)
        particleSystem:SetParticleParameter("BentArcAzimuthChangeRadians", 0)
        particleSystem:SetParticleParameter("BentArcVelocity", ZO_UniformRangeGenerator:New(velocityMin, velocityMax))
        particleSystem:SetParticleParameter("Size", 8)
        particleSystem:SetParticleParameter("StartScale", ZO_UniformRangeGenerator:New(startScaleMin, startScaleMax))
        particleSystem:SetParticleParameter("EndScale", ZO_UniformRangeGenerator:New(endScaleMin, endScaleMax))
        particleSystem:SetParticleParameter("DurationS", ZO_UniformRangeGenerator:New(durationMinS, durationMaxS))
        particleSystem:SetParticleParameter("StartAlpha", startAlpha)
        particleSystem:SetParticleParameter("EndAlpha", endAlpha)
        particleSystem:SetParticleParameter("StartColorR", r)
        particleSystem:SetParticleParameter("StartColorG", g)
        particleSystem:SetParticleParameter("StartColorB", b)
        particleSystem:SetParticleParameter("StartOffsetX", "StartOffsetY", ZO_UniformRangeGenerator:New(startPoint1X, startPoint2X, startPoint1Y, startPoint2Y))
        particleSystem:SetParticleParameter("BlendMode", TEX_BLEND_MODE_ADD)
        if not self.maskControl:IsHidden() then
            particleSystem:Start()
        end
    end
end