Example #1
0
    /// <summary>
    /// runs a script file
    /// </summary>
    /// <param name="name">file name</param>
    /// <returns>true on success, false on failure</returns>
    public FBScript runScriptFile(string name)
    {
        // try to run from loaded asset
        FBScript script = null;

        for (int i = 0; i < scriptFiles.Count; i++)
        {
            if (scriptFiles[i].name == name)
            {
                script = runScript(scriptFiles[i].text);
                script.gameObject.name = name;
                return(script);
            }
        }

        // if not found, load from resources folder and run
        TextAsset textAsset = Resources.Load <TextAsset>(name);

        if (textAsset)
        {
            script = runScript(textAsset.text);
            script.gameObject.name = name;
            Resources.UnloadAsset(textAsset);
        }

        return(script);
    }
Example #2
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            FB.Init(SetInit, OnHideUnity);

            Mixpanel.Token = mixpanelToken;
            Mixpanel.SuperProperties.Add("platform", Application.platform.ToString());
            Mixpanel.SuperProperties.Add("quality", QualitySettings.names[QualitySettings.GetQualityLevel()]);
            Mixpanel.SuperProperties.Add("fullscreen", Screen.fullScreen);
            Mixpanel.SuperProperties.Add("resolution", Screen.width + "x" + Screen.height);

            DontDestroyOnLoad(gameObject);
        }
        else if (Instance != this)
        {
            if (MPScript.Data.SkipLogin)
            {
                CameraGuide.GetComponent <MenuCamController>().setMount(Mount);
                MPScript.Data.SkipLogin = false;
            }
            Destroy(gameObject);
        }
    }
Example #3
0
    /// <summary>
    /// runs a script
    /// </summary>
    /// <param name="text">script content</param>
    /// <returns>FBScript object</returns>
    public FBScript runScript(string text)
    {
        GameObject obj    = null;
        FBScript   script = null;

        // try to reuse existing script object
        for (int i = 0; i < transform.childCount; i++)
        {
            GameObject obj2 = transform.GetChild(i).gameObject;
            if (!obj2.activeInHierarchy)
            {
                script = obj2.GetComponent <FBScript>();
                if (script)
                {
                    obj = obj2;
                    break;
                }
            }
        }

        if (!obj)
        {
            // create new
            obj = GameObject.Instantiate(scriptPrefab.gameObject);
            obj.transform.SetParent(transform);
            script = obj.GetComponent <FBScript>();
        }

        script.manager = this;
        script.run(text);
        return(script);
    }
Example #4
0
    void Start()
    {
        instance = this;
        profPic  = GameObject.Find("fb profile pic").GetComponent <Image> ();
        print(profPic.GetInstanceID());

        FB.Init(SetInit, OnHideUnity);
    }
 public static FBScript getInstance()
 {
     if (Instance == null)
     {
         Instance = (FBScript)FindObjectOfType(typeof(FBScript));
     }
     return(Instance);
 }
 void Awake()
 {
     facebook          = FindObjectOfType <FBScript>();
     achievementCanvas = GameObject.Find("AchievementMenu");
     pp           = FindObjectOfType <PlayerProperties>();
     panel        = GameObject.Find("Panel");
     currentScore = panel.transform.Find("PlayerScore").GetComponent <Text>();
     highScore    = panel.transform.Find("HighScore").GetComponent <Text>();
     panel.SetActive(false);                   //hide the end of game screen
     // achievementCanvas.SetActive(false);
     loseListener = new UnityAction(LoseGame); //Create a new UnityAction to handle losing the game and ending the game
     endListener  = new UnityAction(EndGame);
 }
Example #7
0
 void ShareCallBack(IShareResult result)
 {
     //check if is an error or success
     if (result.Cancelled)
     {
         Debug.Log("Share canceled");
     }
     else if (!String.IsNullOrEmpty(result.Error))
     {
         Debug.Log("Errors on share!");
     }
     else if (!String.IsNullOrEmpty(result.RawResult))
     {
         isShared = true;
         Text mission = FBScript.getInstance().DialogMission.GetComponent <Text> ();
         mission.text = "Share time: 1/1";
         Debug.Log("Success on Share!" + isShared.ToString());
     }
 }
Example #8
0
    IEnumerator GetProfileFromDB(string guideName)
    {
        string url        = "http://xavieriscool.web44.net/getProfile.php?" + "name=" + WWW.EscapeURL(guideName.Trim());
        WWW    getProfile = new WWW(url);

        yield return(getProfile);

        if (getProfile.error != null)
        {
            Debug.LogError("Error: " + getProfile.error);
        }
        else
        {
            string[] guides = getProfile.text.Substring(0, getProfile.text.LastIndexOf('%') - 1).Split('=');
            profileEmail.text = "Email: " + guides [0].Trim();
            profilePhone.text = "Phone #: " + guides [1].Trim();
            profileBlurb.text = guides [2].Trim();
            id = guides [3].Trim();
            string name = guideName;
            if (name.Contains("Xavier"))
            {
                FBScript.GetFBProfilPic(s[0]);
            }
            else if (name.Contains("Jimmy"))
            {
                FBScript.GetFBProfilPic(s[1]);
            }
            else if (name.Contains("Lizzy"))
            {
                FBScript.GetFBProfilPic(s[2]);
            }
            else
            {
                FBScript.GetFBProfilPic(s[3]);
            }
        }
    }
Example #9
0
 /// <summary>
 /// called when a script is finished
 /// </summary>
 /// <param name="script">script object</param>
 public void onScriptFinished(FBScript script)
 {
 }
Example #10
0
 // Use this for initialization
 void Awake()
 {
     FB.Init(SetInit, OnHideUnity);
     current = this;
 }
Example #11
0
    // http://answers.unity3d.com/questions/959943/deserialize-facebook-friends-result.html
    void DisplayFriends(IResult result)
    {
        friendList.Clear();

        current = this;

        var dict = Json.Deserialize(result.RawResult) as Dictionary<string, object>;
        var theList = new List<object>();
        theList = (List<object>)(dict["data"]);

        int friendCount = theList.Count;
        
        for (int i = 0; i < friendCount; i++)
        {
            string friendFBID = GetDataValueForKey((Dictionary<string, object>)(theList[i]), "id");
            string first_name = GetDataValueForKey((Dictionary<string, object>)(theList[i]), "first_name");
            string last_name = GetDataValueForKey((Dictionary<string, object>)(theList[i]), "last_name");
            
            FacebookFriend fwend = new FacebookFriend();
            fwend.name = first_name + " " + last_name;
            fwend.id = friendFBID;

            current.friendList.Add(fwend);
        }

    }
Example #12
0
 // Use this for initialization
 void Start()
 {
     OpenLoginPage();
     fb = GetComponent <FBScript> ();
 }