Skip to content

Commit

Permalink
Only recognize loss through restart and quit, reposition cons won not…
Browse files Browse the repository at this point in the history
…ification
  • Loading branch information
h-shan committed Jul 29, 2016
1 parent 313b4c7 commit 7952029
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 37 deletions.
33 changes: 7 additions & 26 deletions StrategicSoccer/GameScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -282,31 +282,6 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
moveTimer?.pause()
self.userInteractionEnabled = false
}
if gType == .onePlayer{
statistics[Stats.totalGames]! += 1
switch(AIDifficulty){
case 1:
statistics[Stats.totalOne]! += 1
break
case 2:
statistics[Stats.totalTwo]! += 1
break
case 3:
statistics[Stats.totalThree]! += 1
break
case 4:
statistics[Stats.totalFour]! += 1
break
case 5:
statistics[Stats.totalFive]! += 1
break
default:break
}

saveStats()
}


}
func sendPosition(){
viewController.parent.gameService.sendPosition(self)
Expand Down Expand Up @@ -406,7 +381,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
if mode.getType() == .timed && !gameEnded{
showTime()
}
if (goalDelay.getElapsedTime()>2){
if (goalDelay.getElapsedTime()>2 && !gameEnded){
scoreBackground.fadeOut()
setDynamicStates(true)
moveTimer?.restart()
Expand Down Expand Up @@ -1121,23 +1096,29 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
// addChild(blue)
}
func updateStats(won: Bool){
statistics[Stats.totalGames]! += 1
if won{
statistics[Stats.totalWon]! += 1
}
switch(AIDifficulty){
case 1:
statistics[Stats.totalOne]! += 1
if won{statistics[Stats.oneWon]! += 1}
break
case 2:
statistics[Stats.totalTwo]! += 1
if won{statistics[Stats.twoWon]! += 1}
break
case 3:
statistics[Stats.totalThree]! += 1
if won{statistics[Stats.threeWon]! += 1}
break
case 4:
statistics[Stats.totalFour]! += 1
if won{statistics[Stats.fourWon]! += 1}
break
case 5:
statistics[Stats.totalFive]! += 1
if won{statistics[Stats.fiveWon]! += 1}
break
default:break
Expand Down
6 changes: 3 additions & 3 deletions StrategicSoccer/GameViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class GameViewController: UIViewController {
@IBAction func YesQuit(sender: AnyObject){
QuitWarningView.hidden = true
PauseView.userInteractionEnabled = true
scene.updateStats(false)
switch(pauseVC.action){
case .quit:
pauseVC.pauseQuit()
Expand All @@ -63,10 +64,9 @@ class GameViewController: UIViewController {
super.viewDidLoad()
loadingView.layer.borderWidth = 5
loadingView.layer.borderColor = UIColor.blackColor().CGColor
QuitWarningView.layer.borderWidth = 5
QuitWarningView.layer.borderColor = UIColor.blackColor().CGColor
scene.viewController = self

NumberCoins.layer.borderWidth = 5
NumberCoins.layer.borderColor = UIColor.blackColor().CGColor
skView.ignoresSiblingOrder = true

scene.scaleMode = .AspectFill
Expand Down
14 changes: 6 additions & 8 deletions StrategicSoccer/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<string key="text">DO YOU WANT TO SPEND
20 COINS TO BUY THIS FLAG?</string>
<fontDescription key="fontDescription" name="Optima-Regular" family="Optima" pointSize="18"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
Expand Down Expand Up @@ -184,7 +184,6 @@
<string key="text">YOU DO NOT HAVE ENOUGH COINS!
PLAY MORE GAMES TO EARN COINS.</string>
<fontDescription key="fontDescription" name="Optima-Regular" family="Optima" pointSize="18"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
Expand Down Expand Up @@ -413,14 +412,13 @@ PLAY MORE GAMES TO EARN COINS.</string>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="YOU EARNED 00 COINS!" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RVF-qi-W3D">
<rect key="frame" x="134" y="280" width="300" height="30"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<rect key="frame" x="124" y="30" width="320" height="35"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="300" id="I3q-Yn-UG9"/>
<constraint firstAttribute="height" constant="30" id="aRW-fG-mqK"/>
<constraint firstAttribute="width" constant="320" id="I3q-Yn-UG9"/>
<constraint firstAttribute="height" constant="35" id="aRW-fG-mqK"/>
</constraints>
<fontDescription key="fontDescription" name="Optima-Regular" family="Optima" pointSize="24"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<view alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cH7-m2-uYW" userLabel="Dimmer">
Expand Down Expand Up @@ -538,8 +536,8 @@ PLAY MORE GAMES TO EARN COINS.</string>
</view>
</subviews>
<constraints>
<constraint firstItem="RVF-qi-W3D" firstAttribute="bottom" secondItem="3se-qz-xqx" secondAttribute="bottom" constant="-10" id="5kB-Mp-ph9"/>
<constraint firstItem="79a-dm-a6g" firstAttribute="centerY" secondItem="3se-qz-xqx" secondAttribute="centerY" id="6Pu-O5-Kge"/>
<constraint firstItem="RVF-qi-W3D" firstAttribute="top" secondItem="8aa-yV-Osq" secondAttribute="bottom" constant="10" id="AeL-PX-up6"/>
<constraint firstItem="Lmz-fY-9xw" firstAttribute="leading" secondItem="3se-qz-xqx" secondAttribute="leading" id="BAx-jX-DTe"/>
<constraint firstItem="dWH-5P-CjR" firstAttribute="centerX" secondItem="3se-qz-xqx" secondAttribute="centerX" id="Fyi-WE-AeR"/>
<constraint firstItem="RVF-qi-W3D" firstAttribute="centerX" secondItem="3se-qz-xqx" secondAttribute="centerX" id="Jav-Wp-UMP"/>
Expand Down

0 comments on commit 7952029

Please sign in to comment.