Ejemplo n.º 1
0
        override public void Execute(INotification notification)
        {
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("RequestConnectionCommand.Execute", LogLevel.Info);
            ConfigManagerClient configManager   = GameFacade.Instance.RetrieveProxy <ConfigManagerClient>();
            ConnectionProxy     connectionProxy = GameFacade.Instance.RetrieveProxy <ConnectionProxy>();

            connectionProxy.SetConfiguration(configManager);

            if (Application.isEditor || configManager.GetBool("override_boss_server", false))
            {
                GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("RequestConnectionCommand, using in editor settings, connection ip " + connectionProxy.IpAddress + " port " + connectionProxy.Port, LogLevel.Info);
                GameFacade.Instance.RetrieveProxy <ClientMessageProcessor>().Connect(connectionProxy.IpAddress, connectionProxy.Port);
                Console.Log("connection ip " + connectionProxy.IpAddress + " port " + connectionProxy.Port);
            }
            else
            {
                string resolvedPath = connectionProxy.WebServicesBaseUrl + "/Boss/GetStateServer";
                GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("RequestConnectionCommand boss server path = " + resolvedPath, LogLevel.Info);
                GameFacade.Instance.RetrieveProxy <ClientMessageProcessor>().CallToService(resolvedPath, delegate(XmlDocument serverDocument)
                {
                    //Expected format:
                    //<ConnectTo>
                    //   <StateServer Ip="64.106.173.25" Port="8000" Population="0" />
                    //</ConnectTo>
                    XmlElement serverNode = (XmlElement)serverDocument.SelectSingleNode("/ConnectTo/StateServer");
                    string ipAddress      = serverNode.GetAttribute("Ip");
                    int port = int.Parse(serverNode.GetAttribute("Port"));

                    GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("Connecting to state server at " + ipAddress + ":" + port, LogLevel.Info);
                    Console.WriteLine("Connecting to state server at " + ipAddress + ":" + port);

                    GameFacade.Instance.RetrieveProxy <ClientMessageProcessor>().Connect(ipAddress, port);
                });
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Pops up conformation GUI before navigating the browser to the buy cash page.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="message"></param>
        /// <param name="onOk">The string param is the Javascript call result</param>
        /// <param name="onCancel"></param>
        public static void GoToBuyCashPage(string title, string message, Action <string> onOk, Hangout.Shared.Action onCancel)
        {
            ConfigManagerClient configManager = GameFacade.Instance.RetrieveProxy <ConfigManagerClient>();

            if (configManager.GetBool("purchase_page_enabled", true))
            {
                // Popup confirm
                List <object> args = new List <object>();
                args.Add(title);
                args.Add(message);
                Hangout.Shared.Action okcb = delegate()
                {
                    HandleBuyCashOk(onOk);
                };
                args.Add(okcb);
                args.Add(onCancel);
                args.Add(Translation.NEED_CASH_BUTTON);
                GameFacade.Instance.SendNotification(GameFacade.SHOW_CONFIRM, args);
                GameFacade.Instance.SendNotification(GameFacade.GET_CASH_GUI_OPENED);
            }
            else
            {
                // Popup coming soon dialog
                List <object> args = new List <object>();
                args.Add(title);
                args.Add(Translation.NEED_CASH_TEXT_COMING_SOON);

                GameFacade.Instance.SendNotification(GameFacade.SHOW_DIALOG, args);
                GameFacade.Instance.SendNotification(GameFacade.GET_CASH_GUI_OPENED);
            }
        }
Ejemplo n.º 3
0
        // Retrieve all the config values we need to start up
        public void SetConfiguration(ConfigManagerClient configManager)
        {
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("SetConfiguration start", LogLevel.Info);
            mIpAddress = configManager.GetString("state_server_location", "127.0.0.1");
            mStageName = configManager.GetString("instance_name", "DEV");


            mWebEntryPointId = configManager.GetString("web_entry_point", FunnelGlobals.FASHION_MINIGAME);

            mAssetBaseUrl = configManager.GetString("asset_base_url", ProtocolUtility.GetAssetDataPath());
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("asssetBaseUrl " + mAssetBaseUrl, LogLevel.Info);

            mWebServicesBaseUrl = configManager.GetString("web_services_base_url", "http://services.hangoutdev.net");
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("web_services_base_url " + mWebServicesBaseUrl, LogLevel.Info);

            mCampaignId = configManager.GetString("campaign_id", "NO_VALUE_FROM_JS");
            mReferrerId = configManager.GetString("inviter_id", "NO_VALUE_FROM_JS");
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("campaign_id " + mCampaignId, LogLevel.Info);

            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("inviter_id " + mReferrerId, LogLevel.Info);
            mSelectedAvatar = new AvatarId((uint)configManager.GetInt("selected_avatar", 1));
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("mSelectedAvatar " + mSelectedAvatar, LogLevel.Info);

            mFacebookAccountId = configManager.GetLong("fb_account_id", 0);
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("mFacebookAccountId " + mFacebookAccountId, LogLevel.Info);
            mSessionKey = configManager.GetString("fb_session_key", "");
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("mSessionKey " + mSessionKey, LogLevel.Info);
            mNickName  = configManager.GetString("fake_nickname", "");
            mFirstName = configManager.GetString("fake_first_name", "");
            mLastName  = configManager.GetString("fake_last_name", "");
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("fake_nickname " + mNickName, LogLevel.Info);
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("fake_first_name " + mFirstName, LogLevel.Info);
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("fake_last_name " + mLastName, LogLevel.Info);
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("SetConfiguration finished", LogLevel.Info);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handle initial entry into the game.  Put user in a default location based on their if they are a first time user,
        /// and their entry point into the client from the web
        /// </summary>
        private void HandleInitialEntryToGame()
        {
            UserAccountProxy userAccountProxy = GameFacade.Instance.RetrieveProxy <UserAccountProxy>();
            bool             isFirstTimeUser  = false;

            Console.WriteLine("User properties " + userAccountProxy.ToString());
            if (!userAccountProxy.TryGetAccountProperty <bool>(UserAccountProperties.FirstTimeUser, ref isFirstTimeUser))
            {
                Console.WriteLine("First time user property not set, assume it our first time in");
                isFirstTimeUser = true;
            }

            ConfigManagerClient configManager = GameFacade.Instance.RetrieveProxy <ConfigManagerClient>();
            bool returnUsersStartMinigame     = configManager.GetBool("return_users_start_minigame", true);

            if (isFirstTimeUser)
            {
                ConnectionProxy connectionProxy = GameFacade.Instance.RetrieveProxy <ConnectionProxy>();
                switch (connectionProxy.WebEntryPointId)
                {
                case FunnelGlobals.PUBLIC_LOBBY:
                    RoomManagerProxy roomManager = GameFacade.Instance.RetrieveProxy <RoomManagerProxy>();
                    roomManager.JoinLastRoom();
                    break;

                case FunnelGlobals.FASHION_MINIGAME:
                    SendNotification(GameFacade.SWITCHING_TO_FASHION_MINI_GAME);
                    break;

                default:
                    throw new Exception("Unexpected entry point received: " + connectionProxy.WebEntryPointId);
                }
                // Set firstTimeUser property to false
                userAccountProxy.SetAccountProperty <bool>(UserAccountProperties.FirstTimeUser, false);
            }
            else
            {
                if (returnUsersStartMinigame)
                {
                    SendNotification(GameFacade.SWITCHING_TO_FASHION_MINI_GAME);
                }
                else
                {
                    Console.WriteLine("Not a First time user go to room");
                    // Returning user.  Go to default room
                    RoomManagerProxy roomManager = GameFacade.Instance.RetrieveProxy <RoomManagerProxy>();
                    roomManager.JoinLastRoom();
                }
            }
        }