Integrating PuzzleWakeMethod (1/2)
This commit is contained in:
@@ -13,6 +13,12 @@ class AlarmActivationViewController: UIViewController
|
|||||||
var timer: Timer?
|
var timer: Timer?
|
||||||
var currentAlarm: Alarm?
|
var currentAlarm: Alarm?
|
||||||
|
|
||||||
|
//Outlets
|
||||||
|
@IBOutlet weak var puzzleView: UIView!
|
||||||
|
@IBOutlet weak var puzzleQuestionLabel: UILabel!
|
||||||
|
@IBOutlet weak var puzzleAnswerInput: UITextField!
|
||||||
|
var puzzleAnswers: [Int] = []
|
||||||
|
|
||||||
init?(coder: NSCoder, currentAlarm: Alarm)
|
init?(coder: NSCoder, currentAlarm: Alarm)
|
||||||
{
|
{
|
||||||
self.currentAlarm = currentAlarm
|
self.currentAlarm = currentAlarm
|
||||||
@@ -27,6 +33,9 @@ class AlarmActivationViewController: UIViewController
|
|||||||
override func viewDidLoad()
|
override func viewDidLoad()
|
||||||
{
|
{
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
//Hide all inactive wakemethods
|
||||||
|
puzzleView.isHidden = true
|
||||||
|
|
||||||
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AlarmActivationViewController.playSound), userInfo: nil, repeats: true)
|
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AlarmActivationViewController.playSound), userInfo: nil, repeats: true)
|
||||||
setAlarmType()
|
setAlarmType()
|
||||||
print(MathExpression.random())
|
print(MathExpression.random())
|
||||||
@@ -48,7 +57,8 @@ class AlarmActivationViewController: UIViewController
|
|||||||
case "Jump":
|
case "Jump":
|
||||||
jumpAction()
|
jumpAction()
|
||||||
case "Puzzle":
|
case "Puzzle":
|
||||||
puzzleAction()
|
self.puzzleAnswers = puzzleAction(puzzleQuestionLabel: puzzleQuestionLabel)
|
||||||
|
puzzleView.isHidden = false
|
||||||
case "Smash":
|
case "Smash":
|
||||||
print("")
|
print("")
|
||||||
default:
|
default:
|
||||||
@@ -56,4 +66,10 @@ class AlarmActivationViewController: UIViewController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func checkPuzzleSolution(_ sender: Any) {
|
||||||
|
if puzzleAnswers.contains(Int(puzzleAnswerInput.text!)!) {
|
||||||
|
print("alarm solved")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -639,6 +639,36 @@
|
|||||||
<nil key="textColor"/>
|
<nil key="textColor"/>
|
||||||
<nil key="highlightedColor"/>
|
<nil key="highlightedColor"/>
|
||||||
</label>
|
</label>
|
||||||
|
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OMQ-qK-fej" userLabel="PuzzleAlarm">
|
||||||
|
<rect key="frame" x="20" y="261" width="374" height="343"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Solve: " lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CZ0-R6-FDq">
|
||||||
|
<rect key="frame" x="39" y="35" width="300" height="33"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="27"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<textField opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="eTb-g7-8x3">
|
||||||
|
<rect key="frame" x="39" y="154" width="309" height="34"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||||
|
<textInputTraits key="textInputTraits" textContentType="cc-number"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="checkPuzzleSolution:" destination="hDW-11-g9U" eventType="editingChanged" id="nuZ-mN-UR3"/>
|
||||||
|
</connections>
|
||||||
|
</textField>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Input 1 answer:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vHe-pz-8w2">
|
||||||
|
<rect key="frame" x="39" y="113" width="174" height="33"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="27"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" systemColor="systemGray6Color"/>
|
||||||
|
</view>
|
||||||
</subviews>
|
</subviews>
|
||||||
<viewLayoutGuide key="safeArea" id="hS6-fS-yWp"/>
|
<viewLayoutGuide key="safeArea" id="hS6-fS-yWp"/>
|
||||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||||
@@ -653,10 +683,15 @@
|
|||||||
<constraint firstItem="hS6-fS-yWp" firstAttribute="trailing" secondItem="vmg-Oj-8tB" secondAttribute="trailing" constant="20" id="vVE-ID-dgj"/>
|
<constraint firstItem="hS6-fS-yWp" firstAttribute="trailing" secondItem="vmg-Oj-8tB" secondAttribute="trailing" constant="20" id="vVE-ID-dgj"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
|
<connections>
|
||||||
|
<outlet property="puzzleAnswerInput" destination="eTb-g7-8x3" id="xIh-TJ-vhq"/>
|
||||||
|
<outlet property="puzzleQuestionLabel" destination="CZ0-R6-FDq" id="gon-N6-XTD"/>
|
||||||
|
<outlet property="puzzleView" destination="OMQ-qK-fej" id="KLT-oe-RJX"/>
|
||||||
|
</connections>
|
||||||
</viewController>
|
</viewController>
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="78q-sr-CNz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
<placeholder placeholderIdentifier="IBFirstResponder" id="78q-sr-CNz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||||
</objects>
|
</objects>
|
||||||
<point key="canvasLocation" x="1701" y="1102"/>
|
<point key="canvasLocation" x="1700.0000000000002" y="1101.5625"/>
|
||||||
</scene>
|
</scene>
|
||||||
<!--Alarm Activator-->
|
<!--Alarm Activator-->
|
||||||
<scene sceneID="c7a-VN-D68">
|
<scene sceneID="c7a-VN-D68">
|
||||||
@@ -692,6 +727,9 @@
|
|||||||
<systemColor name="systemBackgroundColor">
|
<systemColor name="systemBackgroundColor">
|
||||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
</systemColor>
|
</systemColor>
|
||||||
|
<systemColor name="systemGray6Color">
|
||||||
|
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
|
</systemColor>
|
||||||
<systemColor name="systemOrangeColor">
|
<systemColor name="systemOrangeColor">
|
||||||
<color red="1" green="0.58431372549019611" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
<color red="1" green="0.58431372549019611" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
</systemColor>
|
</systemColor>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import CoreMotion
|
import CoreMotion
|
||||||
import UserNotifications
|
import UserNotifications
|
||||||
|
import UIKit
|
||||||
|
|
||||||
let motionManager = CMMotionManager()
|
let motionManager = CMMotionManager()
|
||||||
|
|
||||||
@@ -27,14 +28,15 @@ func jumpAction() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func puzzleAction() {
|
func puzzleAction(puzzleQuestionLabel: UILabel) -> [Int] {
|
||||||
var problem = QuadraticProb()
|
var problem = QuadraticProb()
|
||||||
|
|
||||||
let answer = problem.getAnswer()
|
let answer = problem.getAnswer()
|
||||||
let problemString = problem.getProblem()
|
let problemString = problem.getProblem()
|
||||||
|
|
||||||
print("Problem: \(problemString)")
|
puzzleQuestionLabel.text = "Solve: \(problemString)"
|
||||||
print("Answer: \(answer)")
|
print("Answer: \(answer)")
|
||||||
|
return answer
|
||||||
}
|
}
|
||||||
|
|
||||||
func smashAction() {
|
func smashAction() {
|
||||||
|
|||||||
Reference in New Issue
Block a user