예제 #1
0
        private void Start()
        {
            duelApi           = ContainerAPI.GetDuelApi();
            assaultApi        = new AssaultAPI();
            allPassiveItems   = duelApi.Inventory.PassiveAbilities.GetAllItems();
            ownedPassiveItems = duelApi.Inventory.PassiveAbilities.GetOwnedItems();
            allForceItems     = duelApi.Inventory.ForcePowers.GetAllItems();
            ownedForceItems   = duelApi.Inventory.ForcePowers.GetOwnedItems();

            if (PanelType == EquipItemType.ForcePower)
            {
                defaultLabel = Title.text;

                List <ForcePowerItem> equippedItems = duelApi.Inventory.ForcePowers.GetEquippedItems();

                foreach (ForcePowerItem item in equippedItems)
                {
                    OnItemSelected(item);
                    break;
                }
            }
            else if (PanelType == EquipItemType.PassivePower1 || PanelType == EquipItemType.PassivePower2)
            {
                defaultLabel = Title.text;

                List <PassiveAbilityItem> equippedItems = duelApi.Inventory.PassiveAbilities.GetEquippedItems();

                if (equippedItems.Count >= 1 && PanelType == EquipItemType.PassivePower1)
                {
                    if (MenuController.ConfigToLoad.Game == Game.Assault)
                    {
                        if (IsAbilityUsableInAssault(equippedItems[0]))
                        {
                            OnItemSelected(equippedItems[0]);
                        }
                    }
                    else
                    {
                        OnItemSelected(equippedItems[0]);
                    }
                }

                if (equippedItems.Count >= 2 && PanelType == EquipItemType.PassivePower2)
                {
                    if (MenuController.ConfigToLoad.Game == Game.Assault)
                    {
                        if (IsAbilityUsableInAssault(equippedItems[1]))
                        {
                            OnItemSelected(equippedItems[1]);
                        }
                    }
                    else
                    {
                        OnItemSelected(equippedItems[1]);
                    }
                }
            }
        }
예제 #2
0
        public static DuelAPI GetDuelApi()
        {
            if (duelApi == null)
            {
                duelApi = new DuelAPI();
            }

            return(duelApi);
        }
예제 #3
0
        public IEnumerator Start()
        {
            // Unity... Animator wants you to wait for some time.
            // 4 Seconds seems to be the sweet spot for long editor times,
            // and is quick enough for faster load times, as it doesn't need precision
            yield return(new WaitForSeconds(4f));

            /*
             *  - First: Starts on
             *  - Second: haven’t beat maul on med.
             *  - Third: planet garel on med
             *  - Four: planet Loth on med
             *  - Fifth: planet Hoth on med
             *  - Six: beat takadona on med
             */

            DuelAPI api = ContainerAPI.GetDuelApi();

            if (api.Progress.HasCompleted(DuelAPI.Duelist.KyloRen, 2))
            {
                CoreAnimator.SetTrigger("TriggerLevel6");
            }
            else if (api.Progress.HasCompleted(DuelAPI.Duelist.DarthVader, 2))
            {
                CoreAnimator.SetTrigger("TriggerLevel5");
            }
            else if (api.Progress.HasCompleted(DuelAPI.Duelist.GrandInquisitor, 2))
            {
                CoreAnimator.SetTrigger("TriggerLevel4");
            }
            else if (api.Progress.HasCompleted(DuelAPI.Duelist.SeventhSister, 2))
            {
                CoreAnimator.SetTrigger("TriggerLevel3");
            }
            else if (api.Progress.HasCompleted(DuelAPI.Duelist.DarthMaul, 2))
            {
                CoreAnimator.SetTrigger("TriggerLevel2");
            }
            else
            {
                CoreAnimator.SetTrigger("TriggerLevel1");
            }
        }
예제 #4
0
        private int[] GeneratePillarRatings(out int nextPlanet, out int nextNode)
        {
            AssaultAPI assaultApi = new AssaultAPI();
            DuelAPI    duelApi    = ContainerAPI.GetDuelApi();

            int[] results          = new int[PillarConfigs.Length];
            int   nextEasyConfig   = -1;
            int   nextMediumConfig = -1;

            for (int i = 0; i < PillarConfigs.Length; i++)
            {
                if (PillarConfigs[i].Game == Game.Duel)
                {
                    int rating = 0;

                    for (int difficulty = 1; difficulty <= (int)DifficultyComplete.Hard; difficulty++)
                    {
                        if (duelApi.Progress.HasCompleted(PillarConfigs[i].Duelist, difficulty))
                        {
                            rating++;
                        }
                    }

                    results[i] = rating;
                }
                else if (PillarConfigs[i].Game == Game.Assault)
                {
                    int rating = 0;

                    for (int difficulty = 1; difficulty <= (int)DifficultyComplete.Hard; difficulty++)
                    {
                        if (assaultApi.RatingForStage(PillarConfigs[i].Planet, PillarConfigs[i].PillarNumber, difficulty) > 0)
                        {
                            rating++;
                        }
                    }

                    results[i] = rating;
                }

                // Next Level Not beat on easy
                if (results[i] == 0 && nextEasyConfig == -1)
                {
                    nextEasyConfig = i;
                }

                // Next level not beat on medium
                if (results[i] == 1)
                {
                    nextMediumConfig = i;
                }

                // Debug.LogWarning("= " + PillarConfigs[i].Game + ": [" + i + "]" + results[i]);
            }

            if (nextEasyConfig != -1)
            {
                nextPlanet = (int)Mathf.Floor((float)nextEasyConfig / Enum.GetNames(typeof(NodeName)).Length);
                nextNode   = nextEasyConfig % Enum.GetNames(typeof(NodeName)).Length;
            }
            else
            {
                nextPlanet = (int)Mathf.Floor((float)nextMediumConfig / Enum.GetNames(typeof(NodeName)).Length);
                nextNode   = nextMediumConfig % Enum.GetNames(typeof(NodeName)).Length;

                // Debug.LogError("Next Medium Config: " + nextPlanet + " | " + nextNode + PillarConfigs[nextMediumConfig].Game);
            }

            return(results);
        }
예제 #5
0
        /// <summary>
        /// Launch the game!
        /// </summary>
        public void Launch()
        {
            // Stop ALl before loading into a game
            AkSoundEngine.StopAll();

            // Audio - MAP_UI_GalaxyMap_SelectGame - playing selected game audio
            AudioEvent.Play(AudioEventName.GalaxyMap.SelectGame, gameObject);
            AudioEvent.Play(AudioEventName.GalaxyMap.TransitionStinger, gameObject);

            //track scene load time
            KpiTracking.TrackSceneLoadTime();

            MenuController.ConfigToLoad = Config;

            if (SkipLevelType > 0)
            {
                if (SkipLevelType == 1)
                {
                    switch (Config.Game)
                    {
                    case Game.Duel:
                        DuelAPI api = ContainerAPI.GetDuelApi();
                        for (int i = 0; i < api.Progress.Battles.Length; i++)
                        {
                            if (api.Progress.Battles[i].DuelistIdentifier == Config.Duelist)
                            {
                                api.Inventory.ForcePowers.GiveAllItems();
                                api.Inventory.ForcePowers.SaveToDisk();
                                api.Inventory.PassiveAbilities.GiveAllItems();
                                api.Inventory.PassiveAbilities.SaveToDisk();
                                api.Progress.SetVictory(api.Progress.Battles[i], (int)MenuController.DifficultyToLoad);
                                api.Progress.SaveToDisk();
                                break;
                            }
                        }
                        break;

                    case Game.Assault:
                        AssaultAPI assaultApi = new AssaultAPI();
                        if (Config.IsBonusPlanet)
                        {
                            assaultApi.SetRatingForStage(Config.BonusPlanet, Config.PillarNumber, (int)MenuController.DifficultyToLoad, 1);
                        }
                        else
                        {
                            assaultApi.SetRatingForStage(Config.Planet, Config.PillarNumber, (int)MenuController.DifficultyToLoad, 1);
                        }
                        break;

                    case Game.HoloChess:
                        (new HolochessAPI()).CompleteLevel(Config, true);
                        break;

                    case Game.TowerDefense:
                        TDAPI.GetInstance().DebugWinBattle(Config.Battle);
                        break;
                    }
                }

                (new ContainerAPI(Game.ForceVision)).FinishLevel(SkipLevelType == 1);

                return;
            }

            ForceVisionAnalytics.LogGameStart();

            switch (Config.Game)
            {
            case Game.Duel:
            case Game.Assault:
                DuelAPI duelApi = ContainerAPI.GetDuelApi();
                int     force   = duelApi.Inventory.ForcePowers.GetOwnedItems().Count;
                int     passive = duelApi.Inventory.PassiveAbilities.GetOwnedItems().Count;

                // They have powers to equip
                if (force > 0 || passive > 0)
                {
                    SceneManager.LoadScene("Equip");
                }
                else
                {
                    if (Config.Game == Game.Assault)
                    {
                        AssaultAPI assaultApi = new AssaultAPI();
                        if (MenuController.ConfigToLoad.IsBonusPlanet)
                        {
                            assaultApi.StartAssaultMode(MenuController.ConfigToLoad.BonusPlanet, MenuController.ConfigToLoad.PillarNumber, (int)MenuController.DifficultyToLoad);
                        }
                        else
                        {
                            assaultApi.StartAssaultMode(MenuController.ConfigToLoad.Planet, MenuController.ConfigToLoad.PillarNumber, (int)MenuController.DifficultyToLoad);
                        }

                        /*
                         * assaultApi.StartAssaultMode(MenuController.ConfigToLoad.Planet,
                         *                          MenuController.ConfigToLoad.PillarNumber,
                         *                          (int)MenuController.DifficultyToLoad);
                         */
                    }
                    else
                    {
                        duelApi.Launch(MenuController.ConfigToLoad.Duelist, (int)MenuController.DifficultyToLoad);
                    }
                }
                break;

            case Game.TowerDefense:
                TDAPI.GetInstance().LaunchBattle(Config.Battle);
                break;

            case Game.HoloChess:
                HolochessAPI holoChessApi = new HolochessAPI();
                holoChessApi.StartHolochess(Config);
                break;
            }
        }
        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();
        }