Exemplo n.º 1
0
        public void StartLevel()
        {
            FashionGameCommands.TryUseEnergy(mLevel.RequiredEnergy, delegate(Message useEnergyResultMessage)
            {
                Energy.UseRequestResult useEnergyResult = (Energy.UseRequestResult)Enum.Parse(typeof(Energy.UseRequestResult), (string)useEnergyResultMessage.Data[0]);

                switch (useEnergyResult)
                {
                case Energy.UseRequestResult.Success:
                    StartWaves();
                    break;

                case Energy.UseRequestResult.NotEnoughEnergy:
                    EventLogger.Log(LogGlobals.CATEGORY_FASHION_MINIGAME, LogGlobals.OUT_OF_ENERGY, "Level", mLevel.Name);
                    mLevel.Gui.ShowOutOfEnergyGui();
                    return;

                default:
                    throw new NotImplementedException("Unhandled Energy.UseRequestResult");
                }

                GameFacade.Instance.RetrieveMediator <FashionGameGui>().SetEnergy
                (
                    float.Parse((string)useEnergyResultMessage.Data[1]),
                    float.Parse((string)useEnergyResultMessage.Data[2]),
                    DateTime.Parse((string)useEnergyResultMessage.Data[3])
                );
            });
        }
Exemplo n.º 2
0
 public override void EnterState()
 {
     FashionGameCommands.GetLoadingInfo(delegate(Message loadingInfoMessage)
     {
         mScheduler.StartCoroutine(ProcessLoadingInfo(loadingInfoMessage));
     });
 }
Exemplo n.º 3
0
        private void GetFriendsToHire(Jobs job, Action <IDictionary <long, FacebookFriendInfo> > result)
        {
            FashionGameCommands.GetFriendsToHire(job, delegate(Message msg)
            {
                if (msg.Data.Count == 0)
                {
                    throw new Exception("Malformed FriendsToHire Message, Data[0] must be a Dictionary<long,FacebookFriendInfo>");
                }

                IDictionary <long, FacebookFriendInfo> possibleHires = null;

                // There is a compatibility bug serializing an empty dict between .NET and mono,
                // so if the dict is empty we just pass down false.
                if ((msg.Data[0] is bool) && ((bool)msg.Data[0] == false))
                {
                    possibleHires = new Dictionary <long, FacebookFriendInfo>();
                }
                else
                {
                    possibleHires = (IDictionary <long, FacebookFriendInfo>)msg.Data[0];
                }

                result(possibleHires);
            });
        }
Exemplo n.º 4
0
        public void BuildNpcsForLevel(FashionLevel level)
        {
            mAvatarsDownloading = true;

            FashionGameCommands.GetAllHiredAvatars(delegate(Message message)
            {
                GetHiredNpcs(message, level, delegate() { mAvatarsDownloading = false; });
            });
        }
Exemplo n.º 5
0
            public void ExecuteClosure()
            {
                if (!mThisRef.mFriendHired)
                {
                    mThisRef.mFriendHired = true;

                    // Cleanup the hire GUI to up framerate through the rest of this function
                    IGuiFrame hireParent = (IGuiFrame)mThisRef.mHireFrame.Parent;
                    ((IGuiFrame)hireParent.Parent).RemoveChildWidget(hireParent);
                    hireParent          = null;
                    mThisRef.mHireFrame = null;

                    mThisRef.mHireFeedbackLabel.Showing = true;
                    mThisRef.mHireFeedbackLabel.Text    = "Hiring " + mFriendInfo.FirstName + " " + mFriendInfo.LastName + ". Please wait...";

                    FashionNpcMediator npcFactory = GameFacade.Instance.RetrieveMediator <FashionNpcMediator>();
                    FashionGameCommands.HireFriend(mFriendInfo.FbAccountId, mJob, delegate(Message message)
                    {
                        npcFactory.HiredFriend(message, mThisRef.mLevel);
                    });

                    string feedType = "";
                    switch (mJob)
                    {
                    case Jobs.Model:
                        feedType = HIRED_FRIEND_MODEL_FEED_COPY;
                        break;

                    case Jobs.Hair:
                        feedType = HIRED_FRIEND_HAIR_FEED_COPY;
                        break;

                    case Jobs.Makeup:
                        feedType = HIRED_FRIEND_MAKEUP_FEED_COPY;
                        break;

                    case Jobs.Seamstress:
                        feedType = HIRED_FRIEND_SEAMSTRESS_FEED_COPY;
                        break;
                    }

                    GameFacade.Instance.RetrieveMediator <FacebookFeedMediator>().PostFeed
                    (
                        mFriendInfo.FbAccountId,
                        FashionMinigame.FACEBOOK_FEED_COPY_PATH,
                        feedType,
                        delegate(){},
                        mFriendInfo.FirstName + " " + mFriendInfo.LastName
                    );

                    // Add mixpanel funnel metrics
                    FunnelGlobals.Instance.LogFunnel(FunnelGlobals.FUNNEL_FRIEND_HIRE, FunnelGlobals.CLICKED_HIRE, "{\"level\":\"" + mThisRef.mLevel.Name + "\"}");
                }
            }
Exemplo n.º 6
0
        public void SaveExperienceToServer(uint xpEarnedOnThisLevel, bool leveledUp)
        {
            FashionGameCommands.SetLevelComplete(mXP, xpEarnedOnThisLevel + mXpForCoins, leveledUp, delegate(Message message)
            {
                //string coinsEarned = (string)message.Data[0];
                string totalCoins = (string)message.Data[1];
                SendNotification(GameFacade.RECV_USER_BALANCE, new string[] { totalCoins, "" });
            });

            mXpForCoins = 0;

            if (leveledUp)
            {
                FashionGameGui gui = GameFacade.Instance.RetrieveMediator <FashionGameGui>();
                gui.LeveledUp();
            }
        }
Exemplo n.º 7
0
        public void GetNextLevel(Action <FashionLevel> fashionLevelResult)
        {
            // Make the first level that this player qualifies for
            int levelNumber = 0;

            FashionGameCommands.GetPlayerData(LAST_LEVEL_DATA_KEY, delegate(Message message)
            {
                //Console.WriteLine(Time.realtimeSinceStartup.ToString("f2") + "> Received Player Data in PlayerProgression");
                XmlDocument xml = new XmlDocument();
                xml.LoadXml(message.Data[0].ToString());
                int lastLevel         = 0;
                XmlNode levelDataNode = xml.SelectSingleNode("//DataKey[@KeyName='" + LAST_LEVEL_DATA_KEY + "']");
                if (levelDataNode != null)
                {
                    int.TryParse(levelDataNode.InnerText, out lastLevel);
                }

                KeyValuePair <uint, LevelInfo> nextLevel = default(KeyValuePair <uint, LevelInfo>);
                foreach (KeyValuePair <uint, LevelInfo> experienceLevel in mExperienceToLevel)
                {
                    levelNumber++;
                    nextLevel = experienceLevel;

                    if (experienceLevel.Key > mXP)
                    {
                        break;
                    }
                }

                bool firstTimePlayed = levelNumber > lastLevel;

                //Load Level Xml
                XmlDocument levelXml = XmlUtility.LoadXmlDocument(nextLevel.Value.LevelDataPath);
                XmlNode feedCopyNode = levelXml.SelectSingleNode("Level/FeedOnFirstTimePlayed/@feedCopyName");

                if (firstTimePlayed && feedCopyNode != null)
                {
                    GameFacade.Instance.RetrieveMediator <FacebookFeedMediator>().PostFeed
                    (
                        null,
                        FashionMinigame.FACEBOOK_FEED_COPY_PATH,
                        feedCopyNode.InnerText,
                        delegate(){},
                        ""
                    );
                }
                else
                {
                    mLevelStartXp = mXP;

                    EarnedXP(0);                     // Cause the XP bar to update
                    GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler.StartCoroutine
                    (
                        BuildLevel
                        (
                            levelXml,
                            nextLevel.Value,
                            firstTimePlayed,
                            fashionLevelResult
                        )
                    );

                    FashionGameCommands.SetServerData(LAST_LEVEL_DATA_KEY, levelNumber.ToString());

                    //Console.WriteLine(Time.realtimeSinceStartup.ToString("f2") + "> Received Next Level Completed");
                }
            });
        }