예제 #1
0
        public override void EnterState()
        {
            EventLogger.Log(LogGlobals.CATEGORY_FASHION_MINIGAME, LogGlobals.EVENT_MINIGAME_ENTERED);

            mStartGame        = DateTime.UtcNow;
            mGameStateMachine = new FashionGameStateMachine();
            mFashionMinigame  = new FashionMinigame(null, new DistributedObjectId(0), new List <object>(), mGameStateMachine);
            GameFacade.Instance.RegisterMediator(mGameStateMachine);
        }
예제 #2
0
        public void CompleteLevel(uint startXp, uint entourageBonusXp, PlayerProgression progression, int coinEarned, int entourageBonusCoins, Hangout.Shared.Action onNextLevelPressed)
        {
            IGuiManager manager = GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>();
            string      levelCompleteGuiPath = mLevelXml.SelectSingleNode("Level/LevelCompleteGui/@path").InnerText;

            mLevelCompleteGui = new GuiController(manager, levelCompleteGuiPath);

            // If we leveled up, show the complete frame, otherwise show the replay frame
            GuiFrame levelCompleteFrame = mLevelCompleteGui.MainGui.SelectSingleElement <GuiFrame>("**/LevelCompleteFrame");
            GuiFrame levelReplayFrame   = mLevelCompleteGui.MainGui.SelectSingleElement <GuiFrame>("**/LevelReplayFrame");
            GuiFrame activeFrame        = null;

            // How much total we have now
            uint currentXP = progression.XP;

            // How much we just earned
            uint earnedXP = (currentXP - startXp);

            // How much total we need to get to the next level
            uint nextLevelXP = progression.GetNextLevelXP();

            // How much we need to finish this level
            uint pointsToNextLevel = nextLevelXP - currentXP;

            progression.SaveExperienceToServer(earnedXP, progression.IsLeveledUp());

            if (progression.IsLeveledUp())
            {
                // DID level up
                if (mLevelUpSfx != null)
                {
                    GameObject mainCamera = GameFacade.Instance.RetrieveMediator <CameraManagerMediator>().MainCamera;
                    AudioSource.PlayClipAtPoint(mLevelUpSfx, mainCamera.transform.position, 0.5f);
                }

                levelCompleteFrame.Showing = true;
                levelReplayFrame.Showing   = false;
                activeFrame = levelCompleteFrame;

                // Facebook Share button
                Button shareButton = activeFrame.SelectSingleElement <Button>("**/ShareButton");
                shareButton.AddOnPressedAction(delegate()
                {
                    // Now that they've shared, disable the button
                    shareButton.Disable();
                    ShareLevelUp(mLevel.Name);
                });
            }
            else
            {
                // Did NOT level up
                if (mLevelCompleteSfx != null)
                {
                    GameObject mainCamera = GameFacade.Instance.RetrieveMediator <CameraManagerMediator>().MainCamera;
                    AudioSource.PlayClipAtPoint(mLevelCompleteSfx, mainCamera.transform.position, 0.5f);
                }
                levelCompleteFrame.Showing = false;
                levelReplayFrame.Showing   = true;
                activeFrame = levelReplayFrame;
                Label levelDetailsLabel = activeFrame.SelectSingleElement <Label>("**/LevelDetails");
                levelDetailsLabel.Text = String.Format(levelDetailsLabel.Text, pointsToNextLevel.ToString());
            }

            // Update coins
            Label coinLabel = activeFrame.SelectSingleElement <Label>("**/CoinsEarnedLabel");

            coinLabel.Text = String.Format(coinLabel.Text, coinEarned.ToString());

            // Entourage bonus
            Label bonusCoinsLabel = activeFrame.SelectSingleElement <Label>("**/EntourageBonusCoinLabel");

            bonusCoinsLabel.Text = String.Format(bonusCoinsLabel.Text, entourageBonusCoins.ToString());
            Label bonusXpLabel = activeFrame.SelectSingleElement <Label>("**/EntourageBonusXpLabel");

            bonusXpLabel.Text = String.Format(bonusXpLabel.Text, entourageBonusXp.ToString());

            Button inviteFriendsButton = mLevelCompleteGui.MainGui.SelectSingleElement <Button>("**/InviteFriendsButton");

            inviteFriendsButton.Text = Translation.ENTOURAGE_INVITE_FRIENDS_BUTTON_TEXT;
            inviteFriendsButton.AddOnPressedAction(delegate()
            {
                InviteFriendsToEntourage();
            });

            // Next level button
            Button nextLevelButton = mLevelCompleteGui.MainGui.SelectSingleElement <Button>("**/NextLevelButton");

            nextLevelButton.AddOnPressedAction(onNextLevelPressed);
            nextLevelButton.AddOnPressedAction(CleanupLevelCompleteGui);

            Button exitToRunwayButton = mLevelCompleteGui.MainGui.SelectSingleElement <Button>("**/ExitToRunwayButton");

            if (exitToRunwayButton != null)
            {
                exitToRunwayButton.AddOnPressedAction(delegate()
                {
                    FashionMinigame.GoToRunway();
                });
            }
        }