playMaker

Author Topic: Prime31 Gamecenter  (Read 5748 times)

MUX

  • Playmaker Newbie
  • *
  • Posts: 43
    • @stefstivala
Prime31 Gamecenter
« on: November 02, 2012, 08:02:30 AM »
how would i use an action to get string data (event) :( from an external script
Code: [Select]
public static event Action<string> profilePhotoLoaded;I tried doing it a few ways , send message doesn't get it & custom actions ( gives me errors )

this is the custom action i tried

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("GameCenter Custom")]
[Tooltip("Get Game Center ProfilePhoto")]

public class GameCenterProfilePhoto : FsmStateAction {
//
//[RequiredField]
[Tooltip("Profile Photo String")]
public FsmString ProfilePhoto;

public override void Reset()
{
ProfilePhoto = null;
}

public override void OnEnter(){
CheckPhoto();
Finish();
}

public void CheckPhoto(){
ProfilePhoto.Value  = GameCenterManager.profilePhotoLoaded;
Debug.Log("Player ProfilePhoto:" + ProfilePhoto.Value);
if (ProfilePhoto == null) return;
}
}
}

hope someone can help & thanks in advance.
« Last Edit: November 26, 2012, 08:26:02 AM by MUX »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: get string from 'Action<string>' from script.
« Reply #1 on: November 06, 2012, 06:06:05 AM »
Hi,

 ok, what plugins are you using? prime31 gameCenter? I don't have this one unfortunatly.

 as far as implement c# action callback. you simply need to register a function within your playmaker custom action to that c# action.

something like

GameCenterManager.profilePhotoLoaded += ProfilePhotoLoadedCallBack;

where ProfilePhotoLoadedCallBack is a function, within that function, you can then set ProfilePhoto.Value to true or false depending on the result of the profilePhotoLoaded action call back.

you should also look up the web for c# examples on event action handling, or simply the example from gameCenter itself, Surely it's implementing somehow this action in a sample right?

bye,

 Jean

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: get string from 'Action<string>' from script.
« Reply #2 on: November 13, 2012, 05:46:33 PM »
Your problem is this line:

Code: [Select]
GameCenterManager.profilePhotoLoaded;
GameCenterManager WON'T call anything. This class is for handling events. Which you really need is this, in GameCenterBinding.cs

Code: [Select]
GameCenterBinding.loadProfilePhotoForLocalPlayer
You might also need to subscribe a function that manages GameCenterManager.profilePhotoLoaded like this:

Code: [Select]
GameCenterManager.profilePhotoLoaded += myDelegateFunction;
...
void myDelegateFunction(string str){
//your code. Here you catch your string value.
}
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

MUX

  • Playmaker Newbie
  • *
  • Posts: 43
    • @stefstivala
Re: get string from 'Action<string>' from script.
« Reply #3 on: November 13, 2012, 06:34:34 PM »
thanks DARK_ETERNAL. i actually tried both those ways with no luck , but i might have been doing something rong then. i struggled with this for a whole week, so in the meantime i actually solved this by customising the GameCenterManager a bit , adding some public variables that i can easily reach from playmaker instead , as long as knew that i was in the correct state (until hopefully some official custom actions are made  :))

EDIT - Scratch THat i'm still stuck in the longrun  >:(
« Last Edit: November 23, 2012, 10:56:57 PM by MUX »

MUX

  • Playmaker Newbie
  • *
  • Posts: 43
    • @stefstivala
Re: get string from 'Action<string>' from script.
« Reply #4 on: November 23, 2012, 10:49:32 PM »
Your problem is this line:

Code: [Select]
GameCenterManager.profilePhotoLoaded;
GameCenterManager WON'T call anything. This class is for handling events. Which you really need is this, in GameCenterBinding.cs

Code: [Select]
GameCenterBinding.loadProfilePhotoForLocalPlayer
You might also need to subscribe a function that manages GameCenterManager.profilePhotoLoaded like this:

Code: [Select]
GameCenterManager.profilePhotoLoaded += myDelegateFunction;
...
void myDelegateFunction(string str){
//your code. Here you catch your string value.
}

DARK_ETERNAL did you use the prime31 gameceneter yourself? im still struggling with integration overall unfortunately. maybe you can give me a tip on the best way to say up the following for what i need?

i do not think what im trying to do is that hard, i just want to easily access values from gamecenter as strings & such so i can use them in my nGUI setup. here's my example..


im tying building a custom UI bit that emulates the look of gamecenter from my launch/startgame screen
i managed to pull out all the values i need one way or another but it's a massive hack. [including my original question on how to get the profile pic string loaded in which i solved]

and jeanfabre , could i maybe purchase the plugin for the forum [not to share obviously] , so it gets official actions like the other hippo plugin? or maybe some one-on-one help? hate to be so stuck & i would love to keep the feature
« Last Edit: November 23, 2012, 10:59:49 PM by MUX »

MUX

  • Playmaker Newbie
  • *
  • Posts: 43
    • @stefstivala
Re: Prime31 Gamecenter [SOLVED]
« Reply #5 on: November 26, 2012, 08:33:30 AM »
think i started to get how this works.. thanks for leading me in the right direction.

heres an example in case anyone needs it

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("GameCenter Custom")]
[Tooltip("Get GameCenter Leaderboards")]



public class GameCenterLoadLeaderboardTitles : FsmStateAction {
//

[Tooltip("Load Leaderboard Result Bool")]
public FsmBool LoadLeaderboardSuccess;

[Tooltip("Event sent if the user is Leaderboards Loading Success")]
public FsmEvent LeaderboardsLoadingSuccess;

[Tooltip("Event sent if the user is Leaderboards Loading Fails")]
public FsmEvent LeaderboardsLoadingFail;

public override void Reset()
{
LoadLeaderboardSuccess = null;
}

public override void OnEnter(){
LoadLeaderboard();
Finish();
}

public void LoadLeaderboard(){

GameCenterBinding.loadLeaderboardTitles();

Debug.Log("LoadLeaderboard Success:" + LoadLeaderboardSuccess.Value);
GameCenterManager.categoriesLoaded += delegate {
Debug.Log("delegate categoriesLoaded");
LoadLeaderboardSuccess.Value = true;
Fsm.Event(LeaderboardsLoadingSuccess);
};

GameCenterManager.loadCategoryTitlesFailed += delegate {
Debug.Log("delegate loadCategoryTitlesFailed");
LoadLeaderboardSuccess.Value = false;
Fsm.Event(LeaderboardsLoadingFail);
};

Finish();
}


}
}
« Last Edit: November 26, 2012, 08:36:15 AM by MUX »

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: Prime31 Gamecenter
« Reply #6 on: November 26, 2012, 09:56:54 AM »
Yeah, I used Prime31 plugin. You are actually using an anonymous delegate. Slightly different from my initial suggestion, although it might work. The only thing I oversee with it is that you should define yet again the same delegate, if you were to use it in another function. However, with GameCenter API, you shouldn't need to call the same delegate in another part of your code.

Hope I've been of help all along.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Prime31 Gamecenter
« Reply #7 on: June 25, 2013, 08:22:46 PM »
Did anyone ever create the actions for Prime[31] Gamecenter plugin in the end? Really need the score/leaderboard action and creating them is way over my head :(

Edit - have contacted MUX via Twitter and currently working something out :)
« Last Edit: June 25, 2013, 08:42:22 PM by LampRabbit »