예제 #1
0
        /// <summary>
        /// Lance le jeu (Le LoginScreen).
        /// </summary>
        protected void StartMain()
        {
            WorldInfos.Init();
            LevelsInfos.Init();
            SquadPattern.Init();

            if (enableLogsGameManager)
            {
                Debug.Log("Finished loading the Main scene");
            }
            loader.OnPreloadDone -= StartMain;

            //Server
            myServer = ServerManager.Instance;
            myServer.OnLoginSuccess        += ServerManager_OnLoginSuccess;
            myServer.OnGettingDatasSuccess += ServerManager_OnGettingDatasSuccess;
            myServer.OnStartFTUE           += FTUE;

            Credentials = Credentials.CheckLocalCredentials();
            if (Credentials == null)
            {
                if (enableLogsGameManager)
                {
                    Debug.LogWarning("[GameManager] No local credentials");
                }
                uiManager.AddScreen(Login.Instance);
            }
            else
            {
                myServer.Login(Credentials, true);
            }
        }
예제 #2
0
 protected void LevelManager_OnCameraFinishToward()
 {
     levelManager.OnCameraFinishToward -= LevelManager_OnCameraFinishToward;
     if (IsInFTUE)
     {
         List <SquadPattern> squadPatterns = new List <SquadPattern> {
             SquadPattern.GetSquadPattern("FTUE", 1)
         };
         SelectionSquad_OnPlay(squadPatterns);
     }
     else if (IsInDailyQuest)
     {
         List <SquadPattern> squadPatterns = new List <SquadPattern> {
             SquadPattern.GetSquadPattern(LevelsInfos.getLevelInfos(WorldIndex, LevelIndex).bestSquadName, 3),
             SquadPattern.GetSquadPattern(LevelsInfos.getLevelInfos(WorldIndex, LevelIndex).bestSquadName, 3)
         };
         SelectionSquad_OnPlay(squadPatterns);
     }
     else
     {
         UIManager.Instance.AddScreen(SelectionSquad.Instance);
     }
 }
예제 #3
0
        private void SelectionSquadCard_OnSelected(SelectionSquadCard selectionSquadCard, SquadPattern squadPattern)
        {
            selectedPatterns.Add(squadPattern);
            selectedSquads.Add(selectionSquadCard);

            if (selectedSquads.Count > 2)
            {
                selectedPatterns.RemoveAt(0);
                selectedSquads[0].isSelectable();
                selectedSquads.RemoveAt(0);
            }
        }
예제 #4
0
 private void SelectionSquadCard_OnDeSelected(SelectionSquadCard selectionSquadCard, SquadPattern squadPattern)
 {
     selectedPatterns.Remove(squadPattern);
     selectedSquads.Remove(selectionSquadCard);
 }
예제 #5
0
        public void ShowSquads(int worldIndex, int levelIndex)
        {
            WorldName.text = String.Concat(worldIndex + 1, ". ", WorldInfos.worldInfos[worldIndex].name);
            LevelName.text = "Level " + (levelIndex + 1);
            LevelsInfos infos = LevelsInfos.getLevelInfos(worldIndex, levelIndex);

            int length = lines.Count;
            int i      = 0;

            for (i = length - 1; i >= 0; i--)
            {
                Destroy(lines[i]);
                lines.RemoveAt(i);
            }

            for (i = 0; i < squadCards.Count; i++)
            {
                squadCards[i].OnSelected -= SelectionSquadCard_OnSelected;
            }

            hadBestSquad = false;

            GameObject line          = Instantiate(LinePrefab, AllSquadsPanel.transform);
            GameObject bestLineSquad = Instantiate(LinePrefab, BestSquadPanel.transform);

            lines.Add(line);
            lines.Add(bestLineSquad);
            GameObject squadCard;

            sortedSquads     = new List <List <Squad> >();
            selectedSquads   = new List <SelectionSquadCard>();
            selectedPatterns = new List <SquadPattern>();
            squadCards       = new List <SelectionSquadCard>();

            List <Squad> squads = GameManager.PlayerDatas.squads;

            length = squads.Count;
            Squad squad;

            int maxLevel = 0;

            for (i = 0; i < length; i++)
            {
                if (maxLevel < squads[i].level)
                {
                    maxLevel = squads[i].level;
                }
            }

            for (i = 0; i < maxLevel; i++)
            {
                sortedSquads.Add(new List <Squad>());
            }

            for (i = 0; i < length; i++)
            {
                sortedSquads[squads[i].level - 1].Add(squads[i]);
            }

            int internalLength           = 0;
            int howManySquadsInLines     = 0;
            int howManyBestSquadsInLines = 0;
            SelectionSquadCard selectionSquadCard;

            for (i = maxLevel - 1; i >= 0; i--)
            {
                internalLength = sortedSquads[i].Count;

                for (int j = internalLength - 1; j >= 0; j--)
                {
                    squad = sortedSquads[i][j];
                    if (SquadPattern.GetSquadPattern(squad.name, squad.level).name == infos.bestSquadName)
                    {
                        hadBestSquad = true;
                        if (howManyBestSquadsInLines % 4 == 0 && howManyBestSquadsInLines != 0)
                        {
                            bestLineSquad = Instantiate(LinePrefab, BestSquadPanel.transform);
                            lines.Add(bestLineSquad);
                            howManyBestSquadsInLines = 1;
                        }
                        else
                        {
                            howManyBestSquadsInLines++;
                        }

                        squadCard = Instantiate(SelectionSquadCardPrefab, bestLineSquad.transform);
                    }
                    else
                    {
                        if (howManySquadsInLines % 4 == 0 && howManySquadsInLines != 0)
                        {
                            line = Instantiate(LinePrefab, AllSquadsPanel.transform);
                            lines.Add(line);
                            howManySquadsInLines = 1;
                        }
                        else
                        {
                            howManySquadsInLines++;
                        }

                        squadCard = Instantiate(SelectionSquadCardPrefab, line.transform);
                    }

                    selectionSquadCard = squadCard.GetComponent <SelectionSquadCard>();
                    selectionSquadCard.InitCard(SquadPattern.GetSquadPattern(squad.name, squad.level), squad);
                    selectionSquadCard.OnSelected   += SelectionSquadCard_OnSelected;
                    selectionSquadCard.OnDeSelected += SelectionSquadCard_OnDeSelected;
                    squadCards.Add(selectionSquadCard);
                    LayoutRebuilder.ForceRebuildLayoutImmediate(BestSquadPanel.GetComponentInParent <RectTransform>());
                }
            }

            BestSquadPanel.SetActive(hadBestSquad);
        }