大宮盆栽デイズ - Omiya Bonsai Days -

冗談めかす埼玉のファインマン

力を合わせて@コードを学ぼう2

//力を合わせて@コードを学ぼう2
let expert = Expert()
let character = Character()

func goToPinkKey() {
    expert.turnLeft()
    while !expert.isBlocked {
        expert.moveForward()
    }
    expert.turnRight()
    expert.moveForward()
    expert.moveForward()
    expert.turnLeft()
}

func goToCenter() {
    expert.turnLeft()
    expert.moveForward()
    expert.moveForward()
    expert.turnLeft()
    for i in 1 ... 3 {
        expert.moveForward()
    }
    expert.turnLeft()
}
func goToGreenKey() {
    expert.turnRight()
    while !expert.isBlocked {
        expert.moveForward()
    }
    expert.turnLeft()
    expert.moveForward()
    expert.moveForward()
    expert.turnRight()
}
goToPinkKey()
expert.turnLockDown()
expert.turnLockDown()
goToCenter()
goToGreenKey()
expert.turnLockUp()

for i in 1 ... 5 {
    if character.isOnGem {
        character.collectGem()
    } else if character.isOnClosedSwitch {
        character.toggleSwitch()
    }
    character.moveForward()
}