Guest User

Untitled

a guest
Apr 19th, 2014
88
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Prime31;
  5.  
  6. namespace HutongGames.PlayMaker.Actions
  7. {
  8.     [ActionCategory("Social/Facebook")]
  9.     [Tooltip("Posts a score for a user")]
  10.     public class PostScore : FsmStateAction
  11.     {
  12.         [RequiredField]
  13.         [Tooltip("Score to submit")]
  14.         public FsmInt score;
  15.  
  16.         [Tooltip("What event to call on success")]
  17.         public FsmEvent onSuccess;
  18.         [Tooltip("What event to call on error")]
  19.         public FsmEvent onError;
  20.         FsmString socialError;
  21.  
  22.         public override void Reset()
  23.         {
  24.            
  25.         }
  26.  
  27.         public override void OnEnter()
  28.         {
  29.             #if UNITY_ANDROID || UNITY_IOS
  30.            
  31.             var hasWritePermissions = FsmVariables.GlobalVariables.GetFsmBool("hasWritePermissions").Value;
  32.             if(!hasWritePermissions) {
  33.                 socialError = "You must have write permissions to call this function";
  34.                 Debug.Log (socialError.Value);
  35.                 Fsm.Event(onError);
  36.                 Finish();
  37.                 return;
  38.             }
  39.  
  40.             Facebook.instance.postScore(score.Value, PostScoreFinish);
  41.  
  42.             #else      
  43.             Finish ();
  44.             #endif
  45.         }
  46.  
  47.         public void PostScoreFinish(bool success) {
  48.  
  49.             Debug.Log ("Post score finished with success: " + success);
  50.             Finish ();
  51.         }
  52.     }
  53. }
RAW Paste Data