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

Commit

Permalink
Closes #103
Browse files Browse the repository at this point in the history
  • Loading branch information
Pluviolithic committed Dec 3, 2023
1 parent cebff8f commit 2e723c6
Show file tree
Hide file tree
Showing 14 changed files with 172 additions and 26 deletions.
15 changes: 10 additions & 5 deletions src/client/Areas/TeleportUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local teleportPlayer = require(StarterPlayer.StarterPlayerScripts.Client.Areas.T
local interfaces = require(StarterPlayer.StarterPlayerScripts.Client.UI.CollidableInterfaces)
local confirmationUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.ConfirmationUI)
local CentralUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.CentralUI)
local PopupUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.PopupUI)
local store = require(StarterPlayer.StarterPlayerScripts.Client.State.Store)
local petUtils = require(ReplicatedStorage.Common.Utils.Player.PetUtils)
local selectors = require(ReplicatedStorage.Common.State.selectors)
Expand Down Expand Up @@ -94,6 +95,7 @@ function TeleportUI:_initialize()
petUtils.instantiatePets(player.Name, selectors.getEquippedPets(store:getState(), player.Name))
end)
else
PopupUI(`You Must Buy The {targetAreaName} Teleport First!`)
self:setEnabled(true)
end
end)
Expand All @@ -108,15 +110,18 @@ function TeleportUI:_initialize()
area.Teleport.Activated:Connect(function()
local hasFreeTeleporters = selectors.hasGamepass(store:getState(), player.Name, "FreeTeleporters")
if area.Locked.Visible or area.CostUI.Visible then
if selectors.getStat(store:getState(), player.Name, "Strength") < areaRequirements[area.Name].Value then
return
end
if
selectors.getStat(store:getState(), player.Name, "Strength") < areaRequirements[area.Name].Value
or (
selectors.getStat(store:getState(), player.Name, "Gems") < area.Cost.Value
and not hasFreeTeleporters
)
selectors.getStat(store:getState(), player.Name, "Gems") < area.Cost.Value
and not hasFreeTeleporters
then
PopupUI "You Can Not Afford This Teleporter!"
MarketplaceService:PromptGamePassPurchase(player, freeTeleportersGamepassID)
return
end

confirmationUI(
confirmationUIInstance,
string.format(
Expand Down
6 changes: 5 additions & 1 deletion src/client/UI/BillboardShops/EggShop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ local Janitor = require(ReplicatedStorage.Common.lib.Janitor)
local Promise = require(ReplicatedStorage.Common.lib.Promise)
local selectors = require(ReplicatedStorage.Common.State.selectors)
local store = require(StarterPlayer.StarterPlayerScripts.Client.State.Store)
local PopupUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.PopupUI)
local RobuxShop = require(StarterPlayer.StarterPlayerScripts.Client.UI.Shops.RobuxShop)
local playerStatePromise = require(StarterPlayer.StarterPlayerScripts.Client.State.PlayerStatePromise)

local autoHatchGamepassID = ReplicatedStorage.Config.GamepassData.IDs["AutoHatch"].Value
Expand Down Expand Up @@ -287,7 +289,8 @@ local function handleShop(shop): ()
end

if selectors.getStat(store:getState(), player.Name, "Gems") < eggGemPrice * count then
hatching = false
PopupUI "You Can Not Afford To Open This Egg!"
RobuxShop:OpenSubShop "Gems"
return
end

Expand All @@ -297,6 +300,7 @@ local function handleShop(shop): ()
selectors.getStat(store:getState(), player.Name, "CurrentPetCount") + count
> selectors.getStat(store:getState(), player.Name, "MaxPetCount")
then
PopupUI "Your Pet Inventory Is Full!"
hatching = false
return
end
Expand Down
12 changes: 11 additions & 1 deletion src/client/UI/BuffsUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local MarketplaceService = game:GetService "MarketplaceService"
local selectors = require(ReplicatedStorage.Common.State.selectors)
local clockUtils = require(ReplicatedStorage.Common.Utils.ClockUtils)
local store = require(StarterPlayer.StarterPlayerScripts.Client.State.Store)
local PopupUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.PopupUI)
local RobuxShop = require(StarterPlayer.StarterPlayerScripts.Client.UI.Shops.RobuxShop)
local playerStatePromise = require(StarterPlayer.StarterPlayerScripts.Client.State.PlayerStatePromise)

Expand Down Expand Up @@ -43,8 +44,17 @@ local function updateBuffTray(state)
activeBoosts[buffDisplay.Name].Duration
)
buffDisplay.Visible = true
else
elseif buffDisplay.Visible then
buffDisplay.Visible = false

local multiplierAmount = "2x "
if buffDisplay.Name:match "Luck" then
multiplierAmount = "5x "
elseif buffDisplay.Name:match "Fearless" then
multiplierAmount = ""
end

PopupUI(`{multiplierAmount}{buffDisplay.Name:match "(%u.+)%u"} Boost Has Expired!`)
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions src/client/UI/Combat/BossUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ local BossUI = player.PlayerGui:WaitForChild "BossUI"
local maxFearFromBossPercentage = ReplicatedStorage.Config.Combat.BossFearPercentage.Value

Remotes.Client:Get("SendFightInfo"):Connect(function(info)
if not info.IsBoss then
return
end

local fearMultiplier = selectors.getMultiplierData(store:getState(), player.Name).FearMultiplier
local fearMultiplierCount = selectors.getMultiplierData(store:getState(), player.Name).FearMultiplierCount
local fearBoostData = selectors.getActiveBoosts(store:getState(), player.Name).FearBoost
Expand Down
30 changes: 21 additions & 9 deletions src/client/UI/Combat/FearMeter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,34 @@ playerStatePromise:andThen(function()

local currentState = store:getState()
local bar = fearMeter.Background.Bar
local fearMeterHidden = false

local function hideFearMeter()
fearMeterHidden = true
fearMeter.Fear.Visible = false
fearMeter.Icon.Visible = false
fearMeter.Image.Visible = false
fearMeter.Enable.Visible = true
fearMeter.Disable.Visible = false
fearMeter.Fearless.Visible = false
fearMeter.Background.Visible = false
end

local function revealFearMeter()
fearMeterHidden = false
fearMeter.Icon.Visible = true
fearMeter.Image.Visible = true
fearMeter.Enable.Visible = false
fearMeter.Disable.Visible = true
fearMeter.Background.Visible = true

if selectors.getActiveBoosts(currentState, player.Name)["FearlessBoost"] then
fearMeter.Fear.Visible = false
fearMeter.Fearless.Visible = true
else
fearMeter.Fear.Visible = true
fearMeter.Fearless.Visible = false
end
end

fearMeter.Background.Activated:Connect(function()
Expand All @@ -82,12 +94,14 @@ playerStatePromise:andThen(function()
local currentTarget = selectors.getCurrentTarget(newState, player.Name)
local previousTarget = selectors.getCurrentTarget(oldState, player.Name)

if selectors.getActiveBoosts(newState, player.Name)["FearlessBoost"] then
fearMeter.Fear.Visible = false
fearMeter.Fearless.Visible = true
else
fearMeter.Fear.Visible = true
fearMeter.Fearless.Visible = false
if not fearMeterHidden then
if selectors.getActiveBoosts(newState, player.Name)["FearlessBoost"] then
fearMeter.Fear.Visible = false
fearMeter.Fearless.Visible = true
else
fearMeter.Fear.Visible = true
fearMeter.Fearless.Visible = false
end
end

if currentTarget ~= previousTarget and currentTarget then
Expand All @@ -112,9 +126,7 @@ playerStatePromise:andThen(function()
fearMeter.Disable.Activated:Connect(hideFearMeter)

RunService.RenderStepped:Connect(function()
local secondsSinceEpoch = workspace:GetServerTimeNow()
local secondsSinceLastScared = secondsSinceEpoch
- selectors.getStat(currentState, player.Name, "LastScaredTimestamp")
local secondsSinceLastScared = os.time() - selectors.getStat(currentState, player.Name, "LastScaredTimestamp")
if secondsSinceLastScared < 120 then
fearMeter.ScaredTextTimer.Text = string.format(
"Lower your fear meter by working out or wait " .. "%02i:%02i" .. " minutes.",
Expand Down
26 changes: 20 additions & 6 deletions src/client/UI/Inventories/PetInventory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local Janitor = require(ReplicatedStorage.Common.lib.Janitor)
local selectors = require(ReplicatedStorage.Common.State.selectors)
local petUtils = require(ReplicatedStorage.Common.Utils.Player.PetUtils)
local store = require(StarterPlayer.StarterPlayerScripts.Client.State.Store)
local PopupUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.PopupUI)
local CentralUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.CentralUI)
local confirmationUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.ConfirmationUI)
local playerStatePromise = require(StarterPlayer.StarterPlayerScripts.Client.State.PlayerStatePromise)
Expand Down Expand Up @@ -63,12 +64,9 @@ function PetInventory:_initialize(): ()
end)

self._ui.Background.Equipped.Buy.Activated:Connect(function()
if
not selectors.hasGamepass(store:getState(), player.Name, "1PetEquipped")
or selectors.hasGamepass(store:getState(), player.Name, "2PetEquipped")
then
if not selectors.hasGamepass(store:getState(), player.Name, "1PetEquipped") then
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["1PetEquipped"].Value)
else
elseif not selectors.hasGamepass(store:getState(), player.Name, "2PetEquipped") then
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["2PetEquipped"].Value)
end
end)
Expand Down Expand Up @@ -372,6 +370,12 @@ function PetInventory:_setFocusedDisplay(details)
then
Remotes.Client:Get("EquipPet"):SendToServer(details.PetName, details.Locked)
else
PopupUI "Unequip A Pet First Or Buy More Pet Equips!"
if not selectors.hasGamepass(store:getState(), player.Name, "1PetEquipped") then
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["1PetEquipped"].Value)
elseif not selectors.hasGamepass(store:getState(), player.Name, "2PetEquipped") then
MarketplaceService:PromptGamePassPurchase(player, gamepassIDs["2PetEquipped"].Value)
end
return
end
details.Locked = not details.Locked
Expand All @@ -380,7 +384,17 @@ function PetInventory:_setFocusedDisplay(details)
end))

self._focusedDestructor:Add(self._ui.RightBackground.Delete.Activated:Connect(function()
if not details.Locked then
if details.Locked then
if petUtils.getPet(details.PetName):FindFirstChild "PermaLock" then
PopupUI "You Can Not Delete This Pet!"
return
end
if details.Equipped then
PopupUI "Unequip The Pet First!"
else
PopupUI "Unlock The Pet First!"
end
else
Remotes.Client:Get("DeletePet"):SendToServer(details.PetName)
self:_clearFocusedDisplay()
end
Expand Down
38 changes: 38 additions & 0 deletions src/client/UI/PopupUI.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
local Players = game:GetService "Players"
local ReplicatedStorage = game:GetService "ReplicatedStorage"

local Remotes = require(ReplicatedStorage.Common.Remotes)

local player = Players.LocalPlayer
local popupTemplate = ReplicatedStorage.PopupTemplate
local Popups = player.PlayerGui:WaitForChild("ScreenEffects").Popups

local activePopups = {}

local popupGenerator = function(message)
if activePopups[message] then
return
end
activePopups[message] = true

local popup = popupTemplate:Clone()
popup.PopupText.Text = message
popup.Parent = Popups

popup.PopupText:TweenPosition(
UDim2.fromScale(0, 0.074),
Enum.EasingDirection.Out,
Enum.EasingStyle.Quad,
0.2,
true,
function()
task.wait(5)
popup:Destroy()
activePopups[message] = nil
end
)
end

Remotes.Client:Get("SendPopupMessage"):Connect(popupGenerator)

return popupGenerator
6 changes: 6 additions & 0 deletions src/client/UI/Shops/WeaponShop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ local Table = require(ReplicatedStorage.Common.Utils.Table)
local selectors = require(ReplicatedStorage.Common.State.selectors)
local petUtils = require(ReplicatedStorage.Common.Utils.Player.PetUtils)
local store = require(StarterPlayer.StarterPlayerScripts.Client.State.Store)
local PopupUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.PopupUI)
local CentralUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.CentralUI)
local teleportUI = require(StarterPlayer.StarterPlayerScripts.Client.Areas.TeleportUI)
local RobuxShop = require(StarterPlayer.StarterPlayerScripts.Client.UI.Shops.RobuxShop)
local confirmationUI = require(StarterPlayer.StarterPlayerScripts.Client.UI.ConfirmationUI)
local teleportPlayer = require(StarterPlayer.StarterPlayerScripts.Client.Areas.TeleportPlayer)

Expand Down Expand Up @@ -52,6 +54,7 @@ function WeaponShop:_initialize(): ()
petUtils.instantiatePets(player.Name, selectors.getEquippedPets(store:getState(), player.Name))
end)
else
PopupUI "You Must Buy The Clown Town Teleport First!"
teleportUI:setEnabled(true)
end
end)
Expand All @@ -70,6 +73,7 @@ function WeaponShop:_initialize(): ()
--local damage = weapons[button.Name].Price.Value

if button:FindFirstChild "Locked" and button.Locked.Visible then
PopupUI "You must buy the previous weapon first!"
return
end

Expand Down Expand Up @@ -130,6 +134,8 @@ function WeaponShop:_initialize(): ()
focusedDisplay.GreenButton.Visible = true
self._eventConnections["PurchaseButton"] = focusedDisplay.GreenButton.Activated:Connect(function()
if selectors.getStat(store:getState(), player.Name, "Gems") < price then
PopupUI "You Can Not Afford This Weapon!"
RobuxShop:OpenSubShop "Gems"
return
end
Remotes.Client:Get("PurchaseWeapon"):CallServerAsync(button.Name)
Expand Down
2 changes: 2 additions & 0 deletions src/server/Combat/Enemies/ApplyDamageToEnemy.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local ReplicatedStorage = game:GetService "ReplicatedStorage"
local CollectionService = game:GetService "CollectionService"
local ServerScriptService = game:GetService "ServerScriptService"

local Remotes = require(ReplicatedStorage.Common.Remotes)
Expand Down Expand Up @@ -51,6 +52,7 @@ return function(player, enemy, info, janitor)
info.DamageDealtByPlayer[player] = (info.DamageDealtByPlayer[player] or 0) + damageToDeal
info.HealthValue.Value -= damageToDeal
Remotes.Server:Get("SendFightInfo"):SendToPlayer(player, {
IsBoss = CollectionService:HasTag(enemy, "Boss"),
Gems = enemy.Configuration.Gems.Value,
Health = info.HealthValue.Value,
MaxHealth = info.MaxHealth,
Expand Down
12 changes: 8 additions & 4 deletions src/server/Exchange/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ local function handlePunchingBag(bag: any)
local cancelled = false

if
inUse
or selectors.getCurrentTarget(store:getState(), player.Name)
or selectors.getStat(store:getState(), player.Name, "Fear")
< selectors.getStat(store:getState(), player.Name, "RequiredFear")
selectors.getStat(store:getState(), player.Name, "Fear")
< selectors.getStat(store:getState(), player.Name, "RequiredFear")
then
Remotes.Server:Get("SendPopupMessage"):SendToPlayer(player, "Not enough fear!")
Remotes.Server:Get("OpenRobuxShopOnClient"):SendToPlayer(player, "Fear")
return
end

if inUse or selectors.getCurrentTarget(store:getState(), player.Name) then
if selectors.getCurrentTarget(store:getState(), player.Name) == bag and not cancelled then
disableSwitch:Fire(player)
end
Expand Down
Loading

0 comments on commit 2e723c6

Please sign in to comment.