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

Commit

Permalink
Closes #44
Browse files Browse the repository at this point in the history
  • Loading branch information
Pluviolithic committed Oct 21, 2023
2 parents 7f3e0a3 + a94c48f commit dd3cfae
Show file tree
Hide file tree
Showing 29 changed files with 883 additions and 65 deletions.
6 changes: 5 additions & 1 deletion src/client/Jumpscare.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ local function jumpscarePlayer(enemyName)
end

playerStatePromise:andThen(function()
local lastEnemyFought = selectors.getCurrentTarget(store:getState(), player.Name)
store.changed:connect(function(newState, oldState)
if selectors.getCurrentTarget(newState, player.Name) then
lastEnemyFought = selectors.getCurrentTarget(newState, player.Name)
end
if
isScared(player.Name, newState)
and not isScared(player.Name, oldState)
and (os.time() - lastJumpscared) > jumpscareGap
then
jumpscarePlayer(selectors.getCurrentTarget(newState, player.Name).Name)
jumpscarePlayer(lastEnemyFought.Name)
end
end)
end)
Expand Down
12 changes: 8 additions & 4 deletions src/client/UI/BillboardShops/EggShop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ local store = require(StarterPlayer.StarterPlayerScripts.Client.State.Store)
local selectors = require(ReplicatedStorage.Common.State.selectors)
local playerStatePromise = require(StarterPlayer.StarterPlayerScripts.Client.State.PlayerStatePromise)

local autoHatchGamepassID = ReplicatedStorage.Config.GamepassData.IDs["Auto"].Value
local tripleHatchGamepassID = ReplicatedStorage.Config.GamepassData.IDs["3X"].Value
local autoHatchGamepassID = ReplicatedStorage.Config.GamepassData.IDs["AutoHatch"].Value
local tripleHatchGamepassID = ReplicatedStorage.Config.GamepassData.IDs["3xHatch"].Value
local fasterHatchGamepassID = ReplicatedStorage.Config.GamepassData.IDs["FasterHatch"].Value
local doubleLuckGamepassID = ReplicatedStorage.Config.GamepassData.IDs["2XLuck"].Value
local tripleLuckGamepassID = ReplicatedStorage.Config.GamepassData.IDs["3XLuck"].Value
local doubleLuckGamepassID = ReplicatedStorage.Config.GamepassData.IDs["2xLuck"].Value
local tripleLuckGamepassID = ReplicatedStorage.Config.GamepassData.IDs["3xLuck"].Value

local hatchingUI = player.PlayerGui:WaitForChild "Hatching"

Expand Down Expand Up @@ -320,6 +320,10 @@ CollectionService:GetInstanceAddedSignal("EggShop"):Connect(handleShop)

local function updateFoundsDisplay(foundPets): ()
for petName in foundPets do
if petName:match "Evolved" then
continue
end

local petUI = player.PlayerGui:WaitForChild(petAreas[petName] .. "EggUI").Background.Pets[petName]
petUI.PetName.Text = petName
petUI.PetImage.ImageColor3 = Color3.fromRGB(255, 255, 255)
Expand Down
3 changes: 3 additions & 0 deletions src/client/UI/CentralUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ function CentralUI:setEnabled(enable: boolean?): ()
self._isOpen = enable

if not enable then
if self.OnClose then
self:OnClose()
end
return
end

Expand Down
4 changes: 1 addition & 3 deletions src/client/UI/Displays.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ end):andThen(function(interfaces)
first = interfaces.PetInventory.Background.Multiplier.Amount,
second = function()
return "X"
.. formatter.truncateMultiplier(
selectors.getStat(store:getState(), player.Name, "PetFearMultiplier")
)
.. formatter.truncateMultiplier(selectors.getStat(store:getState(), player.Name, "FearMultiplier"))
end,
},
{
Expand Down
8 changes: 4 additions & 4 deletions src/client/UI/Inventories/PetInventory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ function PetInventory:_initialize(): ()
self._ui.Background.Storage.Buy.Activated:Connect(function()
local maxPetCount = selectors.getStat(store:getState(), player.Name, "MaxPetCount")
if maxPetCount == 30 or maxPetCount == 130 then
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["+50"].Value)
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["50PetStorage"].Value)
else
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["+100"].Value)
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["100PetStorage"].Value)
end
end)

self._ui.Background.Equipped.Buy.Activated:Connect(function()
if selectors.getStat(store:getState(), player.Name, "MaxPetEquipCount") == 3 then
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["+1PetEquipped"].Value)
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["1PetEquipped"].Value)
else
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["+2PetEquipped"].Value)
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["2PetEquipped"].Value)
end
end)

Expand Down
7 changes: 7 additions & 0 deletions src/client/UI/Missions/MissionFearRewardUI.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local Players = game:GetService "Players"
local StarterPlayer = game:GetService "StarterPlayer"

local CentralUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.CentralUI)
local player = Players.LocalPlayer

return CentralUI.new(player.PlayerGui:WaitForChild "MissionFearReward")
92 changes: 92 additions & 0 deletions src/client/UI/Missions/ProgressUI.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
local Players = game:GetService "Players"
local StarterPlayer = game:GetService "StarterPlayer"
local ReplicatedStorage = game:GetService "ReplicatedStorage"

local player = Players.LocalPlayer
local Client = StarterPlayer.StarterPlayerScripts.Client

local store = require(Client.State.Store)
local selectors = require(ReplicatedStorage.Common.State.selectors)
local playerStatePromise = require(Client.State.PlayerStatePromise)
local regionUtils = require(ReplicatedStorage.Common.Utils.Player.RegionUtils)

local missionRequirements = ReplicatedStorage.Missions

local progressTextFormats = {
Enemy = "Defeat {enemy} {progress}",
Weapon = "Buy a Weapon",
AnyPet = "Hatch Any Pet in {area} {progress}",
PetRarity = "Hatch a {rarity} Pet in {area} {progress}",
}

local function enteredRegion(regionName, progressUI)
local currentMissionData = selectors.getMissionData(store:getState(), player.Name)[regionName]
local currentMissionRequirements =
missionRequirements[regionName][tostring(currentMissionData.CurrentMissionNumber)]

if currentMissionData.Active then
local progressText
for missionType, text in progressTextFormats do
progressText = if currentMissionRequirements:FindFirstChild(missionType) then text else progressText
end

progressUI.Background.MissionName.Text = currentMissionRequirements.MissionName.Value

if currentMissionData.CurrentMissionProgress == currentMissionRequirements.Requirements.Value then
progressUI.Background.Progress.Visible = false
progressUI.Background.Complete.Visible = true
progressUI.Enabled = true
return
end

progressUI.Background.Complete.Visible = false
progressUI.Background.Progress.Visible = true

if progressText == progressTextFormats.Enemy then
progressText = progressText:gsub("{enemy}", currentMissionRequirements.Enemy.Value)
elseif progressText == progressTextFormats.PetRarity then
if currentMissionRequirements.PetRarity.Value:sub(1, 1):lower():match "[aeiou]" then
progressText = progressText:gsub(" {rarity}", "n " .. currentMissionRequirements.PetRarity.Value)
else
progressText = progressText:gsub("{rarity}", currentMissionRequirements.PetRarity.Value)
end
end

progressText = progressText:gsub("{area}", regionName)
progressText = progressText:gsub(
"{progress}",
"("
.. currentMissionData.CurrentMissionProgress
.. "/"
.. currentMissionRequirements.Requirements.Value
.. ")"
)

progressUI.Background.Progress.Text = progressText
progressUI.Enabled = true
else
progressUI.Enabled = false
end
end

playerStatePromise:andThen(function()
local progressUI = player.PlayerGui:WaitForChild "ProgressUI"
for regionName, zone in regionUtils.getRegions() do
if zone:findLocalPlayer() then
enteredRegion(regionName, progressUI)
end
zone.localPlayerEntered:Connect(function()
enteredRegion(regionName, progressUI)
end)
end
store.changed:connect(function(newState, oldState)
local newMissionData = selectors.getMissionData(newState, player.Name)
local oldMissionData = selectors.getMissionData(oldState, player.Name)
if newMissionData == oldMissionData then
return
end
enteredRegion(regionUtils.getPlayerLocationName(player.Name), progressUI)
end)
end)

return 0
Loading

0 comments on commit dd3cfae

Please sign in to comment.