Beispiel #1
0
 private void HandleFriendFBData(FBPlayer friend)
 {
     SaveProfilePictureToFile(friend.ProfilePicture, friend.Id);
     UpdateLeaderboards.SetValueAndForceNotify(value: true);
     if (!PersistentSingleton <FacebookAPIService> .Instance.FBPlayers.ContainsKey(friend.Id))
     {
         PersistentSingleton <FacebookAPIService> .Instance.FBPlayers.Add(friend.Id, friend);
     }
 }
Beispiel #2
0
 public static bool CanGiftPlayer(FBPlayer fbPlayer)
 {
     if (fbPlayer.Id == PlayerData.Instance.FBId.Value)
     {
         return(false);
     }
     if (fbPlayer.GiftTimeStamp + TimeSpan.FromSeconds(PersistentSingleton <GameSettings> .Instance.GiftSendCooldown).Ticks > ServerTimeService.NowTicks())
     {
         return(false);
     }
     return(true);
 }
Beispiel #3
0
 private bool AreAllPlayersGifted()
 {
     foreach (KeyValuePair <string, FBPlayer> fBPlayer in PersistentSingleton <FacebookAPIService> .Instance.FBPlayers)
     {
         FBPlayer value = fBPlayer.Value;
         if (!(value.Id == PlayerData.Instance.FBId.Value) && value.GiftTimeStamp + TimeSpan.FromSeconds(PersistentSingleton <GameSettings> .Instance.GiftSendCooldown).Ticks <= ServerTimeService.NowTicks())
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #4
0
    IEnumerator delayCreate()
    {
        yield return(new WaitForSeconds(0.1f));

        Game.instance.fbGame.setupFBGame(0, (uint)MapID);
        Game.instance.fbGame.createCoach(string.Format("{0}/Resources/Config/Behaviac", Application.dataPath));

        var count = 1;

        if (useAIPlayer)
        {
            count += 7;
        }
        if (useAIGK)
        {
            count += 2;
        }
        for (int i = 1; i <= count; i++)
        {
            ulong uid      = (ulong)i;
            uint  playerID = (uint)i;
            uint  baseID   = 0;
            if (i == 1)
            {
                baseID = BasePlayerID;
            }
            else if (i < 9)
            {
                baseID = (uint)((i + 2) % 3 + 1);
            }
            else
            {
                baseID = 6;
            }
            int      teamID    = (i + (int)team) % 2 + 1;
            string   name      = i.ToString();
            bool     mainActor = i == 1;
            bool     ai        = i != 1;
            FBPlayer player    = Game.instance.fbGame.createPlayer(uid, playerID, baseID, teamID, name, mainActor, ai);
        }

        /*
         * FBPlayer player = Game.instance.fbGame.createPlayer(1, 1, BasePlayerID, 1, "", true, false);
         *
         * FBPlayer aiPlayer = Game.instance.fbGame.createPlayer(2, 2, 1, 2, "", false, false);
         */

        Game.instance.fbGame.fbGameCreateCompleted();
    }
Beispiel #5
0
    public void LoadFriendAPI(string id, FriendDataDelegate callback = null)
    {
        string query = "/" + id + "?fields=id,first_name,picture.width(120).height(120)";

        FB.API(query, HttpMethod.GET, delegate(IGraphResult result)
        {
            if (result.Error == null)
            {
                object value = string.Empty;
                result.ResultDictionary.TryGetValue("first_name", out value);
                FBPlayer f = new FBPlayer(id, (string)value, playing: false, invited: false, 0, 0L);
                string url = GraphUtil.DeserializePictureURL(result.ResultDictionary);
                LoadFriendPicture(url, f, callback);
            }
        });
    }
Beispiel #6
0
 private void LoadFriendPicture(string url, FBPlayer f, FriendDataDelegate callback = null)
 {
     GraphUtil.LoadImgFromURL(url, delegate(Texture pictureTexture)
     {
         if (pictureTexture == null)
         {
             LoadFriendPicture(url, f, callback);
         }
         else
         {
             f.ProfilePicture = (pictureTexture as Texture2D);
             if (callback != null)
             {
                 callback(f);
             }
         }
     });
 }
Beispiel #7
0
 private void LoadMyPicture(string url, FBPlayer f, List <object> friends, MyDataDelegate callback = null)
 {
     GraphUtil.LoadImgFromURL(url, delegate(Texture pictureTexture)
     {
         if (pictureTexture == null)
         {
             LoadMyPicture(url, f, friends, callback);
         }
         else
         {
             f.ProfilePicture = (pictureTexture as Texture2D);
             if (callback != null)
             {
                 callback(f, friends);
             }
         }
     });
 }
Beispiel #8
0
    //创建成员
    public FBPlayer createPlayer(ulong uid,
                                 uint playerID,
                                 uint baseID,
                                 int teamID,
                                 string name,
                                 bool mainActor,
                                 bool ai)
    {
        if (mainActor)
        {
            mainActorID   = playerID;
            mainActorTeam = (FBTeam)teamID;
            onMainActorCreated(playerID, mainActorTeam);
        }
        //jlx 2017.07.05 log:测试用
        if (MainCharacter.instance != null)
        {
            if (!MainCharacter.instance.useAIPlayer)
            {
                if (ai && baseID != 6)
                {
                    return(null);
                }
            }
            if (!MainCharacter.instance.useAIGK)
            {
                if (baseID == 6)
                {
                    return(null);
                }
            }
        }
        FBPlayer fbPlayer = new FBPlayer(playerID, baseID, (FBTeam)teamID, name, mainActor, ai, fbWorld, aiWorld.workspace);

        if (ai)
        {
            fbPlayer.aiTakeOver(true);
        }
        fbPlayer.onCreated();
        gamePlayers.Add(playerID, fbPlayer);
        uids.Add(playerID, uid);
        return(fbPlayer);
    }
Beispiel #9
0
    private IEnumerator PopulateGiftRoutine()
    {
        base.transform.DestroyChildrenImmediate();
        Dictionary <string, object>             pars = new Dictionary <string, object>();
        List <KeyValuePair <string, FBPlayer> > list = PersistentSingleton <FacebookAPIService> .Instance.FBPlayers.ToList();

        foreach (KeyValuePair <string, FBPlayer> keyValue in list)
        {
            FBPlayer fbPlayer = keyValue.Value;
            if (FacebookRunner.CanGiftPlayer(fbPlayer))
            {
                pars.Clear();
                GameObject uiGift = UnityEngine.Object.Instantiate(m_giftPrefab, Vector3.zero, Quaternion.identity);
                uiGift.GetComponent <UISendFacebookGift>().Init(keyValue.Value.Id);
                uiGift.transform.SetParent(base.transform, worldPositionStays: false);
                yield return(null);
            }
        }
    }
Beispiel #10
0
 private void LoadMyDataAPI(string url, MyDataDelegate callback = null)
 {
     FB.API(meQueryString, HttpMethod.GET, delegate(IGraphResult result)
     {
         if (result.Error == null)
         {
             Dictionary <string, string> dictionary = GraphUtil.DeserializeJSONProfile(result.RawResult);
             List <object> friends = GraphUtil.DeserializeJSONFriends(result.RawResult);
             string id             = "me";
             if (dictionary.ContainsKey("id"))
             {
                 id = dictionary["id"];
             }
             string name = dictionary["first_name"];
             int value   = PlayerData.Instance.LifetimeChunk.Value;
             FBPlayer f  = new FBPlayer(id, name, playing: false, invited: false, value, 0L);
             string url2 = GraphUtil.DeserializePictureURL(result.ResultDictionary);
             LoadMyPicture(url2, f, friends, callback);
         }
     });
 }
Beispiel #11
0
    private void HandleMyFBData(MyFacebookData fbData)
    {
        FBPlayer      player  = fbData.Player;
        List <object> friends = fbData.Friends;

        if (!PersistentSingleton <FacebookAPIService> .Instance.FBPlayers.ContainsKey(player.Id))
        {
            PersistentSingleton <FacebookAPIService> .Instance.FBPlayers[fbData.Player.Id] = player;
        }
        SaveProfilePictureToFile(player.ProfilePicture, player.Id);
        UpdateLeaderboards.SetValueAndForceNotify(value: true);
        PlayerID.Value   = player.Id;
        PlayerName.Value = player.Name;
        List <string> list = new List <string>();

        for (int i = 0; i < friends.Count; i++)
        {
            Dictionary <string, object> dictionary = (Dictionary <string, object>)friends[i];
            if (dictionary.ContainsKey("id"))
            {
                string text = (string)dictionary["id"];
                if (PersistentSingleton <FacebookAPIService> .Instance.FBPlayers.ContainsKey(text))
                {
                    FBPlayer fBPlayer = PersistentSingleton <FacebookAPIService> .Instance.FBPlayers[(string)dictionary["id"]];
                    fBPlayer.Playing = true;
                }
                else
                {
                    list.Add(text);
                }
            }
        }
        if (list.Count > 0)
        {
            FBPlayersFromIDs(list);
        }
    }
Beispiel #12
0
 private void HandleFBFriendAppRequest(FBPlayer f)
 {
     f.Invited = true;
     BindingManager.Instance.FacebookInviteSuccessParent.ShowInfo();
     HandleFriendFBData(f);
 }
        internal FBPlayers GetTransactions(string url)
        {
            Console.WriteLine(url);

            var players = new FBPlayers();

            //* Get the URL specified

            HtmlWeb      htmlWeb  = new HtmlWeb();
            HtmlDocument document = htmlWeb.Load(url);

            //* Get <table> tags

            HtmlNodeCollection tableTags = document.DocumentNode.SelectNodes("//table");

            if (tableTags != null)
            {
                int index_td = 0, index_tr = 0;

                foreach (HtmlNode tableTag in tableTags)
                {
                    if (tableTag.Attributes["class"] == null)
                    {
                        continue;
                    }

                    if (tableTag.Attributes["class"].Value == "Tst-table Table")
                    {
                        #region Found the table; find rows to work

                        //PlayerTrend playerTrend;

                        index_tr = 0;

                        foreach (HtmlNode trNode in tableTag.ChildNodes["tbody"].ChildNodes)
                        {
                            index_td = 0;

                            //playerTrend = new PlayerTrend();

                            var player = new FBPlayer();
                            var trend  = new TransactionTrend();

                            foreach (HtmlNode tdNode in trNode.ChildNodes)
                            {
                                if (index_td == 0)
                                {
                                    #region Parse into name, team and positions

                                    foreach (HtmlNode descendant in tdNode.Descendants())
                                    {
                                        if (descendant.Name == "div")
                                        {
                                            if (descendant.Attributes["class"] != null)
                                            {
                                                if (descendant.Attributes["class"].Value.Contains("ysf-player-name"))
                                                {
                                                    string[] allData = descendant.InnerText.Split('-');

                                                    //playerTrend.PlayerName = allData[0].Trim();
                                                    player.Name = allData[0].Trim();

                                                    var aux = player.Name.Split(' ');

                                                    //playerTrend.Team = aux[aux.Length - 1].Trim();

                                                    player.Team = aux[aux.Length - 1].Trim();

                                                    player.Name = player.Name.Remove(
                                                        player.Name.Length - 1 - player.Team.Length);

                                                    //* Position

                                                    string positions = allData[1].Trim();

                                                    foreach (string pos in positions.Split(','))
                                                    {
                                                        player.Positions.Add(pos.Trim());
                                                    }

                                                    break;
                                                }
                                            }
                                        }
                                    }

                                    #endregion
                                }
                                else if (index_td == 1)
                                {
                                    trend.Drops = Convert.ToInt32(tdNode.InnerText.Trim());
                                }
                                else if (index_td == 2)
                                {
                                    trend.Adds = Convert.ToInt32(tdNode.InnerText.Trim());
                                }

                                index_td += 1;
                            }

                            trend.DateOfSample = DateTime.Now;

                            player.TransactionTrends.Add(trend);

                            players.Add(player);

                            //playerTrends.Add(playerTrend);

                            index_tr += 1;
                        }

                        #endregion
                    }
                }
            }

            return(players);
        }
Beispiel #14
0
 public MyFacebookData(FBPlayer player, List <object> friends)
 {
     Player  = player;
     Friends = friends;
 }