Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
! Functional Targets + Fruit Master
Browse files Browse the repository at this point in the history
Finally! Now everyone can use the meta and literally not use any other powers!

TBA: Target sprite should float up and down. There should also be a rotating "flare" sprite behind it.
  • Loading branch information
ShamblesSM committed Jan 13, 2023
1 parent c38a3de commit fcdaa70
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 8 deletions.
36 changes: 28 additions & 8 deletions src/Level.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ function Level:new(data)
end

self.targetFrequency = data.targetFrequency
self.targetInitialDelaySecondsElapsed = false
self.targetInitialDelaySecondsElapsed = false

self.targetHitBases = {3000, 4500, 6750, 10150, 15200, 22800}
self.targetHitScore = 0
-- TODO: Additions to targetHitScore once Spirit Animals and Food are implemented
-- (Kiwi Kebab, to be exact)

self.colorGeneratorNormal = data.colorGeneratorNormal
self.colorGeneratorDanger = data.colorGeneratorDanger
Expand Down Expand Up @@ -96,7 +101,8 @@ end
function Level:updateLogic(dt)
self.map:update(dt)
self.shooter:update(dt)
self.stateCount = self.stateCount + dt
self.stateCount = self.stateCount + dt
self.targetHitScore = self.targetHitBases[math.min(self.targets+1, 6)]

-- Danger sound
local d1 = self:getDanger() and not self.lost
Expand Down Expand Up @@ -253,7 +259,10 @@ function Level:updateLogic(dt)
if self.targetSecondsCooldown < 0 then
if not self.targetInitialDelaySecondsElapsed then
self.targetInitialDelaySecondsElapsed = true
self.targetSecondsCooldown = self.targetFrequency.delay
self.targetSecondsCooldown = self.targetFrequency.delay
if _Game:getCurrentProfile():isPowerEquipped("fruit_master") then
self.targetSecondsCooldown = self.targetSecondsCooldown - _Game.configManager:getPower("fruit_master").levels[_Game:getCurrentProfile():getPowerLevel("fruit_master")].subtractiveSeconds
end
end
for i, point in ipairs(self.map.targetPoints) do
for j, path in ipairs(self.map.paths) do
Expand All @@ -278,7 +287,10 @@ function Level:updateLogic(dt)
end
else
-- don't tick the timer down if there's fruit present
self.targetSecondsCooldown = self.targetFrequency.delay
self.targetSecondsCooldown = self.targetFrequency.delay
if _Game:getCurrentProfile():isPowerEquipped("fruit_master") then
self.targetSecondsCooldown = self.targetSecondsCooldown - _Game.configManager:getPower("fruit_master").levels[_Game:getCurrentProfile():getPowerLevel("fruit_master")].subtractiveSeconds
end
if self.target.delQueue then
self.target = nil
end
Expand Down Expand Up @@ -931,12 +943,16 @@ function Level:reset()
self.gems = 0
self.combo = 0
self.destroyedSpheres = 0
self.targets = 0
self.time = 0
self.stateCount = 0

self.target = nil
if self.targetFrequency.type == "seconds" then
self.targetSecondsCooldown = self.targetFrequency.initialDelay
self.targetSecondsCooldown = self.targetFrequency.initialDelay
if _Game:getCurrentProfile():isPowerEquipped("fruit_master") then
self.targetSecondsCooldown = self.targetSecondsCooldown - _Game.configManager:getPower("fruit_master").levels[_Game:getCurrentProfile():getPowerLevel("fruit_master")].subtractiveSeconds
end
end

self.blitzMeter = 0
Expand Down Expand Up @@ -1082,7 +1098,8 @@ function Level:serialize()
coins = self.coins,
gems = self.gems,
spheresShot = self.spheresShot,
sphereChainsSpawned = self.sphereChainsSpawned,
sphereChainsSpawned = self.sphereChainsSpawned,
targets = self.targets,
maxChain = self.maxChain,
maxCombo = self.maxCombo
},
Expand All @@ -1092,7 +1109,8 @@ function Level:serialize()
lastPowerupDeltas = self.lastPowerupDeltas,
target = (self.target and self.target:serialize()) or {},
targetSecondsCooldown = self.targetSecondsCooldown,
targetInitialDelaySecondsElapsed = self.targetInitialDelaySecondsElapsed,
targetInitialDelaySecondsElapsed = self.targetInitialDelaySecondsElapsed,
targetHitScore = self.targetHitScore,
blitzMeter = self.blitzMeter,
blitzMeterCooldown = self.blitzMeterCooldown,
multiplier = self.multiplier,
Expand Down Expand Up @@ -1133,7 +1151,8 @@ function Level:deserialize(t)
self.coins = t.stats.coins
self.gems = t.stats.gems
self.spheresShot = t.stats.spheresShot
self.sphereChainsSpawned = t.stats.sphereChainsSpawned
self.sphereChainsSpawned = t.stats.sphereChainsSpawned
self.targets = t.stats.targets
self.maxChain = t.stats.maxChain
self.maxCombo = t.stats.maxCombo
self.combo = t.combo
Expand All @@ -1145,6 +1164,7 @@ function Level:deserialize(t)
self.target = t.target
self.targetSecondsCooldown = t.targetSecondsCooldown
self.targetFrequency = t.targetFrequency
self.targetHitScore = t.targetHitScore
self.targetInitialDelaySecondsElapsed = t.targetInitialDelaySecondsElapsed
self.blitzMeter = t.blitzMeter
self.blitzMeterCooldown = t.blitzMeterCooldown
Expand Down
27 changes: 27 additions & 0 deletions src/ShotSphere.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ function ShotSphere:moveStep()
end
elseif sphereConfig.hitBehavior.type == "fireball" then
_Game.session:destroyRadiusColor(self.pos, sphereConfig.hitBehavior.range, self.color)
-- check for targets
if _Game.session.level.target then
local targetPos = _Game.session.level.target.pos
local dist = (targetPos - self.pos):len()
if dist <= sphereConfig.hitBehavior.range then
_Game.session.level.target:onShot()
end
end
self:destroy()
_Game:spawnParticle(sphereConfig.destroyParticle, self.pos)
elseif sphereConfig.hitBehavior.type == "colorCloud" then
Expand Down Expand Up @@ -148,6 +156,25 @@ function ShotSphere:moveStep()
_Game.session.level.blitzMeterCooldown = 0.5
end
end
end


-- check for targets
if _Game.session.level.target then
local targetPos = _Game.session.level.target.pos
local dist = (targetPos - self.pos):len()
if dist < 40 then
local sphereConfig = _Game.configManager.spheres[self.color]
-- TODO: check for color nuke sphere type?
-- they don't hit fruits
_Game.session.level.target:onShot()
if sphereConfig.hitBehavior.type == "fireball" then
_Game.session:destroyRadiusColor(self.pos, sphereConfig.hitBehavior.range, self.color)
_Game:playSound(sphereConfig.hitSound, 1, self.pos)
end
self:destroy()
_Game:spawnParticle(sphereConfig.destroyParticle, self.pos)
end
end

-- delete if outside of the board
Expand Down
8 changes: 8 additions & 0 deletions src/Target.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ end

function Target:onShot()
self:destroy()
_Game:playSound("sound_events/target_hit.json")
_Game.session.level:grantScore(_Game.session.level.targetHitScore)
_Game.session.level:spawnFloatingText(
string.format("BONUS\n+%s", _NumStr(_Game.session.level.targetHitScore * _Game.session.level.multiplier)),
self.pos,
"fonts/score0.json"
)
_Game.session.level.targets = _Game.session.level.targets + 1
end


Expand Down

0 comments on commit fcdaa70

Please sign in to comment.