Exemple #1
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);
            }
        }
 public void GenericUnregisterButtonFuction(KeyCode keyCode, Hangout.Shared.Action callback, IDictionary <KeyCode, List <Hangout.Shared.Action> > directoryToRegisterWith)
 {
     if (directoryToRegisterWith[keyCode].Contains(callback))
     {
         directoryToRegisterWith[keyCode].Remove(callback);
     }
 }
Exemple #3
0
        public void StartLevel(bool firstTimePlayed, bool needsToHire, Hangout.Shared.Action onStartLevel)
        {
            if (needsToHire || firstTimePlayed)
            {
                BuildFirstTimeHireGui(onStartLevel);
            }
            else
            {
                BuildReplayLevelGui(onStartLevel);
            }

            Label energyRequirementLabel = mFirstTimeLevelGui.MainGui.SelectSingleElement <Label>("**/EnergyRequirement");

            energyRequirementLabel.Text = String.Format(energyRequirementLabel.Text, mLevel.RequiredEnergy);

            string musicPath = mLevelXml.SelectSingleNode("Level/Music/@path").InnerText;
            ClientAssetRepository assetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            assetRepo.LoadAssetFromPath <SoundAsset>(musicPath, delegate(SoundAsset asset)
            {
                mMusicClip              = asset.AudioClip;
                mMusicGameObject        = new GameObject("music game object");
                AudioSource audioSource = (AudioSource)mMusicGameObject.AddComponent(typeof(AudioSource));
                audioSource.clip        = mMusicClip;
                audioSource.loop        = true;
                audioSource.volume      = 0.9f;
                audioSource.Play();
            });
        }
Exemple #4
0
 public void UpdateAssetsOverFramesFirstTime(int frames, Hangout.Shared.Action onFinished)
 {
     BodyTexture.ApplyChangesOverFrames(frames, delegate()
     {
         ApplyMeshChangesFirstTime(onFinished);
     });
 }
        public ServerAssetRepository(ServerStateMachine serverStateMachine, Hangout.Shared.Action itemsAndAssetsServiceDoneCallback) : base(serverStateMachine)
        {
            mItemsAndAssetsServiceDoneCallback = itemsAndAssetsServiceDoneCallback;

            mMessageActions.Add(MessageSubType.GetItemsById, GetItemsById);

            CallServices();
        }
 public IReceipt RegisterForButtonUp(KeyCode keyCode, Hangout.Shared.Action callback)
 {
     GenericRegisterButtonFunction(keyCode, callback, mKeyCodeToCallbackForButtonUp);
     return(new InputReceipt(delegate()
     {
         UnregisterForButtonUp(keyCode, callback);
     }));
 }
Exemple #7
0
        public ITask ApplyChangesOverFrames(int frames, Hangout.Shared.Action onTextureFlattenComplete)
        {
            IScheduler scheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler;

            mFlattenLayersTask = scheduler.StartCoroutine(mTexturePalette.FlattenLayersOverFramesCoroutine(frames));
            mFlattenLayersTask.AddOnExitAction(onTextureFlattenComplete);
            return(mFlattenLayersTask);
        }
Exemple #8
0
 private void SwitchRoom(Guid sessionId, RoomId newRoomId, RoomId oldRoomId, Hangout.Shared.Action userJoinedRoomCallback)
 {
     if (oldRoomId != null)
     {
         LeaveRoom(sessionId, oldRoomId);
     }
     JoinRoom(sessionId, newRoomId, userJoinedRoomCallback);
 }
 /// <summary>
 /// Sets up the Fashion Game systems that aren't tied to a specific level; FashionGameInput, ClothingMediator, FashionNpcMediator, PlayerProgression and FashionGameGui.
 /// </summary>
 /// <param name="onInitialInfoLoaded">Called after all the initial systems are ready</param>
 public InitializeGameState(Hangout.Shared.Action onInitialInfoLoaded)
 {
     if (onInitialInfoLoaded == null)
     {
         throw new ArgumentNullException("onInitialInfoLoaded");
     }
     mOnInitialInfoLoaded = onInitialInfoLoaded;
     mScheduler           = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler;
 }
Exemple #10
0
        public void WalkTo(Pair <Vector3> target, Hangout.Shared.Action onTargetReachedCallback)
        {
            if (mWalkingTask != null)
            {
                mWalkingTask.Exit();
            }

            PlayWalkCycleAnimation();

            mWalkingTask = mScheduler.StartCoroutine(WalkingTask(target, onTargetReachedCallback));
        }
        public RunwaySequenceState(Hangout.Shared.Action onExitCallback)
        {
            mOnExitCallback = onExitCallback;

            mClientAssetRepository = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();
            mClientAssetRepository.LoadAssetFromPath <XmlAsset>(PATH_TO_MODELS_XML, delegate(XmlAsset asset)
            {
                mPathToRunwayWalkAnimation = asset.XmlDocument.SelectSingleNode("RunwaySequence/RunwayWalkPath").InnerText;
                mPathToRunwayEnvironment   = asset.XmlDocument.SelectSingleNode("RunwaySequence/RunwayEnvironmentPath").InnerText;
            });
        }
Exemple #12
0
 public void Select(Hangout.Shared.Action onUnselected)
 {
     mOnUnselected  = onUnselected;
     this.Clickable = false;
     mModelMaterials.ForEach
     (
         delegate(Material m)
     {
         // TODO: Hard coded value
         m.SetFloat("_Selection", 0.5f);
     }
     );
 }
 private void GenericRegisterButtonFunction(KeyCode keyCode, Hangout.Shared.Action callback, IDictionary <KeyCode, List <Hangout.Shared.Action> > directoryToRegisterWith)
 {
     if (!directoryToRegisterWith.ContainsKey(keyCode))
     {
         List <Hangout.Shared.Action> newListOfActions = new List <Hangout.Shared.Action>();
         newListOfActions.Add(callback);
         directoryToRegisterWith.Add(keyCode, newListOfActions);
     }
     else
     {
         directoryToRegisterWith[keyCode].Add(callback);
     }
 }
Exemple #14
0
        public IReceipt AddTextChangedCallback(Hangout.Shared.Action onTextChanged)
        {
            if (onTextChanged == null)
            {
                throw new ArgumentNullException("onTextChanged");
            }

            mTextChangedCallbacks.Add(onTextChanged);
            return(new Receipt(delegate()
            {
                mTextChangedCallbacks.Remove(onTextChanged);
            }));
        }
Exemple #15
0
        private void ShowLoginFailedPopup()
        {
            List <object> args = new List <object>();

            args.Add(Translation.LOGIN_FAILED);
            args.Add(Translation.LOGIN_RETRY_TEXT);
            Hangout.Shared.Action okcb     = AttemptToReconnectToServer;
            Hangout.Shared.Action cancelcb = delegate() { };
            args.Add(okcb);
            args.Add(cancelcb);
            args.Add(Translation.RETRY); // optional. "Ok" is default
            args.Add(Translation.QUIT);  // optional. "Cancel" is default
            GameFacade.Instance.SendNotification(GameFacade.SHOW_CONFIRM, args);
        }
Exemple #16
0
        public PlayLevelState(FashionLevel level, Hangout.Shared.Action onLevelComplete)
        {
            if (level == null)
            {
                throw new ArgumentNullException("level");
            }
            mLevel = level;

            GameFacade.Instance.RegisterMediator(mLevel);

            mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler;

            mOnLevelComplete = onLevelComplete;
        }
        public GreenScreenRoomLoadingMediator(Hangout.Shared.Action finishedLoadingCallback)
        {
            mAvatarLoaded          = false;
            mClientAssetRepoLoaded = false;
            if (finishedLoadingCallback == null)
            {
                throw new ArgumentNullException("finishedLoadingCallback");
            }

            if (GameFacade.Instance.RetrieveProxy <ClientAssetRepository>().Loaded)
            {
                mClientAssetRepoLoaded = true;
                CheckLoadingFinished();
            }
            mFinishedLoadingCallback = finishedLoadingCallback;
        }
Exemple #18
0
        public FloatFromPosition(IScheduler scheduler, Camera camera, Vector3 startPosition, GuiAnchor anchor, float floatSpeed, float floatTime, Hangout.Shared.Action onCompleteCallback)
        {
            if (camera == null)
            {
                throw new ArgumentNullException("camera");
            }
            if (scheduler == null)
            {
                throw new ArgumentNullException("scheduler");
            }

            mAnchor = anchor;

            scheduler.StartCoroutine(Animate(startPosition, camera, floatSpeed, floatTime));
            mOnCompleteCallback = onCompleteCallback;
        }
Exemple #19
0
        private void ShowLostConnectionPopup()
        {
            List <object> args = new List <object>();

            args.Add(Translation.CONNECTION_LOST);
            args.Add(Translation.CONNECT_RETRY_TEXT);
            Hangout.Shared.Action okcb = delegate()
            {
                GameFacade.Instance.SendNotification(GameFacade.REQUEST_CONNECT);
            };
            args.Add(okcb);
            //Hangout.Shared.Action cancelcb = delegate() { };
            //args.Add(cancelcb);
            //args.Add(Translation.RETRY); // optional. "Ok" is default
            GameFacade.Instance.SendNotification(GameFacade.SHOW_DIALOG, args);
        }
Exemple #20
0
        private void ShowConnectFailedPopup(string address, int port)
        {
            List <object> args = new List <object>();

            args.Add(Translation.CONNECT_FAILED);
            args.Add(Translation.CONNECT_RETRY_TEXT);
            Hangout.Shared.Action okcb = delegate()
            {
                GameFacade.Instance.SendNotification(GameFacade.REQUEST_CONNECT);
            };
            args.Add(okcb);
            //Hangout.Shared.Action cancelcb = delegate() { };
            //args.Add(cancelcb);
            //args.Add(Translation.RETRY); // optional. "Ok" is default
            GameFacade.Instance.SendNotification(GameFacade.SHOW_DIALOG, args);
        }
Exemple #21
0
        private void BuildReplayLevelGui(Hangout.Shared.Action onStartLevel)
        {
            XmlNode guiPathNode = mLevelXml.SelectSingleNode("Level/ReplayLevelGui/@path");

            if (guiPathNode == null)
            {
                throw new Exception("Level (" + mLevel.Name + ") has no FirstTimeLevelGui/@path node");
            }
            IGuiManager manager = GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>();

            mFirstTimeLevelGui = new GuiController(manager, guiPathNode.InnerText);

            mStartLevelButton = mFirstTimeLevelGui.MainGui.SelectSingleElement <Button>("**/StartLevelButton");
            mStartLevelButton.AddOnPressedAction(onStartLevel);
            mStartLevelButton.AddOnPressedAction(mFirstTimeLevelGui.Dispose);
        }
Exemple #22
0
        public ClientReflector(IScheduler scheduler, Hangout.Shared.Action clientGotDisconnectedCallback)
        {
            mScheduler                     = scheduler;
            mReceiveMessageQueue           = new Queue <MemoryStream>();
            mSendMessageQueue              = new List <MemoryStream>();
            mClientGotDisconnectedCallback = clientGotDisconnectedCallback;

            try
            {
                mClientConnection = new ClientConnection(mScheduler, MessageReceived);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("ERROR cannot create a client connection: " + ex.ToString());
                throw ex;
            }
        }
Exemple #23
0
        private static void HandleFriendCase
        (
            ServerAccount serverAccount,
            long facebookId,
            Action <FacebookFriendInfo> onIsHangoutUser,
            Action <FacebookFriendInfo> onIsNotHangoutUser,
            Hangout.Shared.Action onIsUnknownFacebookId
        )
        {
            if (onIsHangoutUser == null)
            {
                throw new ArgumentNullException("onIsHangoutUser");
            }

            if (onIsNotHangoutUser == null)
            {
                throw new ArgumentNullException("onIsNotHangoutUser");
            }

            if (onIsUnknownFacebookId == null)
            {
                throw new ArgumentNullException("onIsUnknownFacebookId");
            }

            FacebookFriendInfo facebookFriendInfo;

            if (serverAccount.FacebookFriendsLookupTable.TryGetValue(facebookId, out facebookFriendInfo))
            {
                if (facebookFriendInfo.AccountId != null)
                {
                    onIsHangoutUser(facebookFriendInfo);
                }
                else
                {
                    onIsNotHangoutUser(facebookFriendInfo);
                }
            }
            else if (serverAccount.FacebookAccountId == facebookId)
            {
                onIsHangoutUser(null);
            }
            else
            {
                onIsUnknownFacebookId();
            }
        }
 private void UpdateAssetsOverFrames(int frames)
 {
     mUpdatingBodyTask = BodyTexture.ApplyChangesOverFrames(frames, ApplyMeshChanges);
     mUpdatingBodyTask.AddOnExitAction(delegate()
     {
         mFaceRenderer.enabled = true;
         mAssetsBeingUpdatedOverFrames.Clear();
         if (mFinishedUpdatingCallback != null)
         {
             mFinishedUpdatingCallback();
             mFinishedUpdatingCallback = null;
         }
     });
     mUpdatingFaceTask = mFaceTexture.ApplyChangesOverFrames(frames, delegate()
     {
     });
 }
Exemple #25
0
        private void BuyEnergy(string itemOffer)
        {
            mLevel.SendNotification(GameFacade.HIDE_POPUP);

            InventoryProxy inventoryProxy = GameFacade.Instance.RetrieveProxy <InventoryProxy>();

            inventoryProxy.PurchaseRequest(itemOffer, InventoryGlobals.CASH, delegate(Message message)
            {
                XmlDocument xmlResponse = new XmlDocument();
                xmlResponse.LoadXml((string)message.Data[0]);

                inventoryProxy.HidePurchaseModel();
                XmlNode errorCode = xmlResponse.SelectSingleNode("Response/errors/error/@code");
                if (errorCode == null)
                {
                    List <object> args = new List <object>();
                    args.Add(FashionGameTranslation.SUCCESS);
                    args.Add(FashionGameTranslation.PURCHASE_COMPLETE);
                    Hangout.Shared.Action okcb = delegate()
                    {
                        mLevel.SendNotification(GameFacade.HIDE_POPUP);
                        FashionGameGui gui = GameFacade.Instance.RetrieveMediator <FashionGameGui>();
                        gui.EnergyRefilled();
                        mLevel.Gameplay.StartWaves();
                    };
                    args.Add(okcb);
                    args.Add(FashionGameTranslation.PLAY_LEVEL);
                    GameFacade.Instance.SendNotification(GameFacade.SHOW_DIALOG, args);
                }
                else if (int.Parse(errorCode.InnerText) == 270007)                 // Attempt to go below account minimum balance.
                {
                    // Leave the minigame completely and go to the webpage for buying more cash
                    BuyCoinUtility.GoToBuyCashPage
                    (
                        FashionGameTranslation.NOT_ENOUGH_CASH_TITLE,
                        FashionGameTranslation.NOT_ENOUGH_CASH_MESSAGE,
                        delegate(string jsResult)
                    {
                        ShowOutOfEnergyGui();
                    },
                        ShowOutOfEnergyGui
                    );
                }
            });
        }
Exemple #26
0
        public ChatWindow(IInputManager inputManager, IGuiFrame chatFrame)
        {
            if (inputManager == null)
            {
                throw new ArgumentNullException("inputManager");
            }

            SetupSlashCommands();

            mChatFrame = chatFrame;

            mChatEntryBox = mChatFrame.SelectSingleElement <Textbox>("ChatEntryTextbox");

            //mChatLogFrame = (mChatFrame.SelectSingleElement<TabButton>("BottomLeftTabView/ButtonsFrame/ChatLogTab")).Frame;
            //mLocalChatPrototype = mChatLogFrame.SelectSingleElement<Textbox>("**/MyMessages");

            //mChatLogFrame.RemoveChildWidget(mLocalChatPrototype);

            Hangout.Shared.Action chatSend = delegate()
            {
                // Get chat from text entry box, and clear it
                String chatText = mChatEntryBox.Text;
                mChatEntryBox.Text = "";

                Hangout.Shared.Action slashCommand;
                if (mSlashCommands.TryGetValue(chatText, out slashCommand))
                {
                    slashCommand();
                }
                else
                {
                    // Filter out empty string
                    if (chatText != "")
                    {
                        // Dispatch chat event.  This will get picked up by SendChatCommand
                        object[] args = { chatText };
                        GameFacade.Instance.SendNotification(GameFacade.SEND_CHAT, args);
                    }
                }
            };

            mInputReceiptReturn = inputManager.RegisterForButtonDown(KeyCode.Return, chatSend);
            // If numlock is down, some laptops send this event instead
            mInputReceiptEnter = inputManager.RegisterForButtonDown(KeyCode.KeypadEnter, chatSend);
        }
Exemple #27
0
        private void GetMoreEnergyPressed()
        {
            mOutOfEnergyGui.Dispose();

            InventoryProxy inventoryProxy = GameFacade.Instance.RetrieveProxy <InventoryProxy>();

            inventoryProxy.GetStoreInventory
            (
                InventoryGlobals.ENERGY_STORE_CASH,
                ItemType.ENERGY_REFILL,
                0,
                1,
                delegate(Message buyEnergyResponseMessage)
            {
                XmlDocument xml = new XmlDocument();
                xml.LoadXml((string)buyEnergyResponseMessage.Data[0]);

                List <object> args = new List <object>();
                args.Add(FashionGameTranslation.BUY_ENERGY);
                args.Add
                (
                    String.Format
                    (
                        FashionGameTranslation.REFILL_ENERGY_MESSAGE,
                        (int)float.Parse(xml.SelectSingleNode                                 // stupid floor action
                                         (
                                             "Response/store/itemOffers/itemOffer/price/money/@amount"
                                         ).InnerText)
                    )
                );
                Hangout.Shared.Action okcb = delegate()
                {
                    BuyEnergy(xml.SelectSingleNode("Response/store/itemOffers/itemOffer/@id").InnerText);
                };
                Hangout.Shared.Action cancelcb = ShowOutOfEnergyGui;
                args.Add(okcb);
                args.Add(cancelcb);
                args.Add(FashionGameTranslation.BUY);
                args.Add(FashionGameTranslation.CANCEL);

                GameFacade.Instance.SendNotification(GameFacade.SHOW_CONFIRM, args);
            }
            );
        }
Exemple #28
0
        private void BuildFirstTimeHireGui(Hangout.Shared.Action onStartLevel)
        {
            XmlNode guiPathNode = mLevelXml.SelectSingleNode("Level/FirstTimeLevelGui/@path");

            if (guiPathNode == null)
            {
                throw new Exception("Level (" + mLevel.Name + ") has no FirstTimeLevelGui/@path node");
            }
            IGuiManager manager = GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>();

            mFirstTimeLevelGui = new GuiController(manager, guiPathNode.InnerText);

            mFirstTimeLevelGui.MainGui.AddOnCloseAction(delegate()
            {
                mFriendHired = false;
            });

            HandleHireGui(onStartLevel);
        }
Exemple #29
0
        public void Unselect()
        {
            this.Clickable = true;
            mModelMaterials.ForEach
            (
                delegate(Material m)
            {
                m.SetFloat("_Selection", 0.0f);
            }
            );

            if (mOnUnselected != null)
            {
                mOnUnselected();
            }
            mOnUnselected = null;

            GameFacade.Instance.RetrieveMediator <FashionGameInput>().Unselect(this);
        }
Exemple #30
0
        public JSDispatcher()
        {
            // If running in the editor, this class does nothing
            if (Application.isEditor)
            {
                return;
            }

            // If we don't know which calls we're allowed to make, ask the unityDispatcher
            // in Javascript Land.  Asynchronous query, we'll be called back at the
            // delegate we're defining below.  Yay for closure.
            if (mAllowedCalls.Count == 0)
            {
                mOutstandingInitCall = (JSReceipt)MakeForcedJSCall("getExposedFunctions",
                                                                   new List <object>(),
                                                                   delegate(string funcList)
                {
                    try
                    {
                        mAllowedCalls.Clear();
                        string[] funcs = funcList.Split(new Char[] { ',' });

                        foreach (string s in funcs)
                        {
                            if (s != "")
                            {
                                mAllowedCalls.Add(s, true);
                            }
                        }

                        while (mPendingCalls.Count > 0)
                        {
                            Hangout.Shared.Action func = mPendingCalls.Dequeue();
                            func();
                        }
                    }
                    catch (System.Exception ex)
                    {
                        Console.WriteLine("Exception when JSDispatcher received exposed functions: " + ex.Message);
                    }
                });
            }
        }