예제 #1
0
        /// <summary>
        /// Create components do display the statistics of the model used
        /// </summary>
        /// <param name="panelName">Name of the current panel to contstruct</param>
        /// <param name="offsetWidth">Offset by which all components will be shifted (position)</param>
        /// <param name="idAssociatePlayerScreen">Index of associate player screen, Usefull for split screen menu</param>
        public void CreateTextModelsStats(string panelName, int offsetWidth = 0, int idAssociatePlayerScreen = 0)
        {
            Vector2[] offsetStart = { new Vector2(950, 720), new Vector2(1150, 720) };

            // For each model create a list of stats
            for (int i = 0; i < ScenesCommunicationManager.ValuesStats.Length; ++i)
            {
                ListComponents listStats    = new ListComponents("model" + i.ToString() + "Stats");
                int            count        = 0;
                float          offsetHeight = 40;

                // Name of the stats
                foreach (string name in ScenesCommunicationManager.NameStats)
                {
                    var nameCapacity = new TextBox()
                    {
                        InitPos = offsetStart[0] + new Vector2(offsetWidth, count * offsetHeight),
                        Text    = name,
                    };
                    nameCapacity.Font   = UserInterface.menuSmallFont;
                    nameCapacity.Colour = new Color(148, 148, 148);
                    listStats.AddComponent(nameCapacity);
                    ++count;
                }

                // Capacity
                var statCapacity = new Slider(offsetStart[1] + new Vector2(offsetWidth, 0 * offsetHeight), TexturesButtons["slider"])
                {
                };
                statCapacity.lengthSlider    = 175;
                statCapacity.percentPosButon = ((float)ScenesCommunicationManager.ValuesStats[i].Capacity) / ((float)ScenesCommunicationManager.maxModelStats.Capacity);

                // Distance of attack
                var statAttack = new Slider(offsetStart[1] + new Vector2(offsetWidth, 1 * offsetHeight), TexturesButtons["slider"])
                {
                };
                statAttack.lengthSlider    = 175;
                statAttack.percentPosButon = ScenesCommunicationManager.ValuesStats[i].AttackDistance / ScenesCommunicationManager.maxModelStats.AttackDistance;

                // Speed
                var statSpeed = new Slider(offsetStart[1] + new Vector2(offsetWidth, 2 * offsetHeight), TexturesButtons["slider"])
                {
                };
                statSpeed.lengthSlider    = 175;
                statSpeed.percentPosButon = ScenesCommunicationManager.ValuesStats[i].MaxSpeed / ScenesCommunicationManager.maxModelStats.MaxSpeed;

                // Add to list of stat for the current model
                listStats.AddComponent(statCapacity);
                listStats.AddComponent(statAttack);
                listStats.AddComponent(statSpeed);

                if (i != 0)
                {
                    listStats.Active = false;
                }

                // Add list to current panel
                MenuManager.Instance.MenuRect[panelName].AddComponent(listStats);
            }
        }
예제 #2
0
        /// <summary>
        /// Create components to display the rankings
        /// </summary>
        public void LoadRankingsText()
        {
            ListComponents rankings = new ListComponents("rankings_game");

            Vector2[] offsetStart = { new Vector2(864, 320), new Vector2(1056, 320) };

            int i = 0;

            // Create list of components for each combinaison of (#players <-> duration of a round)
            foreach (var noPlayers in MenuManager.Instance.RankingPlayersText)
            {
                foreach (var durationRound in MenuManager.Instance.RankingDurationText)
                {
                    List <Tuple <string, string> > rankinglist = File.ReadRanking("ranking" + durationRound + noPlayers + ".txt"); //File.ReadRanking("Load /Rankings/ranking" + durationRound + noPlayers + ".txt");

                    ListComponents listPersons = new ListComponents("ranking" + durationRound + noPlayers);
                    int            count       = 0;

                    // Text component with player's name and score
                    foreach (var aPerson in rankinglist)
                    {
                        var namePerson = new TextBox()
                        {
                            InitPos = offsetStart[0] + new Vector2(0, count * 40),
                            Text    = aPerson.Item1
                        };
                        namePerson.Font = UserInterface.menuSmallFont;

                        var score = new TextBox()
                        {
                            InitPos = offsetStart[1] + new Vector2(0, count * 40),
                            Text    = aPerson.Item2
                        };
                        score.Font = UserInterface.menuSmallFont;

                        // Add to list
                        listPersons.AddComponent(namePerson); listPersons.AddComponent(score);
                        count++;
                    }

                    if (i != 0)
                    {
                        listPersons.Active = false;
                    }
                    ++i;

                    rankings.AddComponent(listPersons);
                }
            }
            MenuManager.Instance.MenuRect["ranking"].AddComponent(rankings);
        }