public void UpdateState()
        {
            if (Configs == null)
            {
                return;
            }

            bool locked   = true;
            int  complete = 0;
            int  total    = Configs.Length;

            for (int i = 0; i < total; i++)
            {
                if (i == 0)
                {
                    // Exception when playing on hard (Not Core)
                    if (Configs[i].Planet != PlanetType.Core && Difficulty == 3 && Configs[i].Game == Game.Assault && ContainerAPI.GetDuelApi().Progress.HasCompleted(DuelAPI.Duelist.Archivist, 2))
                    {
                        locked = false;
                    }
                    else
                    {
                        locked = ContainerAPI.IsLevelLocked(Configs[i], Difficulty) || ContainerAPI.IsPlanetLocked(Configs[i].Planet);
                    }
                }

                if (ContainerAPI.IsLevelComplete(Configs[i], Difficulty))
                {
                    complete++;
                }
            }

            NotStarted.SetActive(locked);
            InProgress.SetActive(!locked && complete < total);
            Complete.SetActive(total == complete);
        }
Esempio n. 2
0
        private void Start()
        {
            PillarConfig currentConfig = null;

            GuardianPinConfig.Clear();

            // Guardian Track, this one is weird.

            // If the hard archivist is not beating but all hard duelist are, only pin the core (if TD / Chess are beat).
            if (!ContainerAPI.IsLevelComplete(GuardianFinalBattle, 3) && ContainerAPI.IsMedalUnlocked(MedalType.AdvancedCombat))
            {
                if (ContainerAPI.IsMedalUnlocked(MedalType.Insight) && ContainerAPI.IsMedalUnlocked(MedalType.Leadership))
                {
                    // We need to know the given pillar too..
                    currentConfig = GuardianFinalBattle;

                    // We only need to check the last 3 in this execption.
                    for (int i = 0; i < 3; i++)
                    {
                        if (!ContainerAPI.IsLevelLocked(currentConfig, 3))
                        {
                            GuardianPinConfig.Add(currentConfig);
                            GuardianPinConfigDifficulty = 3;
                            break;
                        }

                        currentConfig = currentConfig.PreviousConfig;
                    }

                    // Show the Planet Pin
                    PinHolders[(int)PlanetType.Core].ShowPin(PinType.Guardian);
                }
            }

            // If you beat archivist on medium, we show pins for all planets that you haven't beat the duelist on
            else if (ContainerAPI.IsLevelComplete(GuardianFinalBattle, 2))
            {
                currentConfig = GuardianFinalBattle;
                while (currentConfig != null)
                {
                    // Only Duelist that are not on the core, another exception.
                    if (currentConfig.Game == Game.Duel && !ContainerAPI.IsLevelComplete(currentConfig, 3) && currentConfig.Planet != PlanetType.Core)
                    {
                        // Save for later, More exceptions, need to check back 3 pillars here too....
                        PillarConfig second = currentConfig.PreviousConfig;
                        PillarConfig first  = (second != null) ? second.PreviousConfig : null;

                        if (first != null && !ContainerAPI.IsLevelComplete(first, 3))
                        {
                            GuardianPinConfig.Add(first);
                        }
                        else if (second != null && !ContainerAPI.IsLevelComplete(second, 3))
                        {
                            GuardianPinConfig.Add(second);
                        }
                        else
                        {
                            GuardianPinConfig.Add(currentConfig);
                        }

                        GuardianPinConfigDifficulty = 3;

                        // We show the pin?
                        PinHolders[(int)currentConfig.Planet].ShowPin(PinType.Guardian);
                    }

                    currentConfig = currentConfig.PreviousConfig;
                }
            }

            // If you havent...
            else
            {
                // Check medium progress then easy.
                for (int difficulty = 2; difficulty > 0; difficulty--)
                {
                    currentConfig = GuardianFinalBattle;
                    while (currentConfig != null)
                    {
                        if (!ContainerAPI.IsLevelLocked(currentConfig, difficulty))
                        {
                            // Save for later
                            GuardianPinConfig.Add(currentConfig);
                            GuardianPinConfigDifficulty = difficulty;

                            // We show the pin?
                            PinHolders[(int)currentConfig.Planet].ShowPin(PinType.Guardian);
                            difficulty = 0;
                            break;
                        }

                        currentConfig = currentConfig.PreviousConfig;
                    }
                }
            }

            // Commander Track (Easy Only)
            currentConfig = CommanderFinalBattle;
            while (currentConfig != null)
            {
                // First one not locked.
                if (!ContainerAPI.IsLevelLocked(currentConfig, 1))
                {
                    // Last Level is unlocked but not beat
                    if (currentConfig == CommanderFinalBattle)
                    {
                        if (!ContainerAPI.IsLevelComplete(currentConfig, 1))
                        {
                            PinHolders[(int)PlanetType.Core].ShowPin(PinType.Commander);
                            CommanderPinConfig = currentConfig;
                        }
                        break;
                    }

                    // Save for later
                    CommanderPinConfig = currentConfig;

                    // We show the pin?
                    PinHolders[(int)currentConfig.Planet].ShowPin(PinType.Commander);
                    break;
                }

                currentConfig = currentConfig.PreviousConfig;
            }

            // Consular Track (Easy Only)
            currentConfig = ConsularFinalBattle;
            while (currentConfig != null)
            {
                // First one not locked.
                if (!ContainerAPI.IsLevelLocked(currentConfig, 1))
                {
                    // Last Level is unlocked
                    if (currentConfig == ConsularFinalBattle)
                    {
                        // but not beat
                        if (!ContainerAPI.IsLevelComplete(currentConfig, 1))
                        {
                            PinHolders[(int)PlanetType.Core].ShowPin(PinType.Consular);
                            ConsularPinConfig = currentConfig;
                        }
                        break;
                    }

                    // Save for later
                    ConsularPinConfig = currentConfig;

                    // We show the pin?
                    PinHolders[(int)currentConfig.Planet].ShowPin(PinType.Consular);
                    break;
                }

                currentConfig = currentConfig.PreviousConfig;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Select the current focused node.
        /// </summary>
        public virtual void NodeSelected()
        {
            // Difficulty Button
            if (pillars != null && pillars.UIController.GazeClick())
            {
                return;
            }

            // Nothing selected, or we are animating, or you selected something in the same view as you're aleady in.
            if (Animating || focusedNode == null || (focusedNode != null && focusedNode.NodeType == selectedNode.NodeType))
            {
                return;
            }

            // Locked Planet
            if (focusedNode is PlanetMenuNode && (focusedNode as PlanetMenuNode).Locked)
            {
                // Locked Planet Audio (4 cases)
                PlanetMenuNode planetNode = focusedNode as PlanetMenuNode;

                bool tdComplete    = ContainerAPI.IsLevelComplete(planetNode.PreviousTDConfig, 1);
                bool chessComplete = ContainerAPI.IsLevelComplete(planetNode.PreviousChessConfig, 1);
                bool playAnimation = true;

                if (tdComplete && chessComplete)
                {
                    AudioEvent.Play(AudioEventName.Archivist.GalaxyMap.PlanetLockedBoth, Holocron);
                }
                else if (tdComplete)
                {
                    AudioEvent.Play(AudioEventName.Archivist.GalaxyMap.PlanetLockedTowerDefense, Holocron);
                }
                else if (chessComplete)
                {
                    AudioEvent.Play(AudioEventName.Archivist.GalaxyMap.PlanetLockedChess, Holocron);
                }
                else
                {
                    AudioEvent.Play(AudioEventName.Archivist.GalaxyMap.PlanetLockedGeneral, Holocron);
                    playAnimation = false;
                }

                if (playAnimation)
                {
                    GameObject lockedEffect = (focusedNode as PlanetMenuNode).PreviousPlanetEffect;
                    if (lockedEffect != null)
                    {
                        lockedEffect.SetActive(true);
                    }
                }

                AudioEvent.Play(AudioEventName.GalaxyMap.NodeLocked, gameObject);

                return;
            }

            // Clicked the same pillar twice
            if (selectedPillarNode != null && !selectedPillarNode.Locked && focusedNode == selectedPillarNode)
            {
                DeepLinkOnLoad   = true;
                DifficultyToLoad = pillars.UIController.CurrentDifficulty;
                GetComponent <Animator>().Play("menuFull_hide");
                AudioEvent.Play(AudioEventName.GalaxyMap.LaunchActivity, gameObject);
                StartCoroutine(LaunchGame());
                return;
            }

            if (selectedPillarNode != null)
            {
                selectedPillarNode.Selected = false;
                selectedPillarNode          = null;
            }

            // Pillar Selected, show the screen.
            if (focusedNode.NodeType == MenuNodeType.Pillar)
            {
                selectedPillarNode          = (PillarMenuNode)focusedNode;
                selectedPillarNode.Selected = true;

                pillars.UIController.Setup(selectedPillarNode);

                selectedPillarNode.AnimatePillar();

                AudioEvent.Play(AudioEventName.GalaxyMap.BeginActivity, gameObject);

                return;
            }

            if (focusedNode != null && focusedNode is PorgMenuNode)
            {
                focusedNode.Selected = true;

                return;
            }

            // Animating and set the new current view
            Animating = true;

            // Last and Current Nodes
            lastNode       = selectedNode;
            lastNodeParent = selectedNodeParent;

            selectedNode         = focusedNode;
            selectedNode.Focused = false;
            focusedNode          = null;

            // Selected
            lastNode.Selected     = false;
            selectedNode.Selected = true;

            // Galaxy to Planet
            if (selectedNode.NodeType == MenuNodeType.Planet && lastNode.NodeType == MenuNodeType.Galaxy)
            {
                PlanetMenuNode currentPlanetNode = ((PlanetMenuNode)selectedNode);
                previousMenuNode = lastNode;
                if (currentPlanetNode.IsBonusPlanet)
                {
                    DeepLinkToBonusPlanet = currentPlanetNode.BonusPlanet;
                }
                else
                {
                    DeepLinkToPlanet      = currentPlanetNode.Planet;
                    DeepLinkToBonusPlanet = null;
                }

                // Break Planet Out
                selectedNodeParent = selectedNode.GetRootTransform().parent;
                selectedNode.GetRootTransform().SetParent(Galaxy.transform.parent, true);

                // Animate Planet
                selectedNode.Animator.Play("planet_restToPrimary");
                ((PlanetMenuNode)selectedNode).SurfaceAnimator.Play("planetSurface_show");
                ((PlanetMenuNode)selectedNode).FacePlayer(stereoCamera.transform);

                // Face player
                pillars.FacePlayer(stereoCamera.transform);

                // Animate Galaxy
                lastNode.OnAnimationComplete += AnimationComplete;
                lastNode.Animator.Play("galaxy_primaryToSecondary");

                // Animate New Pillars
                if (!currentPlanetNode.IsBonusPlanet)
                {
                    pillars.GetPlanetAnimator(((PlanetMenuNode)selectedNode).Planet).Play("planetPillars_hiddenToPlanet");
                }
                else
                {
                    pillars.GetPlanetAnimator(((PlanetMenuNode)selectedNode).BonusPlanet).Play("planetPillars_hiddenToPlanet");
                }

                // Show 3rd Pillar Pin if needed
                pillars.CheckToShowSecondLevelPin(((PlanetMenuNode)selectedNode).Planet);
            }

            // Planet to Galaxy
            else if (selectedNode.NodeType == MenuNodeType.Galaxy && lastNode.NodeType == MenuNodeType.Planet)
            {
                PlanetMenuNode lastPlanet = (PlanetMenuNode)lastNode;

                // Animate Galaxy
                previousMenuNode = null;
                selectedNode.Animator.Play("galaxy_secondaryToPrimary");

                // Animate Planet
                //disabling to potentially fix DCM-1751
                //NavigationController.IsWaitingForAnimationToComplete = true;
                lastNode.OnAnimationComplete += AnimationComplete;
                lastNode.Animator.Play("planet_primaryToRest");
                ((PlanetMenuNode)lastNode).SurfaceAnimator.Play("planetSurface_hide");

                // Animate New Pillars
                if (!lastPlanet.IsBonusPlanet)
                {
                    pillars.GetPlanetAnimator(((PlanetMenuNode)lastNode).Planet).Play("planetPillars_planetToHidden");

                    // Hide 3rd Pillar Pin if needed
                    pillars.CheckToHideSecondLevelPin(((PlanetMenuNode)lastNode).Planet);
                }
                else
                {
                    pillars.GetPlanetAnimator(((PlanetMenuNode)lastNode).BonusPlanet).Play("planetPillars_planetToHidden");
                    // Hide 3rd Pillar Pin if needed
                    //pillars.CheckToHideSecondLevelPin(((PlanetMenuNode)lastNode).BonusPlanet);
                }
            }

            // Planet to Surface
            else if (selectedNode.NodeType == MenuNodeType.Surface && lastNode.NodeType == MenuNodeType.Planet)
            {
                PlanetMenuNode lastPlanetNode = (PlanetMenuNode)lastNode;

                previousMenuNode = lastNode;
                DeepLinkToGame   = ((SurfaceMenuNode)selectedNode).LaunchGame;

                if (!lastPlanetNode.IsBonusPlanet)
                {
                    pillars.UIController.Setup((SurfaceMenuNode)selectedNode, ((PlanetMenuNode)lastNode).Planet);
                }
                else
                {
                    pillars.UIController.Setup((SurfaceMenuNode)selectedNode, ((PlanetMenuNode)lastNode).BonusPlanet);
                }

                Galaxy.GetComponent <Animator>().Play("galaxy_secondaryToTertiary");

                if (!lastPlanetNode.IsBonusPlanet)
                {
                    pillars.GetPlanetAnimator(((PlanetMenuNode)lastNode).Planet).Play("planetPillars_planetTo" + GetGameName(((SurfaceMenuNode)selectedNode).LaunchGame));
                }
                else
                {
                    pillars.GetPlanetAnimator(((PlanetMenuNode)lastNode).BonusPlanet).Play("planetPillars_planetTo" + GetGameName(((SurfaceMenuNode)selectedNode).LaunchGame));
                }

                lastNode.OnAnimationComplete += AnimationComplete;
                lastNode.Animator.Play("planet_primaryToSecondary");
                ((PlanetMenuNode)lastNode).SurfaceAnimator.Play("planetSurface_hide");

                AudioEvent.Play(AudioEventName.GalaxyMap.SelectActivity, gameObject);

                // Play the ambience for the planet surface
                if (!lastPlanetNode.IsBonusPlanet)
                {
                    AudioEvent.Play("MAP_SFX_GalaxyMap_Ambience_" + ((PlanetMenuNode)lastNode).Planet + "_Play",
                                    selectedNode.gameObject);
                }
                // Play the ambience for bonus planet
                else
                {
                    AudioEvent.Play("MAP_SFX_GalaxyMap_Ambience_" + ((PlanetMenuNode)lastNode).BonusPlanet + "_Play", selectedNode.gameObject);

                    // checking for assault mode completion on easy
                    if (ConfigToLoad != null && ContainerAPI.IsLevelComplete(ConfigToLoad, 1))
                    {
                        AudioEvent.PlayOnceEver("MAP_DX_Arch_Crait_000_004", selectedNode.gameObject);
                    }
                }
            }

            // Surface to Planet
            else if (selectedNode.NodeType == MenuNodeType.Planet && lastNode.NodeType == MenuNodeType.Surface)
            {
                PlanetMenuNode selectedPlanet = (PlanetMenuNode)selectedNode;

                previousMenuNode = Galaxy.GetComponent <MenuNode>();
                pillars.UIController.Hide();

                // Hide Lock Icons
                PillarMenuNode[] pillarNodes = lastNode.gameObject.GetComponentsInChildren <PillarMenuNode>();

                for (int i = 0; i < pillarNodes.Length; i++)
                {
                    pillarNodes[i].LockObject.SetActive(false);
                }

                Galaxy.GetComponent <Animator>().Play("galaxy_tertiaryToSecondary");

                if (!selectedPlanet.IsBonusPlanet)
                {
                    pillars.GetPlanetAnimator(((PlanetMenuNode)selectedNode).Planet).Play("planetPillars_" + GetGameName(((SurfaceMenuNode)lastNode).LaunchGame).ToLower() + "ToPlanet");
                }
                else
                {
                    pillars.GetPlanetAnimator(((PlanetMenuNode)selectedNode).BonusPlanet).Play("planetPillars_" + GetGameName(((SurfaceMenuNode)lastNode).LaunchGame).ToLower() + "ToPlanet");
                }

                selectedNode.OnAnimationComplete += AnimationComplete;
                selectedNode.Animator.Play("planet_secondaryToPrimary");
                ((PlanetMenuNode)selectedNode).SurfaceAnimator.Play("planetSurface_show");
                ((PlanetMenuNode)selectedNode).FacePlayer(stereoCamera.transform);

                // Show 3rd Pillar Pin if needed
                if (!selectedPlanet.IsBonusPlanet)
                {
                    pillars.CheckToShowSecondLevelPin(((PlanetMenuNode)selectedNode).Planet);
                }
                else
                {
                    pillars.CheckToShowSecondLevelPin(((PlanetMenuNode)selectedNode).BonusPlanet);
                }

                AudioEvent.Play(AudioEventName.GalaxyMap.SelectBack, gameObject);

                // Stop the ambience for the planet surface
                if (!selectedPlanet.IsBonusPlanet)
                {
                    AudioEvent.Play("MAP_SFX_GalaxyMap_Ambience_" + ((PlanetMenuNode)selectedNode).Planet + "_Stop",
                                    lastNode.gameObject);
                }
                else
                {
                    AudioEvent.Play("MAP_SFX_GalaxyMap_Ambience_" + ((PlanetMenuNode)selectedNode).BonusPlanet + "_Stop",
                                    lastNode.gameObject);
                }
            }
        }
        private void SetupDifficulty(Game game)
        {
            // Need to find all the pillars and figure out the highest unlocked difficulty.
            CurrentDifficulty = Difficulty.Easy;
            EasyButton.Locked = false;
            DifficultyHolder.SetActive(game == Game.Assault || game == Game.Duel);

            // Not in a duel or assault
            if (!DifficultyHolder.activeSelf)
            {
                UpdatePillars();
                return;
            }

            // Lock medium and hard until we know and deselect them all
            HardButton.Locked   = MediumButton.Locked = true;
            HardButton.Selected = MediumButton.Selected = EasyButton.Selected = false;
            EasyButton.SetDefault();
            MediumButton.SetDefault();
            HardButton.SetDefault();

            DuelAPI    duelApi = ContainerAPI.GetDuelApi();
            PlanetType planet  = PlanetType.Naboo;

            // This will unlock Medium and Hard if possible
            for (int i = 0; i < pillars.Length; i++)
            {
                planet = pillars[i].Config.Planet;

                // Special exception for hard duelists
                if (pillars[i].Config.PillarNumber == 1 && duelApi.Progress.HasCompleted(DuelAPI.Duelist.Archivist, 2) && pillars[i].Config.Planet != PlanetType.Core)
                {
                    MediumButton.Locked = false;
                    HardButton.Locked   = false;
                }

                // Normal Path
                else if (pillars[i].Config.PreviousConfig != null)
                {
                    if (MediumButton.Locked)
                    {
                        MediumButton.Locked = !ContainerAPI.IsLevelComplete(pillars[i].Config.PreviousConfig, (int)Difficulty.Medium);
                    }

                    if (HardButton.Locked)
                    {
                        HardButton.Locked = !ContainerAPI.IsLevelComplete(pillars[i].Config.PreviousConfig, (int)Difficulty.Hard);
                    }
                }

                // First Levels
                else
                {
                    if (planet == PlanetType.DarkSide)
                    {
                        if (MediumButton.Locked)
                        {
                            MediumButton.Locked = (ContainerAPI.AllProgressionUnlocked) ? false : !duelApi.Progress.HasCompleted(DuelAPI.Duelist.Rey, 1);
                        }

                        if (HardButton.Locked)
                        {
                            HardButton.Locked = (ContainerAPI.AllProgressionUnlocked) ? false : !duelApi.Progress.HasCompleted(DuelAPI.Duelist.Rey, 2);
                        }
                    }
                    else
                    {
                        if (MediumButton.Locked)
                        {
                            MediumButton.Locked = (ContainerAPI.AllProgressionUnlocked) ? false : !duelApi.Progress.HasCompleted(DuelAPI.Duelist.KyloRen,
                                                                                                                                 1);
                        }

                        if (HardButton.Locked)
                        {
                            HardButton.Locked = (ContainerAPI.AllProgressionUnlocked) ? false : !duelApi.Progress.HasCompleted(DuelAPI.Duelist.Archivist,
                                                                                                                               2);
                        }
                    }
                }

                // Special exception for core duel track
                if (pillars[i].Config.Planet == PlanetType.Core && (pillars[i].Config.Game == Game.Duel || pillars[i].Config.Game == Game.Assault))
                {
                    if (!ContainerAPI.IsMedalUnlocked(MedalType.Insight) || !ContainerAPI.IsMedalUnlocked(MedalType.Leadership) || !ContainerAPI.IsMedalUnlocked(MedalType.AdvancedCombat))
                    {
                        HardButton.Locked = true;
                    }
                }
            }

            // If the planet is Core, there are only two difficulties, Medium and Hard. Medium is called Easy to the Player
            EasyButton.gameObject.SetActive(planet != PlanetType.Core);
            ButtonOrientation(planet != PlanetType.Core);
            MediumButtonText.text = Localizer.Get((planet != PlanetType.Core) ? "LightsaberDuel.Difficulty.Medium" : "LightsaberDuel.Difficulty.Easy");

            // Hard or Medium unlocked?
            if (!HardButton.Locked)
            {
                CurrentDifficulty   = Difficulty.Hard;
                HardButton.Selected = true;
            }
            else if (!MediumButton.Locked)
            {
                CurrentDifficulty     = Difficulty.Medium;
                MediumButton.Selected = true;
            }
            else if (!EasyButton.Locked)
            {
                EasyButton.Selected = true;
            }

            // Update all 3 pillars based on new difficulty selection
            UpdatePillars();
        }