示例#1
0
        // advertisements
        void OnAdvertisementResult(object sender, InstantMessageArgs args)
        {
            AdvertisementResult result = (AdvertisementResult)args.arg;

            Debug.Log("OnAdvertisementResult: " + result.ToString());
            switch (result)
            {
            case AdvertisementResult.Successful:
                Debug.Log("Adding coins: " + adBonus.ToString());
                decimal coins = GlobalManager.MStorage.CurrentCoins;
                AddCoins(ref coins, adBonus.value);
                GlobalManager.MStorage.CurrentCoins = coins;
                GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.GUIRotoCoinsChanged, this, GlobalManager.MStorage.CurrentCoins);
                break;
            }
        }
示例#2
0
        void OnPuzzleAutostep(object sender, InstantMessageArgs args)
        {
            bool firstRound    = GlobalManager.MStorage.FirstRound;
            int  selectedLevel = GlobalManager.MStorage.SelectedLevel;

            if (firstRound)
            {
                switch (selectedLevel)
                {
                case 0:
                case 1:
                    return;
                }
            }
            decimal coins = GlobalManager.MStorage.CurrentCoins;

            AddCoins(ref coins, -autostepPrice.value);
            GlobalManager.MStorage.CurrentCoins = coins;
            GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.GUIRotoCoinsChanged, this, GlobalManager.MStorage.CurrentCoins);
        }
示例#3
0
        void OnPuzzleComplete(object sender, InstantMessageArgs args)
        {
            PuzzleCompleteStatus completeStatus = (PuzzleCompleteStatus)args.arg;

            if (!puzzleCompletionProcessed)
            {
                // this may be the first pass at tutorial levels
                puzzleCompletionProcessed = true;
                Debug.Log("GameManager.OnPuzzleComplete: set puzzleCompletionProcessed flag to true");
                bool firstRound = GlobalManager.MStorage.FirstRound;
                if (completeStatus != null)
                {
                    int            nextLevelId = GlobalManager.MLevel.NextLevel(completeStatus.descriptor.init.id);
                    int            prevLevelId = GlobalManager.MLevel.PreviousLevel(completeStatus.descriptor.init.id);
                    RealmData.Init realmData   = RealmData.initializers[completeStatus.descriptor.init.realmId];

                    // set a message queue for the Victory screen
                    if (completeStatus.firstTime)   // a puzzle is assembled for the first time
                    {
                        GlobalManager.MQueue.PostMessage(levelCompletedId);
                        if (completeStatus.descriptor.init.id == 0)                                  // this is the very first puzzle in the game
                        {
                            GlobalManager.MStorage.GalleryLevel = completeStatus.descriptor.init.id; // set the gallery level to the newly completed one
                            GlobalManager.MStorage.FirstGallery = true;                              // gallery message should be shown
                            GlobalManager.MQueue.PostMessage(galleryOpenedId);                       // post a message about the gallery
                        }
                        if (completeStatus.descriptor.init.realmId >= 0)                             // this should always be true, yet...
                        {
                            if (realmData.mainLevelId == completeStatus.descriptor.init.id)
                            {
                                // main (first) level of the realm has been complete
                                GlobalManager.MQueue.PostMessage(realmRevealedId);
                            }
                        }
                        if (nextLevelId >= 0)
                        {
                            // there is another level to play at
                            GlobalManager.MQueue.PostMessage(newLevelPlayableId);
                        }
                    }
                    else
                    {
                        GlobalManager.MQueue.PostMessage(levelCompletedOnceAgainId);
                    }

                    // Do the accounting chores
                    // Also report of achievements
                    long earnedPoints = completeStatus.descriptor.state.EarnedPoints;
                    if (firstRound)
                    {
                        switch (completeStatus.descriptor.init.id)
                        {
                        case 0:
                            completeStatus.descriptor.state.EarnedPoints =
                                ((completeStatus.descriptor.init.height + 1) * completeStatus.descriptor.init.height / 2) * puzzleAssembledRowBonusStep +
                                firstRunLevel0Row0Bonus +
                                puzzleCompleteBonus;
                            GlobalManager.MAchievement.ReportNewAchievement(AchievementType.FirstPuzzleAssembled);
                            break;

                        case 1:
                            completeStatus.descriptor.state.EarnedPoints =
                                ((completeStatus.descriptor.init.height + 1) * completeStatus.descriptor.init.height / 2) * puzzleAssembledRowBonusStep +
                                firstRunLevel1Row0Bonus +
                                firstRunLevel1Row1Bonus +
                                puzzleCompleteBonus;
                            AddBonusCoins();
                            GlobalManager.MAchievement.ReportNewAchievement(AchievementType.SecondPuzzleAssembled);
                            break;

                        case 2:
                            GlobalManager.MAchievement.ReportNewAchievement(AchievementType.ThirdPuzzleAssembled);
                            break;

                        default:
                            AddPoints(ref earnedPoints, puzzleCompleteBonus);
                            completeStatus.descriptor.state.EarnedPoints = earnedPoints;
                            break;
                        }
                    }
                    else
                    {
                        AddPoints(ref earnedPoints, puzzleCompleteBonus);
                        completeStatus.descriptor.state.EarnedPoints = earnedPoints;
                    }
                    GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.GUIRotoChipsChanged, this, (decimal)completeStatus.descriptor.state.EarnedPoints);
                    earnedPoints = GlobalManager.MStorage.CurrentPoints;
                    AddPoints(ref earnedPoints, completeStatus.descriptor.state.EarnedPoints);
                    GlobalManager.MStorage.CurrentPoints = earnedPoints;
                    //completeStatus.descriptor.state.Complete = true;

                    // set all the levels in the current realm revealed
                    bool realmComplete = true;
                    for (int i = 0; i < realmData.members.Length; i++)
                    {
                        LevelDataManager.Descriptor descriptor = GlobalManager.MLevel.GetDescriptor(realmData.members[i]);
                        if (!descriptor.state.Revealed)
                        {
                            descriptor.state.Revealed = true;
                        }
                        // check if all other levels in the realm are complete
                        if (descriptor.init.id != completeStatus.descriptor.init.id && !descriptor.state.Complete)
                        {
                            realmComplete = false;
                        }
                    }

                    // now add an achievement
                    if (firstRound)
                    {
                        switch (completeStatus.descriptor.init.id)
                        {
                        case 0:
                            break;

                        case 1:
                            break;
                        }
                    }

                    if (nextLevelId >= 0)
                    {
                        // make next level revealed and playable
                        LevelDataManager.Descriptor descriptor = GlobalManager.MLevel.GetDescriptor(nextLevelId);
                        descriptor.state.Revealed = true;
                        descriptor.state.Playable = true;
                        completeStatus.descriptor.state.NextPlayableId = nextLevelId;
                        //GlobalManager.MStorage.SelectedLevel = nextLevelId;
                    }
                    if (prevLevelId >= 0)
                    {
                        // link previously completed level to the newly completed one
                        LevelDataManager.Descriptor descriptor = GlobalManager.MLevel.GetDescriptor(prevLevelId);
                        descriptor.state.NextCompleteId = completeStatus.descriptor.init.id;
                    }

                    // check if the game is complete
                    if (realmComplete)
                    {
                        GlobalManager.MQueue.PostMessage(realmCompletedId);
                        if (realmData.id >= 0 && realmData.id < realmAchievements.Length)
                        {
                            GlobalManager.MAchievement.ReportNewAchievement(realmAchievements[realmData.id]);
                        }
                        if (nextLevelId < 0)    // no more new levels
                        {
                            // the game is complete
                            GlobalManager.MStorage.GameFinished = true;
                            GlobalManager.MStorage.FirstRound   = false;
                            GlobalManager.MQueue.PostMessage(gameCompletedId);
                            GlobalManager.MAchievement.ReportNewAchievement(AchievementType.FirstRunFinished);
                        }
                        else
                        {
                            GlobalManager.MQueue.PostMessage(realmOpenedId);
                        }
                    }
                }
            }
            // there may be some unshown hints; notify for puzzle processing completion otherwise
            if (puzzleHintsShown)
            {
                // this may be the second pass at tutorial levels (0 and 1)
                Debug.Log("GameManager.OnPuzzleComplete: all hints are shown, completing the level");
                completeStatus.descriptor.state.Complete = true;
                GlobalManager.MStorage.SelectedLevel     = GlobalManager.MLevel.NextLevel(completeStatus.descriptor.init.id);
                GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.PuzzleCompleteProcessed, this, completeStatus);
            }
            else
            {
                Debug.Log("GameManager.OnPuzzleComplete: not every hint is shown yet");
            }
        }
示例#4
0
        // OnPuzzleTileInPlace is called whenever PuzzleController detects a new "good" puzzle state
        // This happens before any button rotation, so to correctly show a hint we have to wait until ther button rotation ends
        // Hence the usage of WaitForButtonRotation
        void OnPuzzleTileInPlace(object sender, InstantMessageArgs args)
        {
            bool firstRound                = GlobalManager.MStorage.FirstRound;
            int  selectedLevel             = GlobalManager.MStorage.SelectedLevel;
            TileInPlaceReport tilesInPlace = (TileInPlaceReport)args.arg;

            LevelDataManager.Descriptor descriptor = GlobalManager.MLevel.GetDescriptor(selectedLevel);
            if (firstRound)
            {
                switch (selectedLevel)
                {
                case 0:
                    // only (0,0), (1,0), and (2,0) tiles are counted
                    // the total points value for the completed level is recalculated in OnPuzzleComplete
                    if (IsTileInPlace(new Vector2Int(descriptor.init.width - 1, 0), tilesInPlace, descriptor))
                    {
                        // tile (2,0) is in place; first row assembled
                        descriptor.state.EarnedPoints = firstRunLevel0Row0Bonus + puzzleAssembledRowBonusStep;
                        //GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.RotoChipsChanged, this, (decimal)descriptor.state.EarnedPoints);
                        StartCoroutine(WaitForButtonRotation(HintType.ThirdTileInPlace));
                        //GlobalManager.MHint.ShowNewHint(HintType.ThirdTileInPlace);
                    }
                    else if (IsTileInPlace(new Vector2Int(1, 0), tilesInPlace, descriptor))
                    {
                        // tile (1,0) is in place
                        StartCoroutine(WaitForButtonRotation(HintType.SecondTileInPlace));
                        //GlobalManager.MHint.ShowNewHint(HintType.SecondTileInPlace);
                    }
                    else if (IsTileInPlace(new Vector2Int(0, 0), tilesInPlace, descriptor))
                    {
                        // tile (0,0) is in place
                        StartCoroutine(WaitForButtonRotation(HintType.FirstTileInPlace));
                        //GlobalManager.MHint.ShowNewHint(HintType.FirstTileInPlace);
                    }
                    return;

                case 1:
                    // only (2,0) and (2,1) tiles are counted
                    // the total points value for the completed level is recalculated in OnPuzzleComplete
                    if (IsTileInPlace(new Vector2Int(descriptor.init.width - 1, 1), tilesInPlace, descriptor))
                    {
                        // second row assembled
                        if (!puzzleCompletionProcessed)
                        {
                            descriptor.state.EarnedPoints = firstRunLevel1Row1Bonus + firstRunLevel1Row0Bonus + (2 + 1) * puzzleAssembledRowBonusStep;
                        }
                        StartCoroutine(WaitForButtonRotation(HintType.TwoRowsInPlace));
                    }
                    else
                    if (IsTileInPlace(new Vector2Int(descriptor.init.width - 1, 0), tilesInPlace, descriptor))
                    {
                        // first row assembled
                        if (!puzzleCompletionProcessed)
                        {
                            descriptor.state.EarnedPoints = firstRunLevel1Row0Bonus + puzzleAssembledRowBonusStep;
                        }
                        StartCoroutine(WaitForButtonRotation(HintType.FirstRowCongratulation));
                    }
                    return;
                }
            }
            // calculate points bonuses
            if (!descriptor.state.AutocompleteUsed)
            {
                AddPointsBonuses(tilesInPlace, descriptor);
            }
        }
示例#5
0
 void OnPuzzleButtonRotated(object sender, InstantMessageArgs args)
 {
     buttonRotated = true;
 }
示例#6
0
        void OnGUIHintClosed(object sender, InstantMessageArgs args)
        {
            HintRequest hintRequest   = (HintRequest)args.arg;
            bool        firstRound    = GlobalManager.MStorage.FirstRound;
            int         selectedLevel = GlobalManager.MStorage.SelectedLevel;

            Debug.Log("GameManager.OnGUIHintClosed after " + hintRequest.type.ToString());
            switch (sceneType)
            {
            case SceneType.World:
                if (firstRound)
                {
                    switch (selectedLevel)
                    {
                    case 0:
                        switch (hintRequest.type)
                        {
                        case HintType.FirstTimeWelcome:
                            GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.WorldRotateToSelected, this);
                            GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.RedirectFirstTimeWelcome2, this);
                            worldWaits = StartCoroutine(WorldWaitsForHint());
                            break;

                        case HintType.FirstTimeWelcome2:
                            if (worldWaits != null)
                            {
                                // if hint has been closed before the world finishes to rotate
                                StopCoroutine(worldWaits);
                                worldWaits = null;
                                GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.WorldRotationEnable, this, true);
                            }
                            break;
                        }
                        break;

                    case 1:
                        switch (hintRequest.type)
                        {
                        case HintType.GalleryOpened:
                            if (worldWaits != null)
                            {
                                // if hint has been closed before the world finishes to rotate
                                StopCoroutine(worldWaits);
                                GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.WorldRotationEnable, this, true);
                            }
                            break;
                        }
                        break;
                    }
                }
                break;

            case SceneType.Puzzle:
                if (firstRound)
                {
                    switch (selectedLevel)
                    {
                    case 0:
                        switch (hintRequest.type)
                        {
                        case HintType.PuzzleFirstShuffled:
                            GlobalManager.MHint.ShowNewHint(HintType.FirstLevelChallenge);
                            break;

                        case HintType.FirstLevelChallenge:
                            // this will actually show a FirstTileInPlace hint
                            GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.RedirectFirstTileButtons, this);
                            break;

                        case HintType.FirstTileInPlace:
                            // this will actually show a SecondTileButtonsHint
                            GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.RedirectSecondTileButtons, this);
                            break;

                        case HintType.ThirdTileInPlace:
                            // level 0 challenge complete
                            GlobalManager.MHint.ShowNewHint(HintType.TwoRowsInPlace1);
                            break;

                        case HintType.TwoRowsInPlace1:
                            // special processing for a completed puzzle
                            puzzleHintsShown = true;
                            Debug.Log("GameManager.OnGUIHintClosed: after " + hintRequest.type.ToString() + " puzzleCompletionProcessed is " + puzzleCompletionProcessed.ToString());
                            if (puzzleCompletionProcessed)
                            {
                                LevelDataManager.Descriptor descriptor     = GlobalManager.MLevel.GetDescriptor(selectedLevel);
                                PuzzleCompleteStatus        completeStatus = new PuzzleCompleteStatus
                                {
                                    descriptor = descriptor,
                                    firstTime  = !descriptor.state.Complete
                                };
                                GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.PuzzleComplete, this, completeStatus);
                            }
                            else
                            {
                                GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.PuzzleAutocomplete, this);
                            }
                            break;
                        }
                        break;

                    case 1:
                        switch (hintRequest.type)
                        {
                        case HintType.TwoRowsInPlace:
                            Debug.Log("GameManager.OnGUIHintClosed: after " + hintRequest.type.ToString() + " show new hint TwoRowsInPlace2");
                            AddBonusCoins();
                            GlobalManager.MHint.ShowNewHint(HintType.TwoRowsInPlace2);
                            break;

                        case HintType.TwoRowsInPlace2:
                            // special processing for a completed puzzle
                            puzzleHintsShown = true;
                            Debug.Log("GameManager.OnGUIHintClosed: after " + hintRequest.type.ToString() + " puzzleCompletionProcessed is " + puzzleCompletionProcessed.ToString());
                            if (puzzleCompletionProcessed)
                            {
                                LevelDataManager.Descriptor descriptor     = GlobalManager.MLevel.GetDescriptor(selectedLevel);
                                PuzzleCompleteStatus        completeStatus = new PuzzleCompleteStatus
                                {
                                    descriptor = descriptor,
                                    firstTime  = !descriptor.state.Complete
                                };
                                GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.PuzzleComplete, this, completeStatus);
                            }
                            else
                            {
                                GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.PuzzleAutocomplete, this);
                            }
                            break;
                        }
                        break;
                    }
                }
                break;
            }
        }
示例#7
0
 void OnPuzzleSourceImageClosed(object sender, InstantMessageArgs args)
 {
     sourceImageClosed = true;
 }
示例#8
0
        void OnGUIWhiteCurtainFaded(object sender, InstantMessageArgs args)
        {
            bool up = (bool)args.arg;

            if (up)
            {
                sceneType = SceneType.None;
                return;
            }
            bool firstRound    = GlobalManager.MStorage.FirstRound;
            int  selectedLevel = GlobalManager.MStorage.SelectedLevel;

            switch (sceneType)
            {
            case SceneType.World:
                if (firstRound)
                {
                    switch (selectedLevel)
                    {
                    case 0:
                        // hint FirstTimeWelcome is shown once at the very first start of the game
                        GlobalManager.MHint.ShowNewHint(HintType.FirstTimeWelcome);
                        break;

                    case 1:
                        if (!GlobalManager.MHint.IsHintShown(HintType.GalleryOpened))
                        {
                            // hint GalleryOpened
                            // requires the gallery satellite as an argument
                            GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.RedirectGalleryOpened, this);
                            worldWaits = StartCoroutine(WorldWaitsForHint());
                        }
                        else
                        {
                            // rotate to selected as usual
                            GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.WorldRotateToSelected, this);
                        }
                        break;

                    default:
                        GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.WorldRotateToSelected, this);
                        break;
                    }
                }
                else
                {
                    GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.WorldRotateToSelected, this);
                }
                break;

            case SceneType.Puzzle:
                // now shuffle the puzzle
                string shuffleConfig = null;
                if (firstRound)
                {
                    // the first two levels are shuffled specially while on the first round
                    switch (selectedLevel)
                    {
                    case 0:
                        shuffleConfig = tutorial0ShuffleConfig;
                        break;

                    case 1:
                        shuffleConfig = tutorial1ShuffleConfig;
                        break;
                    }
                }
                StartCoroutine(WaitAndShufflePuzzle(shuffleConfig));
                break;
            }
        }
示例#9
0
 void OnWorldRotatedToObject(object sender, InstantMessageArgs args)
 {
     worldRotated = true;
 }
示例#10
0
 void OnShopStarted(object sender, InstantMessageArgs args)
 {
     sceneType = SceneType.Shop;
     GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.GUIConfigureAppearance, this, shopGUIConfiguration);
 }
示例#11
0
 void OnGalleryStarted(object sender, InstantMessageArgs args)
 {
     sceneType = SceneType.Gallery;
     GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.GUIConfigureAppearance, this, galleryGUIConfiguration);
 }
示例#12
0
 void OnWorldStarted(object sender, InstantMessageArgs args)
 {
     sceneType = SceneType.World;
     ConfigureWorldGUI();
 }