Permalink
Browse files

Notification for unlocking organelles (#523)

Notifications! :D
  • Loading branch information...
zyad137 authored and crodnu committed Aug 14, 2017
1 parent a12e7ae commit b428537ed0b5ff4dffb08a96262eb8f29bceb2dd
Showing with 93 additions and 7 deletions.
  1. +16 −0 scripts/microbe_stage/configs.lua
  2. +77 −7 scripts/microbe_stage/microbe_stage_hud.lua
@@ -22,13 +22,16 @@ agents = {
-- must be global
chloroplast_Organelle_Number = 0
toxin_Organelle_Number = 0
chloroplast_unlocked = false
toxin_unlocked = false
-- this count the toxin Organelle Number
function toxin_number()
toxin_Organelle_Number = toxin_Organelle_Number + 1
print (toxin_Organelle_Number)
if toxin_Organelle_Number >= 3 then -- 3 is an example
toxinEffect()
toxin_call_Notification()
end
return true
end
@@ -48,6 +51,7 @@ function chloroplast_number()
print (chloroplast_Organelle_Number)
if chloroplast_Organelle_Number >= 3 then -- 3 is an example
chloroplastEffect()
chloroplast_call_Notification()
end
return true
end
@@ -61,6 +65,18 @@ if Engine:playerData():lockedMap():isLocked("chloroplast") then
getComponent(guiSoundEntity, SoundSourceComponent):playSound("microbe-pickup-organelle")
end
end
function chloroplast_call_Notification()
if chloroplast_unlocked == false then
global_activeMicrobeStageHudSystem:chloroplastNotificationenable()
chloroplast_unlocked = true
end
end
function toxin_call_Notification()
if toxin_unlocked == false then
global_activeMicrobeStageHudSystem:toxinNotificationenable()
toxin_unlocked = true
end
end
--[[
Placing organelles can get downright annoying if you don't
@@ -1,7 +1,12 @@
--
-- TODO: merge the common things in microbe_stage_tutorial_hud
--
-- notification setting up
t1 = 0
t2 = 0
t3 = 0
b1 = false
b2 = false
b3 = false
-- Updates the hud with relevant information
@@ -24,6 +29,8 @@ HudSystem = class(
end
)
-- This methods would get overriden by their duplicates below.
--[[
function HudSystem:init(gameState)
LuaSystem.init(self, "HudSystem", gameState)
end
@@ -41,6 +48,7 @@ function HudSystem:update(renderTime, logicTime)
self.saveDown = saveDown
self.loadDown = loadDown
end
]]
global_if_already_displayed = false
@@ -56,7 +64,11 @@ function HudSystem:activate()
self.menuOpen = false
self.compoundsOpen = true
Engine:resumeGame()
self:updateLoadButton();
self:updateLoadButton()
self:chloroplastNotificationdisable()
self:toxinNotificationdisable()
self:editornotificationdisable()
end
function HudSystem:init(gameState)
@@ -71,6 +83,8 @@ function HudSystem:init(gameState)
local loadButton = self.rootGUIWindow:getChild("PauseMenu"):getChild("LoadGameButton")
local resumeButton = self.rootGUIWindow:getChild("PauseMenu"):getChild("ResumeButton")
local closeHelpButton = self.rootGUIWindow:getChild("PauseMenu"):getChild("CloseHelpButton")
local chloroplast_unlock_notification = self.rootGUIWindow:getChild("chloroplastUnlockNotification")
local toxin_unlock_notification = self.rootGUIWindow:getChild("toxinUnlockNotification")
--local collapseButton = self.rootGUIWindow:getChild() collapseButtonClicked
local helpButton = self.rootGUIWindow:getChild("PauseMenu"):getChild("HelpButton")
local helpPanel = self.rootGUIWindow:getChild("PauseMenu"):getChild("HelpPanel")
@@ -182,9 +196,33 @@ function HudSystem:update(renderTime)
self.oxytoxyMaxLabel:setText("/ ".. math.floor(playerMicrobe.microbe.capacity/CompoundRegistry.getCompoundUnitVolume(CompoundRegistry.getCompoundId("oxytoxy"))))
local playerSpecies = playerMicrobe:getSpeciesComponent()
--notification setting up
if b1 == true and t1 < 300 then
t1 = t1 + 2
if t1 == 300 then
global_activeMicrobeStageHudSystem:chloroplastNotificationdisable()
end
end
if b2 == true and t2 < 300 then
t2 = t2 + 2
if t2 == 300 then
global_activeMicrobeStageHudSystem:toxinNotificationdisable()
end
end
if b3 == true and t3 < 300 then
t3 = t3 + 2
if t3 == 300 then
global_activeMicrobeStageHudSystem:editornotificationdisable()
end
end
--TODO display population in home patch here
if keyCombo(kmp.togglemenu) then
self:menuButtonClicked()
elseif keyCombo(kmp.gotoeditor) then
@@ -254,6 +292,12 @@ end
function HudSystem:showReproductionDialog()
-- print("Reproduction Dialog called but currently disabled. Is it needed? Note that the editor button has been enabled")
--global_activeMicrobeStageHudSystem.rootGUIWindow:getChild("ReproductionPanel"):show()
if b3 == false then
getComponent("gui_sounds", g_luaEngine.currentGameState, SoundSourceComponent
):playSound("microbe-pickup-organelle")
self.rootGUIWindow:getChild("editornotification"):show()
b3 = true
end
self.editorButton:enable()
end
@@ -323,6 +367,32 @@ function HudSystem:toggleCompoundPanel()
end
end
function HudSystem:chloroplastNotificationenable()
getComponent("gui_sounds", g_luaEngine.currentGameState, SoundSourceComponent
):playSound("microbe-pickup-organelle")
self.rootGUIWindow:getChild("chloroplastUnlockNotification"):show()
b1 = true
self.rootGUIWindow:getChild("toxinUnlockNotification"):hide()
end
function HudSystem:chloroplastNotificationdisable()
self.rootGUIWindow:getChild("chloroplastUnlockNotification"):hide()
end
function HudSystem:toxinNotificationenable()
getComponent("gui_sounds", g_luaEngine.currentGameState, SoundSourceComponent
):playSound("microbe-pickup-organelle")
self.rootGUIWindow:getChild("toxinUnlockNotification"):show()
b2 = true
self.rootGUIWindow:getChild("chloroplastUnlockNotification"):hide()
end
function HudSystem:toxinNotificationdisable()
self.rootGUIWindow:getChild("toxinUnlockNotification"):hide()
end
function HudSystem:editornotificationdisable()
self.rootGUIWindow:getChild("editornotification"):hide()
end
function HudSystem:helpButtonClicked()
getComponent("gui_sounds", self.gameState, SoundSourceComponent):playSound("button-hover-click")
self.rootGUIWindow:getChild("PauseMenu"):getChild("HelpPanel"):show()
@@ -369,6 +439,8 @@ function HudSystem:editorButtonClicked()
getComponent("gui_sounds", self.gameState, SoundSourceComponent):playSound("button-hover-click")
self.editorButton:disable()
b3 = false
t3 = 0
g_luaEngine:setCurrentGameState(GameState.MICROBE_EDITOR)
end
@@ -390,5 +462,3 @@ function quitButtonClicked()
getComponent("gui_sounds", self.gameState, SoundSourceComponent):playSound("button-hover-click")
Engine:quit()
end

0 comments on commit b428537

Please sign in to comment.