Easy Game Center \ EGC Easy Game Center helps you manage Game Center on iOS. Report and track high scores , achievements and Multiplayer . Easy Game Center facilitate Game Center management. iOS Games using Easy Game Center Hipster Moustache : http://bit.ly/1zGJMNG By Stephan Yannick Dyslexia : http://apple.co/1L3D6xS By Nicolas Morelli Kicuby : https://goo.gl/BzNXBW By Kicody Nixie : http://bit.ly/nixieGame By Domsware DodgerBall : http://apple.co/1Ruz7Qj By Ray Hughes Project Features Swift and Objective-C Manage Multiplayers Manage Leaderboards Manage Achievements Manage in single line of code most functions of Game Center Achievements are saved in cache and automatically refreshed Delegate function when player is connected, not connected, multiplayer etc... Most of the functions have completion Simply use the methods with EGC.method or EasyGameCenter.method Contributions & Support Any contribution is more than welcome ! You can contribute through pull requests and issues on GitHub. :D Send me your applications link, if you use Easy Game center, I will add on the cover page Contact for support Issues or @YannickSteph Installation CocoaPods pod EasyGameCenter , :git => https://github.com/DaRkD0G/Easy-Game-Center-Swift.git Manual Add the following classe EasyGameCenter.swift to your Xcode project (make sure to select Copy Items in the dialog) Add GameKit and SystemConfiguration frameworks to your Xcode project. Documentation Initialize and Example You can add protocol EGCDelegate for access to delegate functions Connexion EGCAuthentified EGCInCache Multiplayer EGCMatchStarted EGCMatchRecept EGCMatchEnded EGCMatchCancel EGCDelegate its optional, its not mandatory class MainViewController : UIViewController, EGCDelegate { /** This method is called after the view controller has loaded */ override func viewDidLoad () { super . viewDidLoad () // Init EGC and set delegate UIViewController EGC. sharedInstance ( self ) // Will not show automatic Game Center login page // EGC.showLoginPage = false // If you want see message debug // EGC.debugMode = true } /** Notifies the view controller that its view was added to a view hierarchy. */ override func viewDidAppear ( animated : Bool ) { super . viewDidAppear (animated) // Set new view controller delegate, thats when you change UIViewController // If you have several UIViewController just add this in your UIViewControllers for set new Delegate EGC. delegate = self } /// ############################################################ /// /// Mark: - Delegate function of EasyGameCenter /// /// ############################################################ /// /** Listener Player is authentified Optional function */ func EGCAuthentified ( authentified : Bool ) { print ( " Player Authentified = \( authentified) " ) } /** Listener when Achievements is in cache Optional function */ func EGCInCache () { // Call when GkAchievement & GKAchievementDescription in cache } /// ############################################################ /// /// Mark: - Delegate function of EasyGameCenter for MultiPlaye /// /// ############################################################ /// /** Listener When Match Started Optional function */ func EGCMatchStarted () { print ( " MatchStarted " ) } /** Listener When Match Recept Data When player send data to all player Optional function */ func EGCMatchRecept ( match : GKMatch, didReceiveData data : NSData, fromPlayer playerID : String ) { // See Packet Example in project let strucData = Packet. unarchive (data) print ( " Recept From player = \( playerID) " ) print ( " Recept Packet.name = \( strucData. name ) " ) print ( " Recept Packet.index = \( strucData. index ) " ) } /** Listener When Match End Optional function */ func EGCMatchEnded () { print ( " MatchEnded " ) } /** Listener When Match Cancel Optional function */ func EGCMatchCancel () { print ( " Match cancel " ) } Show Methods Show Achievements Show Game Center Achievements with optional completion // Without completion EGC. showGameCenterAchievements () // With completion EGC. showGameCenterAchievements { (isShow) -> Void in if isShow { print ( " Game Center Achievements is shown " ) } } Show Leaderboard Show Game Center Leaderboard with optional completion // Without completion EGC. showGameCenterLeaderboard ( leaderboardIdentifier : " IdentifierLeaderboard " ) // With completion EGC. showGameCenterLeaderboard ( leaderboardIdentifier : " IdentifierLeaderboard " ) { (isShow) -> Void in if isShow { print ( " Game Center Leaderboards is shown " ) } } Show Challenges Show Game Center Challenges with optional completion // Without completion EGC. showGameCenterChallenges () // With completion EGC. showGameCenterChallenges { (isShow) -> Void in if isShow { print ( " Game Center Challenges Is shown " ) } } Show authentification page Game Center Show Game Center authentification page with optional completion // Without completion EGC. showGameCenterAuthentication () // With completion EGC. showGameCenterAuthentication { (result) -> Void in if result { print ( " Game Center Authentication is open " ) } } Show custom banner Show custom banner Game Center with optional completion // Without completion EGC. showCustomBanner ( title : " Title " , description : " My Description... " ) // With completion EGC. showCustomBanner ( title : " Title " , description : " My Description... " ) { print ( " Custom Banner is finish to Show " ) } Achievements Methods Progress Achievements Add progress to an Achievement with show banner Option : Report achievement EGC. reportAchievement ( progress : 42.00 , achievementIdentifier : " Identifier " ) Option : Without show banner EGC. reportAchievement ( progress : 42.00 , achievementIdentifier : " Identifier " , showBannnerIfCompleted : false ) Option : Add progress to existing (addition to the old) EGC. reportAchievement ( progress : 42.00 , achievementIdentifier : " Identifier " , addToExisting : true ) Option : Without show banner & add progress to existing (addition to the old) EGC. reportAchievement ( progress : 42.00 , achievementIdentifier : " Identifier " , showBannnerIfCompleted : false , addToExisting : true ) If Achievement completed Is completed Achievement if EGC. isAchievementCompleted ( achievementIdentifier : " Identifier " ) { print ( " \n [Easy Game Center]Yes \n " ) } else { print ( " \n [Easy Game Center] No \n " ) } Get All Achievements completed for banner not show Get All Achievements completed and banner not show with completion if let achievements : [GKAchievement] = EGC. getAchievementCompleteAndBannerNotShowing () { for oneAchievement in achievements { print ( " \n [Easy Game Center] Achievement where banner not show \( oneAchievement. identifier ) \n " ) } } else { print ( " \n [Easy Game Center] No Achievements with banner not showing \n " ) } Show all Achievements completed for banner not show Show All Achievements completed and banner not show with completion Option : Without completion EGC. showAllBannerAchievementCompleteForBannerNotShowing () Option : With completion EGC. showAllBannerAchievementCompleteForBannerNotShowing { (achievementShow) -> Void in if let achievementIsOK = achievementShow { print ( " \n [Easy Game Center] Achievement show is \( achievementIsOK. identifier ) \n " ) } else { print ( " \n [Easy Game Center] No Achievements with banner not showing \n " ) } } Get all Achievements GKAchievementDescription Get all achievements descriptions (GKAchievementDescription) with completion EGC. getGKAllAchievementDescription { (arrayGKAD) -> Void in if let arrayAchievementDescription = arrayGKAD { for achievement in arrayAchievementDescription { print ( " \n [Easy Game Center] ID : \( achievement. identifier ) \n " ) print ( " \n [Easy Game Center] Title : \( achievement. title ) \n " ) print ( " \n [Easy Game Center] Achieved Description : \( achievement. achievedDescription ) \n " ) print ( " \n [Easy Game Center] Unachieved Description : \( achievement. unachievedDescription ) \n " ) } } } Get Achievements GKAchievement Get One Achievement (GKAchievement) if let achievement = EGC. getAchievementForIndentifier ( identifierAchievement : " AchievementIdentifier " ) { print ( " \n [Easy Game Center] ID : \( achievement. identifier ) \n " ) } Get Achievements GKAchievement GKAchievementDescription (Tuple) Get Tuple ( GKAchievement , GKAchievementDescription) for identifier Achievement EGC. getTupleGKAchievementAndDescription ( achievementIdentifier : " AchievementIdentifier " ) { (tupleGKAchievementAndDescription) -> Void in if let tupleInfoAchievement = tupleGKAchievementAndDescription { // Extract tuple let gkAchievementDescription = tupleInfoAchievement. gkAchievementDescription let gkAchievement = tupleInfoAchievement. gkAchievement // The title of the achievement. print ( " \n [Easy Game Center] Title : \( gkAchievementDescription. title ) \n " ) // The description for an unachieved achievement. print ( " \n [Easy Game Center] Achieved Description : \( gkAchievementDescription. achievedDescription ) \n " ) } } Achievement progress Get Progress to an achievement let progressAchievement = EGC. getProgressForAchievement ( achievementIdentifier : " AchievementIdentifier " ) Reset all Achievements Reset all Achievement Option : Without completion EGC. resetAllAchievements () EGC. resetAllAchievements { (achievementReset) -> Void in print ( " \n [Easy Game Center] ID : \( achievementReset. identifier ) \n " ) } Leaderboards Methods Report Report Score Leaderboard EGC. reportScoreLeaderboard ( leaderboardIdentifier : " LeaderboardIdentifier " , score : 100 ) Get GKLeaderboard Get GKLeaderboard with completion EGC. getGKLeaderboard { (resultArrayGKLeaderboard) -> Void in if let resultArrayGKLeaderboardIsOK = resultArrayGKLeaderboard { for oneGKLeaderboard in resultArrayGKLeaderboardIsOK { print ( " \n [Easy Game Center] ID : \( oneGKLeaderboard. identifier ) \n " ) print ( " \n [Easy Game Center] Title : \( oneGKLeaderboard. title ) \n " ) print ( " \n [Easy Game Center] Loading ? : \( oneGKLeaderboard. loading ) \n " ) } } } Get GKScore Get GKScore Leaderboard with completion EGC. getGKScoreLeaderboard ( leaderboardIdentifier : " LeaderboardIdentifier " ) { (resultGKScore) -> Void in if let resultGKScoreIsOK = resultGKScore as GKScore ? { print ( " \n [Easy Game Center] Leaderboard Identifier : \( resultGKScoreIsOK. leaderboardIdentifier ) \n " ) print ( " \n [Easy Game Center] Date : \( resultGKScoreIsOK. date ) \n " ) print ( " \n [Easy Game Center] Rank : \( resultGKScoreIsOK. rank ) \n " ) print ( " \n [Easy Game Center] Hight Score : \( resultGKScoreIsOK. value ) \n " ) } } Get Hight Score (Tuple) Get Hight Score Leaderboard with completion, (Tuple of name,score,rank) EGC. getHighScore ( leaderboardIdentifier : " LeaderboardIdentifier " ) { (tupleHighScore) -> Void in //(playerName:String, score:Int,rank:Int)? if let tupleIsOk = tupleHighScore { print ( " \n [Easy Game Center] Player name : \( tupleIsOk. playerName ) \n " ) print ( " \n [Easy Game Center] Score : \( tupleIsOk. score ) \n " ) print ( " \n [Easy Game Center] Rank : \( tupleIsOk. rank ) \n " ) } } MultiPlayer MultiPlayer Methods Find player By number of player Find Player By min and max player EGC. findMatchWithMinPlayers ( 2 , maxPlayers : 4 ) Send Data to all Player Send Data to all Player (NSData) // Example Struc var myStruct = Packet ( name : " My Data to Send ! " , index : 1234567890 , numberOfPackets : 1 ) //Send Data EGC. sendDataToAllPlayers (myStruct. archive (), modeSend : . Reliable ) : 4 ) Get Player in match Get Player in match return Set if let players = EGC. getPlayerInMatch () { for player in players{ print (player. alias ) } } Get match Get current match if let match = EGC. getMatch () { print (match) } Disconnect Match / Stop Disconnect Match or Stop for send data to all player in match EGC. disconnectMatch () Other methods Game Center Player identified to Game Center Is player identified to gameCenter if EGC. isPlayerIdentified { /* Player identified */ } Get Local Player Get local Player (GKLocalPlayer) let localPlayer = EGC. getLocalPlayer () Get information on Local Player EGC. getlocalPlayerInformation { (playerInformationTuple) -> () in //playerInformationTuple:(playerID:String,alias:String,profilPhoto:UIImage?) if let typleInformationPlayer = playerInformationTuple { self . PlayerID . text = " Player ID : \( typleInformationPlayer. playerID ) " self . Name . text = " Name : \( typleInformationPlayer. alias ) " self . PlayerAuthentified . text = " Player Authentified : True " if let haveProfilPhoto = typleInformationPlayer. profilPhoto { self . PlayerProfil . image = haveProfilPhoto } } } NetWork Is Connected to NetWork if EGC. isConnectedToNetwork { /* You have network */ } Hidden automatique login of Game Center Hidden automatique page for login to Game Center, if player not login EGC. showLoginPage = false Debug Mode If you doesnt want see message of Easy Game Center // If you doesnt want see message Easy Game Center, delete this ligne // EGC.debugMode = true Legacy support For support of iOS 7+ & iOS 8+ @RedWolfStudioFR @YannickSteph Yannick Stephan works hard to have as high feature parity with Easy Game Center as possible. License The MIT License (MIT) Copyright (c) 2015 Red Wolf Studio, Yannick Stephan Red Wolf Studio Yannick Stephan
Easy Game Center helps to manage Game Center in iOS. http://yannickstephan.com
3997
来源:
Licence:
联系:
分类:
平台:
环境:
大小:
更新:
标签:
免费下载
×
温馨提示
请用电脑打开本网页,即可以免费获取你想要的了。














