-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
390 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// AnnotationHelpers.swift | ||
// MC2Maps | ||
// | ||
// Created by Evelyn Hong on 8/21/24. | ||
// | ||
|
||
import Foundation | ||
import CoreLocation | ||
|
||
// MARK: - Annotation Management | ||
|
||
extension MapsView { | ||
// MARK: 어노테이션을 추가하는 함수 | ||
func addAnnotation() { | ||
guard annotations.count < maxAnnotations, let baseLocation = baseLocation else { | ||
return // 최대 어노테이션 수에 도달하면 추가하지 않음 | ||
} | ||
|
||
specialAnnotationCounter += 1 | ||
let isSpecial = (specialAnnotationCounter % 4 == 0) | ||
// 4로 나눈 나머지가 0일 때 isSpecial이 true, 나머지는 false | ||
|
||
let index = annotations.count | ||
let row = index / gridSize | ||
let column = index % gridSize | ||
|
||
// 그리드 셀 내에서 무작위 오프셋 계산 | ||
let offsetLat = (Double(row) + Double.random(in: 0...1)) * 0.0001 | ||
let offsetLon = (Double(column) + Double.random(in: 0...1)) * 0.0001 | ||
|
||
// 변동 위치 계산 | ||
let newCoordinate = calculateOffsetCoordinate(base: baseLocation, offsetLat: offsetLat, offsetLon: offsetLon) | ||
let newAnnotation = AnnotationItem(coordinate: newCoordinate, isSpecial: isSpecial) | ||
|
||
// 새로운 어노테이션 추가 | ||
annotations.append(newAnnotation) | ||
} | ||
|
||
// MARK: 계산된 새로운 좌표 반환 | ||
func calculateOffsetCoordinate(base: CLLocationCoordinate2D, offsetLat: Double, offsetLon: Double) -> CLLocationCoordinate2D { | ||
let newLatitude = base.latitude + offsetLat | ||
let newLongitude = base.longitude + offsetLon | ||
return CLLocationCoordinate2D(latitude: newLatitude, longitude: newLongitude) | ||
} | ||
|
||
// MARK: 클로버 수를 업데이트하는 함수 | ||
func updateCloverCounts() { | ||
cloverCounts.threeLeaf = annotations.filter { !$0.isSpecial }.count | ||
cloverCounts.fourLeaf = annotations.filter { $0.isSpecial }.count | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// AnnotationItem.swift | ||
// MC2Maps | ||
// | ||
// Created by Evelyn Hong on 8/21/24. | ||
// | ||
|
||
// AnnotationItem.swift | ||
// MC2Maps | ||
// | ||
// Created by donghwan on 8/21/24. | ||
// | ||
|
||
import Foundation | ||
import CoreLocation | ||
|
||
//MARK: 커스텀 어노테이션 구조체 생성 | ||
struct AnnotationItem: Identifiable, Equatable { | ||
let id = UUID() | ||
var coordinate: CLLocationCoordinate2D | ||
var isSpecial: Bool | ||
|
||
static func == (lhs: AnnotationItem, rhs: AnnotationItem) -> Bool { | ||
return lhs.id == rhs.id // 여기서는 ID가 같으면 같은 어노테이션으로 간주 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// AnnotationModels.swift | ||
// MC2Maps | ||
// | ||
// Created by Evelyn Hong on 8/21/24. | ||
// | ||
|
||
import Foundation | ||
import CoreLocation | ||
|
||
// MARK: - AnnotationItem | ||
|
||
struct AnnotationItem: Identifiable, Equatable { | ||
let id = UUID() | ||
var coordinate: CLLocationCoordinate2D | ||
var isSpecial: Bool | ||
|
||
static func == (lhs: AnnotationItem, rhs: AnnotationItem) -> Bool { | ||
return lhs.id == rhs.id // ID가 같으면 같은 어노테이션으로 간주 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// CloverManager.swift | ||
// MC2Maps | ||
// | ||
// Created by Evelyn Hong on 8/21/24. | ||
// | ||
|
||
import Foundation | ||
import CoreLocation | ||
|
||
class CloverManager: ObservableObject { | ||
@Published var isCloverConditionMet: Bool = false | ||
|
||
func checkCloverGenerationCondition(location: CLLocation) { | ||
// 조건 확인 후, 조건이 충족되면 isCloverConditionMet를 true로 설정 | ||
self.isCloverConditionMet = true // 예시로 조건을 충족시킴 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// LocationManager.swift | ||
// MC2Maps | ||
// | ||
// Created by Evelyn Hong on 8/21/24. | ||
// | ||
|
||
import Foundation | ||
import CoreLocation | ||
import Combine | ||
|
||
class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate { | ||
var locationManager = CLLocationManager() | ||
@Published var location: CLLocation? | ||
|
||
override init() { | ||
super.init() | ||
self.locationManager.delegate = self | ||
self.locationManager.requestWhenInUseAuthorization() | ||
self.locationManager.startUpdatingLocation() | ||
self.locationManager.allowsBackgroundLocationUpdates = true // 백그라운드에서 동작 | ||
} | ||
|
||
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { | ||
guard let location = locations.last else { return } | ||
self.location = location | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+16 KB
(130%)
...codeproj/project.xcworkspace/xcuserdata/evelyn.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Logo_.png", | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.