Skip to content

Commit

Permalink
Merge pull request #36 from surenpoghosian/Hints-LS-71
Browse files Browse the repository at this point in the history
Hints-LS-71 added hint on how to play before the first game
  • Loading branch information
surenpoghosian authored Jan 16, 2024
2 parents 40c303e + ed628e6 commit 6172730
Show file tree
Hide file tree
Showing 9 changed files with 443 additions and 29 deletions.
4 changes: 4 additions & 0 deletions Greedy Kings.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
33025D8A2B5710D70010EAC0 /* HintViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33025D892B5710D70010EAC0 /* HintViewController.swift */; };
33298FE82B57044A00DE9AB7 /* ResultModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33298FE72B57044A00DE9AB7 /* ResultModels.swift */; };
333931802B4AF645002D4F91 /* .gitignore in Resources */ = {isa = PBXBuildFile; fileRef = 3339317F2B4AF645002D4F91 /* .gitignore */; };
335334A12B27BA3300BB3E8E /* strengthIndicator.json in Resources */ = {isa = PBXBuildFile; fileRef = 335334A02B27BA3300BB3E8E /* strengthIndicator.json */; };
Expand Down Expand Up @@ -186,6 +187,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
33025D892B5710D70010EAC0 /* HintViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HintViewController.swift; sourceTree = "<group>"; };
33298FE72B57044A00DE9AB7 /* ResultModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultModels.swift; sourceTree = "<group>"; };
3339317F2B4AF645002D4F91 /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = "<group>"; };
3353349D2B27B19A00BB3E8E /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -589,6 +591,7 @@
E8BBD4222ABFC7600056E1E8 /* ResultViewController.swift */,
E8BBD4322ABFC8A70056E1E8 /* PlayerDataViewController.swift */,
336A95382AE180D900F43B13 /* PauseViewController.swift */,
33025D892B5710D70010EAC0 /* HintViewController.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -903,6 +906,7 @@
buildActionMask = 2147483647;
files = (
E8BBD4332ABFC8A70056E1E8 /* PlayerDataViewController.swift in Sources */,
33025D8A2B5710D70010EAC0 /* HintViewController.swift in Sources */,
E8BBD40F2ABFA5460056E1E8 /* MainMenuViewController.swift in Sources */,
33F00D642ABCB4CB00A5D5B2 /* RootViewController.swift in Sources */,
33E8D3E02AD0456300C3892C /* PhysicsModels.swift in Sources */,
Expand Down
Binary file not shown.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Greedy Kings/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//

import UIKit
import FirebaseCore
import FirebaseAnalytics
import FirebaseCrashlytics
//import FirebaseCore
//import FirebaseAnalytics
//import FirebaseCrashlytics

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand Down
17 changes: 16 additions & 1 deletion Greedy Kings/Application/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,26 @@
</objects>
<point key="canvasLocation" x="4906" y="-895"/>
</scene>
<!--Hint View Controller-->
<scene sceneID="3co-LV-fzi">
<objects>
<viewController storyboardIdentifier="HintView" useStoryboardIdentifierAsRestorationIdentifier="YES" id="dFz-Dh-XU4" customClass="HintViewController" customModule="Greedy_Kings" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="2a1-ZC-fEQ">
<rect key="frame" x="0.0" y="0.0" width="852" height="393"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="LM8-vc-YUy"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="5Xf-LX-3bT" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="4120" y="-86"/>
</scene>
</scenes>
<resources>
<image name="logo" width="2248" height="361"/>
<systemColor name="secondarySystemBackgroundColor">
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.94901960780000005" green="0.94901960780000005" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Gamescene_Hint.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,33 @@ final class GameSceneViewController: UIViewController {
initializeGameScene()

buildLevel(scene: levelType!, battleModel: battleModel)

setCharactersIcons(characters: pickedCharacters)

startTimer()
if isFirstGame() {
showHintModal()
} else {
startTimer()
startAnimation(for: .player1)
}

addSwitchToBackgroundModeObserver()

}


func isFirstGame() -> Bool{

if let _ = storageManager.get(key: "firstGame", storageType: .userdefaults) as? String {
return false

} else {
storageManager.set(key: "firstGame", value: "data", storageType: .userdefaults)
return true

}
}

func initializeGameScene(){
gameScene = nil
gameScene = UIView()
Expand Down Expand Up @@ -292,7 +310,6 @@ final class GameSceneViewController: UIViewController {

pauseButton.addTarget(self, action: #selector(onPause), for: .touchUpInside)

startAnimation(for: .player1)

let leftAmmo = gameScene.subviews[6]
let rightAmmo = gameScene.subviews[7]
Expand Down Expand Up @@ -536,6 +553,20 @@ final class GameSceneViewController: UIViewController {

}

func showHintModal(){
let storyboard = UIStoryboard(name: "Main", bundle: nil)
if let vc = storyboard.instantiateViewController(withIdentifier: "HintView") as? HintViewController {

vc.onHintClose = onHintClose
navigationController?.present(vc, animated: true)
}

}

func onHintClose(){
startTimer()
startAnimation(for: .player1)
}

func onHit(ammo: UIView, side: Side){
if let temporaryCurrentPlayer {
Expand Down
118 changes: 118 additions & 0 deletions Greedy Kings/Game/UI/Game Scene/Views/HintViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
//
// HintView.swift
// Greedy Kings
//
// Created by Suren Poghosyan on 16.01.24.
//

import UIKit


final class HintViewController: UIViewController {
private var modal: UIView!
private var modalStackView: UIStackView!

private var hintImage: UIImage!
private var hintImageView: UIImageView!
private var okButton: UIButton!
private var screenSize = UIScreen.main.bounds
private var modalWidth: Double!
private var modalHeight: Double!

var onHintClose: (() -> Void)?

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.clear

modalWidth = screenSize.width * 0.7
modalHeight = screenSize.height * 0.85
setupHintImageView()
setupOkButton()
setupModal()
setupModalStackView()
}



private func setupOkButton(){
okButton = UIButton()
okButton.setTitle("START", for: .normal)

okButton.setBackgroundImage(UIImage(named: "button"), for: .normal)
okButton.setBackgroundImage(UIImage(named: "buttonTouched"), for: .highlighted)

okButton.setTitleColor(UIColor(named: "backgroundColor"), for: .normal)
okButton.titleLabel?.font = UIFont.systemFont(ofSize: 28, weight: .bold)

okButton.translatesAutoresizingMaskIntoConstraints = false

okButton.addAction(UIAction(handler: {[weak self]_ in
if let onHintClose = self?.onHintClose {
self?.dismiss(animated: true)
onHintClose()
}
}), for: .touchUpInside)

}


private func setupHintImageView(){
hintImage = UIImage(named: "Gamescene_Hint")
hintImageView = UIImageView()
hintImageView.image = hintImage
hintImageView.contentMode = .scaleAspectFit

hintImageView.translatesAutoresizingMaskIntoConstraints = false

NSLayoutConstraint.activate([
hintImageView.widthAnchor.constraint(equalToConstant: CGFloat(modalWidth * 0.9)),
hintImageView.heightAnchor.constraint(equalToConstant: CGFloat(modalHeight * 0.75))
])
}

private func setupModal(){
modal = UIView()
modal.layer.cornerRadius = 30
modal.backgroundColor = UIColor(named: "backgroundColor")

view.addSubview(modal)

modal.translatesAutoresizingMaskIntoConstraints = false

NSLayoutConstraint.activate([
modal.centerXAnchor.constraint(equalTo: view.centerXAnchor),
modal.centerYAnchor.constraint(equalTo: view.centerYAnchor),
modal.widthAnchor.constraint(equalToConstant: modalWidth),
modal.heightAnchor.constraint(equalToConstant: modalHeight)
])
}

private func setupModalStackView(){


modalStackView = UIStackView(arrangedSubviews: [hintImageView, okButton])

modalStackView.translatesAutoresizingMaskIntoConstraints = false

modalStackView.axis = .vertical
modalStackView.spacing = 10

modal.addSubview(modalStackView)

modalStackView.distribution = .fillProportionally

NSLayoutConstraint.activate([
modalStackView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
modalStackView.leftAnchor.constraint(equalTo: modal.leftAnchor, constant: 35),
modalStackView.rightAnchor.constraint(equalTo: modal.rightAnchor, constant: -35),
modalStackView.topAnchor.constraint(equalTo: modal.topAnchor, constant: 20),
modalStackView.bottomAnchor.constraint(equalTo: modal.bottomAnchor, constant: -20),

])
}



}

0 comments on commit 6172730

Please sign in to comment.