Permalink
Browse files

Remove old tech files

  • Loading branch information...
Silverfeelin committed Oct 1, 2016
1 parent 0bc681e commit d3803a2f1f5ce65b980eb7624d64581b2730a5f6
View
@@ -1,121 +0,0 @@
require "/tech/doubletap.lua"
function init()
require "/scripts/luanimator.lua"
self.mode = "none"
self.blinkTimer = 0
self.dashDirection = 0
self.dashCooldownTimer = 0
self.rechargeEffectTimer = 0
self.blinkOutTime = config.getParameter("blinkOutTime")
self.blinkInTime = config.getParameter("blinkInTime")
self.groundOnly = config.getParameter("groundOnly")
self.dashMaxDistance = config.getParameter("dashDistance")
self.dashCooldown = config.getParameter("dashCooldown")
self.rechargeDirectives = config.getParameter("rechargeDirectives", "?fade=CCCCFFFF=0.25")
self.rechargeEffectTime = config.getParameter("rechargeEffectTime", 0.1)
self.doubleTap = DoubleTap:new({"left", "right"}, config.getParameter("maximumDoubleTapTime"), function(dashKey)
if self.mode == "none"
and self.dashCooldownTimer == 0
and groundValid()
and not mcontroller.crouching()
and not status.statPositive("activeMovementAbilities") then
self.targetPosition = findTargetPosition(dashKey == "left" and -1 or 1, self.dashMaxDistance)
if self.targetPosition then self.mode = "start" end
end
end)
end
function uninit()
status.clearPersistentEffects("movementAbility")
end
function update(args)
if self.dashCooldownTimer > 0 then
self.dashCooldownTimer = math.max(0, self.dashCooldownTimer - args.dt)
if self.dashCooldownTimer == 0 then
self.rechargeEffectTimer = self.rechargeEffectTime
animator.playSound("recharge")
end
end
if self.rechargeEffectTimer > 0 then
self.rechargeEffectTimer = math.max(0, self.rechargeEffectTimer - args.dt)
end
self.doubleTap:update(args.dt, args.moves)
if self.mode == "start" then
mcontroller.setVelocity({0, 0})
tech.setToolUsageSuppressed(true)
self.mode = "out"
self.blinkTimer = 0
animator.playSound("activate")
status.setPersistentEffects("movementAbility", {{stat = "activeMovementAbilities", amount = 1}})
elseif self.mode == "out" then
animator.setAnimationState("blinking", "out")
mcontroller.setVelocity({0, 0})
self.blinkTimer = self.blinkTimer + args.dt
if self.blinkTimer > self.blinkOutTime then
mcontroller.setPosition(self.targetPosition)
self.targetPosition = nil
self.mode = "in"
self.blinkTimer = 0
end
elseif self.mode == "in" then
animator.setAnimationState("blinking", "in")
mcontroller.setVelocity({0, 0})
self.blinkTimer = self.blinkTimer + args.dt
if self.blinkTimer > self.blinkInTime then
tech.setToolUsageSuppressed(false)
self.mode = "none"
self.dashCooldownTimer = self.dashCooldown
status.clearPersistentEffects("movementAbility")
end
end
end
function groundValid()
return mcontroller.onGround() or not self.groundOnly
end
function findTargetPosition(dir, maxDist)
local dist = 1
local targetPosition
local collisionPoly = mcontroller.collisionPoly()
local testPos = mcontroller.position()
while dist <= maxDist do
testPos[1] = testPos[1] + dir
if not world.polyCollision(collisionPoly, testPos, {"Null", "Block", "Dynamic"}) then
local oneDown = {testPos[1], testPos[2] - 1}
if not world.polyCollision(collisionPoly, oneDown, {"Null", "Block", "Dynamic"}) then
testPos = oneDown
end
else
local oneUp = {testPos[1], testPos[2] + 1}
if not world.polyCollision(collisionPoly, oneUp, {"Null", "Block", "Dynamic"}) then
testPos = oneUp
else
break
end
end
targetPosition = testPos
dist = dist + 1
end
if targetPosition then
local towardGround = {testPos[1], testPos[2] - 0.8}
local groundPosition = world.resolvePolyCollision(collisionPoly, towardGround, 0.8)
if groundPosition and not (groundPosition[1] == towardGround[1] and groundPosition[2] == towardGround[2]) then
targetPosition = groundPosition
end
end
return targetPosition
end
View
@@ -1,89 +0,0 @@
require "/tech/doubletap.lua"
function init()
require "/scripts/luanimator.lua"
self.energyCostPerSecond = config.getParameter("energyCostPerSecond")
self.dashControlForce = config.getParameter("dashControlForce")
self.dashRunModifier = config.getParameter("dashRunModifier")
self.groundOnly = config.getParameter("groundOnly")
self.stopAfterDash = config.getParameter("stopAfterDash")
self.doubleTap = DoubleTap:new({"left", "right"}, config.getParameter("maximumDoubleTapTime"), function(dashKey)
local direction = dashKey == "left" and -1 or 1
if not self.dashDirection
and groundValid()
and mcontroller.facingDirection() == direction
and not mcontroller.crouching()
and not status.resourceLocked("energy")
and not status.statPositive("activeMovementAbilities") then
startDash(direction)
end
end)
end
function uninit()
status.clearPersistentEffects("movementAbility")
end
function update(args)
self.doubleTap:update(args.dt, args.moves)
if self.dashDirection then
if args.moves[self.dashDirection > 0 and "right" or "left"]
and not mcontroller.liquidMovement()
and not dashBlocked() then
if mcontroller.facingDirection() == self.dashDirection then
if status.overConsumeResource("energy", self.energyCostPerSecond * args.dt) then
mcontroller.controlModifiers({runModifier = self.dashRunModifier})
animator.setAnimationState("dashing", "on")
animator.setParticleEmitterActive("dashParticles", true)
else
endDash()
end
else
animator.setAnimationState("dashing", "off")
animator.setParticleEmitterActive("dashParticles", false)
end
else
endDash()
end
end
end
function groundValid()
return mcontroller.onGround() or not self.groundOnly
end
function dashBlocked()
return mcontroller.velocity()[1] == 0
end
function startDash(direction)
self.dashDirection = direction
status.setPersistentEffects("movementAbility", {{stat = "activeMovementAbilities", amount = 1}})
animator.setFlipped(self.dashDirection == -1)
animator.setAnimationState("dashing", "on")
animator.setParticleEmitterActive("dashParticles", true)
end
function endDash(direction)
status.clearPersistentEffects("movementAbility")
if self.stopAfterDash then
local movementParams = mcontroller.baseParameters()
local currentVelocity = mcontroller.velocity()
if math.abs(currentVelocity[1]) > movementParams.runSpeed then
mcontroller.setVelocity({movementParams.runSpeed * self.dashDirection, 0})
end
mcontroller.controlApproachXVelocity(self.dashDirection * movementParams.runSpeed, self.dashControlForce)
end
animator.setAnimationState("dashing", "off")
animator.setParticleEmitterActive("dashParticles", false)
self.dashDirection = nil
end
@@ -1,66 +0,0 @@
require "/tech/distortionsphere/distortionsphere.lua"
function init()
require "/scripts/luanimator.lua"
initCommonParameters()
self.ballLiquidSpeed = config.getParameter("ballLiquidSpeed")
end
function update(args)
restoreStoredPosition()
if not self.specialLast and args.moves["special"] == 1 then
attemptActivation()
end
self.specialLast = args.moves["special"] == 1
if self.active then
local inLiquid = mcontroller.liquidPercentage() > 0.2
if inLiquid then
self.transformedMovementParameters.runSpeed = self.ballLiquidSpeed
self.transformedMovementParameters.walkSpeed = self.ballLiquidSpeed
else
self.transformedMovementParameters.runSpeed = self.ballSpeed
self.transformedMovementParameters.walkSpeed = self.ballSpeed
end
mcontroller.controlParameters(self.transformedMovementParameters)
status.setResourcePercentage("energyRegenBlock", 1.0)
local controlDirection = 0
if args.moves["right"] then controlDirection = controlDirection - 1 end
if args.moves["left"] then controlDirection = controlDirection + 1 end
updateAngularVelocity(args.dt, inLiquid, controlDirection)
updateRotationFrame(args.dt)
end
updateTransformFade(args.dt)
self.lastPosition = mcontroller.position()
end
function updateAngularVelocity(dt, inLiquid, controlDirection)
if mcontroller.isColliding() then
-- If we are on the ground, assume we are rolling without slipping to
-- determine the angular velocity
local positionDiff = world.distance(self.lastPosition or mcontroller.position(), mcontroller.position())
self.angularVelocity = -vec2.mag(positionDiff) / dt / self.ballRadius
if positionDiff[1] > 0 then
self.angularVelocity = -self.angularVelocity
end
elseif inLiquid then
if controlDirection ~= 0 then
self.angularVelocity = 1.5 * self.ballLiquidSpeed * controlDirection
else
self.angularVelocity = self.angularVelocity - (self.angularVelocity * 0.8 * dt)
if math.abs(self.angularVelocity) < 0.1 then
self.angularVelocity = 0
end
end
end
end
Oops, something went wrong.

0 comments on commit d3803a2

Please sign in to comment.