Advertisement
Guest User

level1.lua

a guest
Jun 21st, 2016
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.97 KB | None | 0 0
  1. Math = luajava.bindClass("java.lang.Math")
  2.  
  3. function onCreate()
  4. -- properties
  5.  
  6. world.MAX_X = 100
  7. world.MAX_Y = 100
  8. world.freeEnergy = 100
  9. world.viscosity = 100
  10. world.BrownianCutoff = 0
  11. world.unlimitedEnergy = true;
  12. -- lights
  13. -- genome
  14. --stage:setSensitivityValues({0, 25, 50, 75, 100})
  15. stage:setSensitivityValues({0, 10, 75})
  16. stage.showHPBar = false
  17. stage:setShowDegradationValues(false)
  18. stage:setShowSensitivityValues(false)
  19.  
  20. stage:setShowCostOnIcon(false)
  21. stage:setShowDegradationOnIcon(false)
  22.  
  23. local genome = luajava.newInstance("com.sgstudio.genebox.blogic.Genome")
  24. genome.maxPopulationDivide = 1
  25. genome.color:set(0, 0.5, 0.5, 1)
  26. genome.shape = "hedgehog"
  27. world:setGenome(genome)
  28.  
  29. local Gene = luajava.bindClass("com.sgstudio.genebox.blogic.genes.Gene")
  30. local GeneType = luajava.bindClass("com.sgstudio.genebox.blogic.genes.Gene$TYPE")
  31.  
  32. housekeepingGene = Gene:createGeneByType(GeneType.HOUSEKEEPING)
  33. housekeepingGene:setPosition(100, 100)
  34. housekeepingGene.defaultProteins = 50
  35. housekeepingGene.controlled = false
  36. genome:addGene(housekeepingGene)
  37.  
  38. growthGene = Gene:createGeneByType(GeneType.GROWTH)
  39. growthGene:setPosition(300, 100)
  40. growthGene.defaultProteins = 100
  41. growthGene.isRegulator = false
  42. genome:addGene(growthGene)
  43. housekeepingGene.deletable=false
  44. growthGene.deletable=false
  45.  
  46. housekeepingGene:addRegulator(housekeepingGene, 200);
  47.  
  48. --Solution
  49. --growthGene:addRegulator(housekeepingGene, 10);
  50.  
  51.  
  52. -- microbes
  53.  
  54. Microbe1 = world:addMicrobeToGroup(genome, 50, 50);
  55.  
  56. -- available genes
  57.  
  58. world:addAvailableGene(GeneType.NONE)
  59. -- win conditions
  60.  
  61. timer = 100
  62.  
  63. hint = 0
  64.  
  65. --[[stage:showHintWindow({"text:CLICK_DIAGRAM,align:right,highlight:true,actorName:playButton",
  66. "text:CLICK_DIAGRAM,align:left,arrowAlign:right,actorName:mainMenuButton",
  67. "text:CLICK_DIAGRAM,align:left,arrowAlign:left,highlight:true,actorName:diagramButton",
  68. "text:CLICK_DIAGRAM,align:left,arrowAlign:bottomLeft,highlight:true,actorName:diagramButton",
  69. "text:CLICK_DIAGRAM,align:topRight,actorName:diagramButton",
  70. "text:LEVEL1_HINT_1,image:hints/Lvl1Fig1.png,imageSize:200",
  71. "text:LEVEL1_HINT_2,image:hints/Lvl1Fig2.png,imageSize:50",
  72. "text:LEVEL1_HINT_3,image:hints/Lvl1Fig3.png,imageSize:100",
  73. "text:LEVEL1_HINT_4,image:hints/Lvl1Fig4.png,imageSize:50",
  74. "text:LEVEL1_HINT_5,image:hints/Lvl1Fig5.png,imageSize:150"})
  75.  
  76. stage:showHintWindow({"text:WELCOME_HINT,image:hints/Lvl1Fig1.png,imageSize:200,stageBackground:true",
  77. "text:GROWTH_OBJECTIVE,image:hints/Lvl1Fig1.png,imageSize:200,stageBackground:true",
  78. "text:CLICK_ON_DIAGRAM,align:right,arrowAlign:bottom,highlight:true,actorName:diagramButton,waitFor:diagramWindow,width:200,pad:100",
  79. "text:GENES_FIRST_HINT, align:bottomRight,arrowAlign:right, actorName:geneTableHousekeeping, width:200",
  80. "text:CLICK_ON_GENE, align:bottomRight, arrowAlign:right, actorName:geneTableHousekeeping, waitFor:geneControlWindow,width:400",
  81. "text:DRAG_IT,align:topRight,arrowAlign:top,actorName:dependencyButton,moveTo:geneTableGrowth,hideClose:true"})
  82. ]]
  83. stage:showHintWindow({"text:WELCOME_HINT,image:hints/Lvl1Fig1.png,imageSize:200,stageBackground:true",
  84. "text:GROWTH_OBJECTIVE,image:hints/Lvl1Fig2.png,imageSize:200,stageBackground:true",
  85. "text:CLICK_ON_DIAGRAM,align:right,arrowAlign:bottom,highlight:true,actorName:diagramButton,waitFor:diagramWindow,width:200,pad:100",
  86. "text:GENES_FIRST_HINT,align:right,width:450",
  87. "text:GENES_SECOND_HINT,image:hints/Lvl1Fig3.png,imageSize:150,align:right,width:450",
  88. "text:GENES_THIRD_HINT,image:hints/Lvl1Fig4.png,imageSize:200,align:right,width:500",
  89. "text:GENES_FOURTH_HINT,image:hints/Lvl1Fig5.png,imageSize:200,align:right,width:400",
  90. "text:GENES_FIFTH_HINT,image:hints/Lvl1Fig6.png,imageSize:200,align:right,width:400",
  91. "text:GENES_SIXTH_HINT,image:hints/Lvl1Fig7.png,imageSize:300,align:right,width:400",
  92.  
  93. "text:CLICK_ON_GENE,align:bottomRight,arrowAlign:right,actorName:geneTableHousekeeping,waitFor:geneControlWindow,width:300",
  94. "text:DRAG_IT,align:topRight,arrowAlign:top,actorName:dependencyButton,moveTo:geneTableGrowth,hideClose:true"})
  95. end
  96.  
  97. function onCheck(delta)
  98.  
  99. local cnt = world.microbes:get(world:getGenome()):size()
  100. --energyZones[5].enabled = world.time < 50
  101.  
  102. if Microbe1.size >= 8 then stage:finish(true) end
  103.  
  104. if timer < stage:getTime() or cnt == 0 then
  105. stage:finish(1 == cnt)
  106. end
  107.  
  108. stage:setTimer(timer - stage:getTime())
  109. stage:setMicrobeCount(Microbe1.size, 8, "gene_growth")
  110. end
  111.  
  112. function onAct()
  113. if hint == 0 and stage.gameUIStage:getRoot():findActor("sensitivityWindow") ~= nil and
  114. stage.gameUIStage:getRoot():findActor("sensitivityWindow"):isVisible() then
  115. hint = 1
  116. stage:showHintWindow("text:MOVE_TO_2_ARROWS,align:topRight,hideClose:true,actorName:sensitivityWindow,moveBy:0x60,arrowOffset:0x-60,arrowAlign:right")
  117. --[[stage.gameUIStage.hintWindow:setCheckListener(luajava.createProxy('com.badlogic.gdx.scenes.scene2d.EventListener', {
  118. handle = function()
  119. local hasMore50 = growthGene.regulatedBy:get(0).sensitivity > 50
  120. if hasMore50 then
  121. stage:showHintWindow("text:CLOSE_DIAGRAM_AND_SEE,align:bottomLeft,arrowAlign:bottom,actorName:diagramButton,waitFor:!diagramWindow")
  122. stage.gameUIStage.hintWindow:setOnCloseListener(luajava.createProxy('com.badlogic.gdx.scenes.scene2d.EventListener', {
  123. handle = function(e)
  124. stage:setSpeed(1)
  125. end
  126. }))
  127. end
  128. return hasMore50
  129. end
  130. }))]]
  131. end
  132.  
  133. if hint == 1 and growthGene.regulatedBy:get(0).sensitivity >= 50 then
  134. hint = 2
  135. stage:showHintWindow({"text:CLOSE_DIAGRAM,align:bottomLeft,arrowAlign:bottom,actorName:diagramButton,waitFor:!diagramWindow",
  136. "text:TAP_ON_MICROBE,align:bottom,arrowAlign:top,waitFor:microbeInfoTable",
  137. "text:CLICK_HERE_TO_ENABLE_GRAPH,align:top,arrowAlign:top,actorName:geneTableGrowthForGraph,hideClose:true",
  138. "text:SEE_THE_GOAL,align:left,arrowAlign:bottom,actorName:statusProgressBar"})
  139. end
  140.  
  141. if hint == 2 and stage.gameUIStage.gameUI.infoTable:isVisible(growthGene) then
  142. stage:showHintWindow("text:CLICK_ON_PLAY,align:left,arrowAlign:bottom,actorName:playButton,hideClose:true")
  143. hint = 3
  144. end
  145.  
  146. if stage.speed > 0 and hint == 3 then
  147. stage:closeHintWindow()
  148. hint = 4
  149. end
  150.  
  151. --[[if hint == 4 and stage:getTime()>10 then
  152. hint = 5
  153. stage:showHintWindow("text:LEVEL1_HINT_10,image:hints/Lvl1Fig10.png,imageSize:200")
  154. end
  155.  
  156. if hint == 3 and (stage.gameUIStage.gameUI.infoTable:showGraph(housekeepingGene) or stage.gameUIStage.gameUI.infoTable:showGraph(growthGene)) then
  157. hint = 4
  158. stage:showHintWindow("text:LEVEL1_HINT_9,image:hints/Lvl1Fig9.png,imageSize:100")
  159. end
  160.  
  161. --Here we need to learn if the mocrobe window is ON (instead 1==1)
  162. if hint == 2 and stage.gameUIStage.gameUI.infoTable:isVisible() then
  163. hint = 3
  164. stage:showHintWindow("text:LEVEL1_HINT_8,image:hints/Lvl1Fig8.png,imageSize:100")
  165. end
  166.  
  167. if hint == 1 and growthGene.regulatedBy:size() > 0 then
  168. if growthGene.regulatedBy:get(0).sensitivity > 50 then
  169. hint = 2
  170. stage:showHintWindow("text:LEVEL1_HINT_7,image:hints/Lvl1Fig7.png,imageSize:0")
  171. end
  172. end
  173.  
  174. if hint == 0 and growthGene.regulatedBy:size() > 0 then
  175. hint = 1
  176. stage:showHintWindow("text:LEVEL1_HINT_6,image:hints/Lvl1Fig6.png,imageSize:200")
  177. end]]
  178. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement