diff --git a/star-dash/star-dash.xcodeproj/project.pbxproj b/star-dash/star-dash.xcodeproj/project.pbxproj index 74c5b857..d4e1f390 100644 --- a/star-dash/star-dash.xcodeproj/project.pbxproj +++ b/star-dash/star-dash.xcodeproj/project.pbxproj @@ -85,6 +85,8 @@ E64361152BA4C2CD003850FD /* GameBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = E643610F2BA4C2CC003850FD /* GameBridge.swift */; }; E69EE9322BAC6CBB00033AB5 /* GameInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = E69EE9312BAC6CBB00033AB5 /* GameInfo.swift */; }; E69EE9342BAC6CC300033AB5 /* OverlayInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = E69EE9332BAC6CC300033AB5 /* OverlayInfo.swift */; }; + E69FDDE02BAD3DAD0089D5F3 /* PointsComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = E69FDDDF2BAD3DAD0089D5F3 /* PointsComponent.swift */; }; + E69FDDE22BAD3DC40089D5F3 /* EntityConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = E69FDDE12BAD3DC40089D5F3 /* EntityConstants.swift */; }; E6A011172BA5F4AD006904D9 /* EntitySyncInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A011162BA5F4AD006904D9 /* EntitySyncInterface.swift */; }; E6A745162BA057040080C1BE /* MTKRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A745112BA057040080C1BE /* MTKRenderer.swift */; }; E6A745172BA057040080C1BE /* ControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A745122BA057040080C1BE /* ControlView.swift */; }; @@ -212,6 +214,8 @@ E643610F2BA4C2CC003850FD /* GameBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameBridge.swift; sourceTree = ""; }; E69EE9312BAC6CBB00033AB5 /* GameInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameInfo.swift; sourceTree = ""; }; E69EE9332BAC6CC300033AB5 /* OverlayInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OverlayInfo.swift; sourceTree = ""; }; + E69FDDDF2BAD3DAD0089D5F3 /* PointsComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PointsComponent.swift; sourceTree = ""; }; + E69FDDE12BAD3DC40089D5F3 /* EntityConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntityConstants.swift; sourceTree = ""; }; E6A011162BA5F4AD006904D9 /* EntitySyncInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntitySyncInterface.swift; sourceTree = ""; }; E6A745112BA057040080C1BE /* MTKRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MTKRenderer.swift; sourceTree = ""; }; E6A745122BA057040080C1BE /* ControlView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlView.swift; sourceTree = ""; }; @@ -464,6 +468,7 @@ 4E630F282B9F7EC20008F887 /* Components */ = { isa = PBXGroup; children = ( + E69FDDDF2BAD3DAD0089D5F3 /* PointsComponent.swift */, E6B34A462BAA03AF0009A60B /* PlayerComponent.swift */, 4E630F292B9F7EF60008F887 /* PositionComponent.swift */, 14970F4F2BA814D500CC1E8A /* ScoreComponent.swift */, @@ -487,6 +492,7 @@ 4E86605D2BA095CC0035530D /* Constants */ = { isa = PBXGroup; children = ( + E69FDDE12BAD3DC40089D5F3 /* EntityConstants.swift */, 4E8660652BA097D40035530D /* PhysicsConstants.swift */, 14970F552BA8177B00CC1E8A /* GameConstants.swift */, ); @@ -765,6 +771,7 @@ 4604BBD92BA81C940078B84C /* InventorySystem.swift in Sources */, 14E247952BA2CB480071FFC0 /* EventManager.swift in Sources */, 4E630EF82B9F7E070008F887 /* SceneDelegate.swift in Sources */, + E69FDDE02BAD3DAD0089D5F3 /* PointsComponent.swift in Sources */, 14970F542BA8163300CC1E8A /* ScoreSystem.swift in Sources */, E64361112BA4C2CD003850FD /* SyncModule.swift in Sources */, E6A7451B2BA0C1890080C1BE /* PlayerView.swift in Sources */, @@ -786,6 +793,7 @@ E6A7451D2BA0CAD90080C1BE /* JoystickView.swift in Sources */, E6B550A12BA15E9C00DC7396 /* OverlayView.swift in Sources */, 46D418262BA5D6500091A38B /* Wall+Collidable.swift in Sources */, + E69FDDE22BAD3DC40089D5F3 /* EntityConstants.swift in Sources */, 4E630F342B9F8FC00008F887 /* Player.swift in Sources */, 4E630F372B9F91DE0008F887 /* PlayerSprite.swift in Sources */, 14970F502BA814D500CC1E8A /* ScoreComponent.swift in Sources */, diff --git a/star-dash/star-dash/Constants/EntityConstants.swift b/star-dash/star-dash/Constants/EntityConstants.swift index 54e43455..46f593fd 100644 --- a/star-dash/star-dash/Constants/EntityConstants.swift +++ b/star-dash/star-dash/Constants/EntityConstants.swift @@ -1,7 +1,9 @@ +import CoreGraphics + struct EntityConstants { struct CoinCollectible { - let points = 10 - let sprite = "Coin" - let size = CGSize(width: 50, height: 50) + static let points = 10 + static let sprite = "Coin" + static let size = CGSize(width: 50, height: 50) } } diff --git a/star-dash/star-dash/Events/PlayerEvents/PickupCollectibleEvent.swift b/star-dash/star-dash/Events/PlayerEvents/PickupCollectibleEvent.swift index 28ed89f4..b4a94aad 100644 --- a/star-dash/star-dash/Events/PlayerEvents/PickupCollectibleEvent.swift +++ b/star-dash/star-dash/Events/PlayerEvents/PickupCollectibleEvent.swift @@ -21,7 +21,7 @@ class PickupCollectibleEvent: Event { func execute(on target: EventModifiable) { guard let scoreSystem = target.system(ofType: ScoreSystem.self), - let pointsComponent = target.component(ofType: PointsComponent.self, ofEntity: entityId) else { + let pointsComponent = target.component(ofType: PointsComponent.self, ofEntity: collectibleEntityId) else { return } scoreSystem.applyScoreChange(to: entityId, scoreChange: pointsComponent.points)