Skip to content

Commit

Permalink
Merge pull request #403 from Revolutionary-Games/RemainingIssues-0.3.1
Browse files Browse the repository at this point in the history
Fixed Remainaing issues for 0.3.1
  • Loading branch information
TheCreator-- committed Feb 18, 2016
2 parents f05c1b5 + e37fc90 commit 1f0fad7
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 8 deletions.
8 changes: 6 additions & 2 deletions scripts/microbe_editor/microbe_editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ function MicrobeEditor:isValidPlacement(organelleType, q, r, rotation)
end
end

if empty and touching then
if empty and touching then
newOrganelle.rotation = data.rotation
return newOrganelle
else
return nil
Expand Down Expand Up @@ -319,8 +320,11 @@ function MicrobeEditor:_addOrganelle(organelle, q, r, rotation)
local cytoplasm = self.currentMicrobe:getOrganelleAt(hex.q + q, hex.r + r)
if cytoplasm then
if cytoplasm.name == "cytoplasm" then
self:removeOrganelleAt(hex.q + q, hex.r + r)
self.currentMicrobe:removeOrganelle(hex.q + q, hex.r + r)
self.currentMicrobe.sceneNode.transform:touch()
self.organelleCount = self.organelleCount - 1
local s = encodeAxial(hex.q + q, hex.r + r)
self.occupiedHexes[s]:destroy()
end
end
local x, y = axialToCartesian(hex.q + q, hex.r + r)
Expand Down
15 changes: 14 additions & 1 deletion scripts/microbe_editor/microbe_editor_hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ function MicrobeEditorHudSystem:init(gameState)

self.helpPanel = root:getChild("HelpPanel")
root:getChild("HelpButton"):registerEventHandler("Clicked", function() self:helpButtonClicked() end)

-- Set species name and cut it off if it is too long.
local name = self.nameLabel:getText()
if string.len(name) > 18 then
name = string.sub(name, 1, 15)
name = name .. "..."
end
self.nameLabel:setText(name)
end


Expand Down Expand Up @@ -258,7 +266,12 @@ end

function MicrobeEditorHudSystem:updateMicrobeName()
self.editor.currentMicrobe.microbe.speciesName = self.nameTextbox:getText()
self.nameLabel:setText(self.editor.currentMicrobe.microbe.speciesName)
local name = self.editor.currentMicrobe.microbe.speciesName
if string.len(name) > 18 then
name = string.sub(self.editor.currentMicrobe.microbe.speciesName, 1, 15)
name = name .. "..."
end
self.nameLabel:setText(name)
self.nameTextbox:hide()
self.nameLabel:show()
end
Expand Down
7 changes: 7 additions & 0 deletions scripts/microbe_stage/hex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,10 @@ function rotateAxial(q, r)
local r2 = q + r
return q2, r2
end

-- Flips a hex vertically about 0,0.
function flipHorizontally(q,r)
local q2 = -q
local r2 = q + r2
return q2, r2
end
4 changes: 3 additions & 1 deletion scripts/microbe_stage/movement_organelle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function MovementOrganelle:_moveMicrobe(microbe, milliseconds)
local direction = microbe.microbe.movementDirection
local forceMagnitude = self.force:dotProduct(direction)
if forceMagnitude > 0 then
if direction:isZeroLength() or self.force:isZeroLength() then
if direction:isZeroLength() or self.force:isZeroLength() then
self.movingTail = false
self.sceneNode:setAnimationSpeed(0.25)
return
Expand All @@ -57,6 +57,8 @@ function MovementOrganelle:_moveMicrobe(microbe, milliseconds)
local availableEnergy = microbe:takeCompound(CompoundRegistry.getCompoundId("atp"), energy)
if availableEnergy < energy then
forceMagnitude = sign(forceMagnitude) * availableEnergy * 1000 / milliseconds
self.movingTail = false
self.sceneNode:setAnimationSpeed(0.25)
end
local impulseMagnitude = microbe.microbe.movementFactor * milliseconds * forceMagnitude / 1000
local impulse = impulseMagnitude * direction
Expand Down
4 changes: 2 additions & 2 deletions scripts/microbe_stage/organelle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Organelle:__init()
q = 0,
r = 0
}
self.rotation = 0
self.rotation = nil
self.name = "<nameless>"
end

Expand Down Expand Up @@ -100,7 +100,7 @@ function Organelle:onAddedToMicrobe(microbe, q, r, rotation)
self.microbe = microbe
self.position.q = q
self.position.r = r
self.rotation = rotation
self.rotation = rotation

local offset = Vector3(0,0,0)
local count = 0
Expand Down
17 changes: 15 additions & 2 deletions scripts/microbe_stage/process_organelle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,15 @@ function OrganelleFactory.make_mitochondrion(data)
end

function OrganelleFactory.make_chloroplast(data)
local x, y = axialToCartesian(data.q, data.r)

local chloro = ProcessOrganelle()
chloro:addProcess(global_processMap["Photosynthesis"])

local angle = (data.rotation / 60)
if x < 0 then
angle = angle + 5
end

chloro:addHex(0, 0)
local q = 1
Expand Down Expand Up @@ -364,7 +369,11 @@ function OrganelleFactory.render_chloroplast(data)
data.sceneNode[2].transform.position = translation
OrganelleFactory.setColour(data.sceneNode[2], data.colour)

local angle = (data.rotation / 60)
local angle = (data.rotation / 60) + 5
if x < 0 then
angle = angle + 7
end

local q = 1
local r = 0
for i=0, angle do
Expand Down Expand Up @@ -411,9 +420,13 @@ function OrganelleFactory.sizeof_mitochondrion(data)
end

function OrganelleFactory.sizeof_chloroplast(data)
local x, y = axialToCartesian(data.q, data.r)
local hexes = {}

local angle = (data.rotation / 60)
local angle = (data.rotation / 60) + 5
if x < 0 then
angle = angle + 7
end

hexes[1] = {["q"]=0, ["r"]=0}

Expand Down

0 comments on commit 1f0fad7

Please sign in to comment.