Exemple #1
0
    //
    //Awake Function
    //

    void Start()
    {
        if (!isCreated)
        {
            //RandomNameGenerator Initialization
            RandomNameGenerator.SetNameList();

            //League Initialization
            Values.league = new League(true);

            //MyTeam Initailization
            Values.myTeam = Values.league.teams[0].Value;
            //Values.myTeam = Values.league.teams[UnityEngine.Random.Range(0, Values.league.teams.d.Count)].Value;

            //MyTeam schedule Initialization
            Values.schedules = new Dictionary <int, Schedule>();
            Values.league.BuildGameSchedule();

            //Date Init.
            DateManagement.ProceedDate();

            isCreated = true;
        }

        //DEBUG: sample data setup
        //Values.schedules = Values.sampleSchedules;
        ArrayToDict();
        //foreach(List<Schedule> ss in scheduleByDate.Values)
        //{
        //    foreach(Schedule s in ss)
        //    {
        //        Debug.Log(s.GetTitle());
        //    }
        //}

        //Values.myPlayers = RandomPlayerGenerator.CreateTeam();
        //Values.myStartingMembers = RandomPlayerGenerator.CreateStartingMember(Values.myTeam.players);

        //Set today's game.
        game = Values.league.FindGame(Values.date, Values.myTeam);

        //when loaded
        animator.SetBool("isLoaded", true);

        //Load data: schedules, counter
        //SaveData();
        //LoadData();

        //Inactivates menu panels
        playersPanel.SetActive(false);

        //Inactivates transition text.
        transitionTextObject.SetActive(false);

        //LeftPanel

        //DateText
        dateText.text = Values.date.ToString("MMM dd", CultureInfo.CreateSpecificCulture("en-US")) + ", " + Values.date.Year;

        //ScheduleList
        Values.myTeam.RefreshSchedule(Values.date, Values.league);

        bool noSchedules = true;

        for (DateTime d = new DateTime(Values.date.Year, Values.date.Month, Values.date.Day); (d - Values.date).Days < 14; d = d.AddDays(1))
        {
            //Checks whether the schedule exists
            if (Values.scheduleByDate.ContainsKey(d))
            {
                noSchedules = false;
                DateInstantiate(new Date(d));

                foreach (Schedule s in Values.scheduleByDate[d])
                {
                    ListInstantiate(s);
                    if (s.GetType() == typeof(Schedule_MatchUp) && s.date == Values.date)
                    {
                        isMatchUpToday = true;
                    }
                }
            }
        }

        //Shows "No Schedules" if there's no schdules at all.
        if (noSchedules)
        {
            DateInstantiate(new Date("No Schedules"));
        }

        //RIghtPanel

        //Components initially.
        dropdown.gameObject.SetActive(false);
        confirm.gameObject.SetActive(false);
        accentPanel.color = Color.white;

        //PlayersPanel
        RefreshPlayerList(Filter.Mode.ALL, SortDropdown.SortMode.OVERALL);
        skillPanel.SetActive(false);
        statisticsPanel.SetActive(false);
        roastersPanel.SetActive(false);
        trainingPanel.SetActive(false);

        //StatisticsPanel-GraphPanel
        SP_graphPanel.SetActive(false);
    }