示例#1
0
        public int Compare(int a, int b)
        {
            TournamentConfig ta = ConfigData.GetTournamentConfig(a);
            TournamentConfig tb = ConfigData.GetTournamentConfig(b);

            return(ta.ApplyDate.CompareTo(tb.ApplyDate));
        }
示例#2
0
    private IEnumerator PopulateRewards()
    {
        yield return(null);

        base.transform.DestroyChildrenImmediate();
        TournamentConfig config = Singleton <EconomyHelpers> .Instance.GetTournamentPriceBracket(Singleton <TournamentRunner> .Instance.PlayerRank.Value);

        Dictionary <string, object> pars = new Dictionary <string, object>();

        for (int i = 0; i < 3; i++)
        {
            if (config.Rewards[i] == null)
            {
                continue;
            }
            string prefabPath = GetPrefabPath(config.Rewards[i].Type);
            if (prefabPath != string.Empty)
            {
                int num = config.Rewards[i].Amount.ToInt();
                if (num > 0)
                {
                    pars.Clear();
                    pars.Add("IntValue", num);
                    GameObject gameObject = Singleton <PropertyManager> .Instance.InstantiateFromResources(prefabPath, Vector3.zero, Quaternion.identity, pars);

                    gameObject.transform.SetParent(base.transform, worldPositionStays: false);
                }
            }
        }
    }
示例#3
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            config = new TournamentConfig("flex.cfg");
            string osuPath = config.GetOrDef("OsuPath", string.Empty);

            // Select a path to an osu! executable
            if (osuPath == string.Empty)
            {
                MessageBox.Show("You have to select a path to the osu!.exe which will be used to start the clients\n\n" +
                                "It is recommanded to not use your default installation", "Information");
                using (var o = new OpenFileDialog())
                {
                    o.Filter = "osu! executable|osu!.exe";
                    var res = o.ShowDialog();
                    // If no osu!.exe was selected, close
                    if (res != DialogResult.OK)
                    {
                        return;
                    }
                    osuPath = o.FileName;
                }

                config.Set("OsuPath", osuPath);
                config.SaveAsync().ContinueWith((t) => FlexLogger.Log($"Configuration save terminated with status {t.Status}"));
            }

            Application.Run(new MainForm(osuPath));
        }
示例#4
0
        public void Award()
        {
            List <int[]>     ranks            = GetRanks();
            TournamentConfig tournamentConfig = ConfigData.GetTournamentConfig(Id);

            for (int i = 0; i < tournamentConfig.Awards.Length; i++)
            {
                UserProfile.InfoWorld.UpdatePeopleRank(ranks[i][0], tournamentConfig.Awards[i]);
            }

            for (int i = 0; i < tournamentConfig.Resource.Count; i++)
            {
                if (ranks[i][0] == -1)
                {
                    if (tournamentConfig.Resource[i].Id == 99)
                    {
                        UserProfile.InfoBag.AddDiamond(tournamentConfig.Resource[i].Value);
                    }
                    else
                    {
                        UserProfile.InfoBag.AddResource((GameResourceType)tournamentConfig.Resource[i].Id,
                                                        (uint)tournamentConfig.Resource[i].Value);
                    }
                }
            }

            Engage = false;
        }
示例#5
0
        public DbTournamentData(int tid)
        {
            Id = tid;
            TournamentConfig tournamentConfig = ConfigData.GetTournamentConfig(tid);

            Pids    = new int[tournamentConfig.PlayerCount];
            Results = new MatchResult[tournamentConfig.MatchCount];
        }
示例#6
0
        private void TourLeague4_Paint(object sender, PaintEventArgs e)
        {
            if (show)
            {
                Font             font             = new Font("宋体", 11 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel);
                TournamentConfig tournamentConfig = ConfigData.GetTournamentConfig(tid);
                foreach (int mid in TournamentBook.GetTournamentMatchIds(tid))
                {
                    TournamentMatchConfig tournamentMatchConfig = ConfigData.GetTournamentMatchConfig(mid);
                    Image head = MatchManager.GetHeadImage(tourData.Pids[tournamentMatchConfig.LeftValue]);
                    if (head != null)
                    {
                        e.Graphics.DrawImage(head, 10 + (36 - headSize) / 2, gridSize * tournamentMatchConfig.Offset + 10 + (36 - headSize) / 2, headSize, headSize);
                    }
                    Brush nbrush = new SolidBrush(MatchManager.GetNameColor(tourData.Results[tournamentMatchConfig.Offset].Winner, tourData.Pids[tournamentMatchConfig.LeftValue]));
                    e.Graphics.DrawString(MatchManager.GetPlayerName(tourData.Pids[tournamentMatchConfig.LeftValue]), font, nbrush, 50, gridSize * tournamentMatchConfig.Offset + 25);
                    nbrush.Dispose();

                    head = MatchManager.GetHeadImage(tourData.Pids[tournamentMatchConfig.RightValue]);
                    if (head != null)
                    {
                        e.Graphics.DrawImage(head, 210 + (36 - headSize) / 2, gridSize * tournamentMatchConfig.Offset + 10 + (36 - headSize) / 2, headSize, headSize);
                    }
                    nbrush = new SolidBrush(MatchManager.GetNameColor(tourData.Results[tournamentMatchConfig.Offset].Winner, tourData.Pids[tournamentMatchConfig.RightValue]));
                    e.Graphics.DrawString(MatchManager.GetPlayerName(tourData.Pids[tournamentMatchConfig.RightValue]), font, nbrush, 250, gridSize * tournamentMatchConfig.Offset + 25);
                    nbrush.Dispose();

                    if (tourData.Results[tournamentMatchConfig.Offset].Winner != 0)
                    {
                        e.Graphics.DrawString(tourData.Results[tournamentMatchConfig.Offset].Winner == tourData.Pids[tournamentMatchConfig.LeftValue] ? "胜" : "负", font, Brushes.White, 143, gridSize * tournamentMatchConfig.Offset + 25);
                    }
                }

                List <int[]> ranks = tourData.GetRanks();
                Brush        brush = new SolidBrush(Color.FromArgb(15, 15, 15));
                e.Graphics.FillRectangle(brush, 340, 53, 165, 200);
                brush.Dispose();
                e.Graphics.DrawRectangle(Pens.Gray, 340, 53, 165, tournamentConfig.PlayerCount * 50);
                e.Graphics.DrawLine(Pens.Gray, 400, 53, 400, 53 + tournamentConfig.PlayerCount * 50);
                for (int i = 0; i < tournamentConfig.PlayerCount - 1; i++)
                {
                    e.Graphics.DrawLine(Pens.Gray, 340, 103 + 50 * i, 505, 103 + 50 * i);
                }
                for (int i = 0; i < tournamentConfig.PlayerCount; i++)
                {
                    Image head = MatchManager.GetHeadImage(ranks[i][0]);
                    if (head != null)
                    {
                        e.Graphics.DrawImage(head, 350, 50 * i + 60, 36, 36);
                        e.Graphics.DrawString(string.Format("{0}战 {1}胜 {2}分", ranks[i][1], ranks[i][2], ranks[i][3]), font, Brushes.White, 410, 50 * i + 75);
                    }
                }

                font.Dispose();
            }
        }
示例#7
0
        private void buttonEngage_Click(object sender, EventArgs e)
        {
            TournamentConfig tournamentConfig = ConfigData.GetTournamentConfig(tid);

            if (UserProfile.InfoBasic.Level < tournamentConfig.MinLevel || UserProfile.InfoBasic.Level > tournamentConfig.MaxLevel)
            {
                return;
            }
            UserProfile.InfoWorld.GetTournamentData(tid).Engage = true;
            buttonEngage.Visible = false;
            Invalidate();
        }
示例#8
0
 private void listViewMethods_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewMatchs.SelectedIndices.Count > 0)
     {
         tid = int.Parse(listViewMatchs.SelectedItems[0].Tag.ToString());
         if (tid == 0)
         {
             viewStack1.SelectedIndex = 3;
             tourRankList1.Init();
             buttonEngage.Visible = false;
             pictureBox1.Visible  = false;
         }
         else
         {
             TournamentConfig tournamentConfig = ConfigData.GetTournamentConfig(tid);
             if (tournamentConfig.Type == TournamentTypes.Cup8)
             {
                 viewStack1.SelectedIndex = 0;
                 tourCup81.Init(tid);
             }
             else if (tournamentConfig.Type == TournamentTypes.League4)
             {
                 viewStack1.SelectedIndex = 1;
                 tourLeague41.Init(tid);
             }
             else if (tournamentConfig.Type == TournamentTypes.Cup16)
             {
                 viewStack1.SelectedIndex = 2;
                 tourCup161.Init(tid);
             }
             else
             {
                 return;
             }
             //if (tour.apply_date != UserProfile.Profile.time.Date)
             //    buttonEngage.Visible = false;
             //else if (UserProfile.MemData.GetTournamentData(tid).engage)
             //    buttonEngage.Visible = false;
             //else if (UserProfile.Profile.level < tour.min_level || UserProfile.Profile.level > tour.max_level)
             //    buttonEngage.Visible = false;
             //else
             //    buttonEngage.Visible = true;
             pictureBox1.Image   = HSIcons.GetIconsByEName(tournamentConfig.Icon);
             pictureBox1.Visible = true;
         }
         Invalidate();
     }
 }
示例#9
0
    public static List <TournamentConfig> ParseTournaments(string text)
    {
        List <RewardEnum>      rewardTypes = ParseRewardTypes(text);
        IEnumerable <string[]> source      = TSVParser.Parse(text + "\t").Skip(1);

        return(source.Select(delegate(string[] line)
        {
            TournamentConfig tournamentConfig = new TournamentConfig
            {
                Rank = line.asInt(0, line.toError <int>())
            };
            tournamentConfig.Rewards[0] = new RewardData(rewardTypes[0], line.asBigDouble(1, line.toError <BigDouble>()));
            tournamentConfig.Rewards[1] = new RewardData(rewardTypes[1], line.asBigDouble(2, line.toError <BigDouble>()));
            tournamentConfig.Rewards[2] = new RewardData(rewardTypes[2], line.asBigDouble(3, line.toError <BigDouble>()));
            return tournamentConfig;
        }).ToList());
    }
示例#10
0
        public void CheckMatch(int mid, bool autoGiveup)
        {
            TournamentConfig tournamentConfig = ConfigData.GetTournamentConfig(Id);

            TournamentMatchConfig match = ConfigData.GetTournamentMatchConfig(mid);
            int left;
            int right;

            if (match.LeftType == 1)
            {
                left = Pids[match.LeftValue];
            }
            else
            {
                left = Results[match.LeftValue].Winner;
            }
            if (match.RightType == 1)
            {
                right = Pids[match.RightValue];
            }
            else
            {
                right = Results[match.RightValue].Winner;
            }

            currentMid        = mid;
            currentAutoGiveUp = autoGiveup;
            currentRvId       = left == -1 ? right : left;

            Results[mid] = new MatchResult();
            if (left != -1 && right != -1)
            {
                FastBattle.Instance.StartGame(left, right, tournamentConfig.Map, -1);
                Results[mid].Winner = FastBattle.Instance.LeftWin ? left : right;
                Results[mid].Loser  = FastBattle.Instance.LeftWin ? right : left;
            }
            else
            {
                PeopleBook.Fight(currentRvId, tournamentConfig.Map, 1, new PeopleFightParm(), OnWin, OnLose, null);
            }
        }
示例#11
0
    protected void Start()
    {
        base.transform.DestroyChildrenImmediate();
        ParameterRunner parameterRunner = (ParameterRunner)Singleton <PropertyManager> .Instance.GetContext("ParameterRunner", base.transform);

        TournamentConfig tournamentPriceBracket = Singleton <EconomyHelpers> .Instance.GetTournamentPriceBracket(parameterRunner.IntValue.Value);

        Dictionary <string, object> dictionary = new Dictionary <string, object>();

        for (int i = 0; i < 3; i++)
        {
            if (tournamentPriceBracket.Rewards[i] != null)
            {
                dictionary.Clear();
                dictionary.Add("IntValue", tournamentPriceBracket.Rewards[i].Amount.ToInt());
                GameObject gameObject = Singleton <PropertyManager> .Instance.InstantiateFromResources(GetPrefabPath(tournamentPriceBracket.Rewards[i].Type), Vector3.zero, Quaternion.identity, dictionary);

                gameObject.transform.SetParent(base.transform, worldPositionStays: false);
            }
        }
    }
示例#12
0
        public void Init(int id)
        {
            show = true;

            tid      = id;
            tourData = UserProfile.InfoWorld.GetTournamentData(id);

            TournamentConfig tournamentConfig = ConfigData.GetTournamentConfig(tid);

            if (tournamentConfig.PlayerCount > 4)
            {
                headSize = 24;
                gridSize = 36;
            }
            else
            {
                headSize = 36;
                gridSize = 50;
            }
            if (buttons != null)
            {
                foreach (Button button in buttons)
                {
                    Controls.Remove(button);
                }
            }
            buttons = new Button[tournamentConfig.MatchCount];
            for (int i = 0; i < tournamentConfig.MatchCount; i++)
            {
                Button btn = MatchManager.GetButton(i, 116, 18 + gridSize * i);
                btn.Click += new EventHandler(button1_Click);
                Controls.Add(btn);
                buttons[i] = btn;
            }

            RefreshButtons();

            Height = Math.Max(410, tournamentConfig.MatchCount * gridSize);
            Invalidate();
        }
示例#13
0
        public override void Init(int width, int height)
        {
            base.Init(width, height);
            ListViewItem lvm1 = new ListViewItem("总积分榜");

            lvm1.Tag       = "0";
            lvm1.ForeColor = Color.Orange;
            listViewMatchs.Items.Add(lvm1);
            int[] tournamentIds = new int[ConfigData.TournamentDict.Count];
            int   index         = 0;

            foreach (int key in ConfigData.TournamentDict.Keys)
            {
                tournamentIds[index++] = key;
            }
            Array.Sort(tournamentIds, new CompareTournamentByADay());

            foreach (int tournamentId in tournamentIds)
            {
                TournamentConfig tournamentConfig = ConfigData.GetTournamentConfig(tournamentId);

                ListViewItem lvm = new ListViewItem(tournamentConfig.Name);
                lvm.Tag = tournamentConfig.Id.ToString();
                // Tournament tour = TournamentBook.GetTournament(tournament.id);
                //if (tour.apply_date == UserProfile.Profile.time.Date)
                //{
                //    lvm.ForeColor = Color.Red;
                //    lvm.Text = lvm.Text + @"(报名中)";
                //}
                //else if (tour.begin_date <= UserProfile.Profile.time.Date && tour.end_date >= UserProfile.Profile.time.Date)
                //{
                //    lvm.ForeColor = Color.Lime;
                //    lvm.Text = lvm.Text + @"(比赛中)";
                //}
                listViewMatchs.Items.Add(lvm);
            }
            listViewMatchs.SelectedIndices.Add(0);
        }
示例#14
0
    public void ClaimTournamentPrice()
    {
        int tournamentID = PlayerData.Instance.TournamentIdCurrent.Value;

        PersistentSingleton <PlayFabService> .Instance.LoggedOnPlayerId.Take(1).Subscribe(delegate
        {
            UploadTournamentRun(tournamentID);
        }).AddTo(SceneLoader.Instance);

        PlayerHighestWorld.Value = PlayerData.Instance.TournamentRun.Value[PlayerData.Instance.TournamentRun.Value.Length - 1];
        BindingManager.Instance.TournamentRewardsClaimingParent.ShowInfo();
        if (PersistentSingleton <GameAnalytics> .Instance != null)
        {
            PersistentSingleton <GameAnalytics> .Instance.TournamentEvent.SetValueAndForceNotify(value : false);
        }
        TournamentConfig tournamentPriceBracket = Singleton <EconomyHelpers> .Instance.GetTournamentPriceBracket(PlayerRank.Value);

        for (int i = 0; i < tournamentPriceBracket.Rewards.Length; i++)
        {
            if (tournamentPriceBracket.Rewards[i] == null)
            {
                continue;
            }
            if (tournamentPriceBracket.Rewards[i].Type == RewardEnum.AddToBerries)
            {
                for (int j = 0; j < tournamentPriceBracket.Rewards[i].Amount; j++)
                {
                    RewardFactory.ToRewardAction(new RewardData(RewardEnum.AddToBerries, 1L), RarityEnum.Common, Singleton <EconomyHelpers> .Instance.GetNumUnlockedHeroes(PlayerData.Instance.LifetimeChunk.Value)).GiveReward();
                }
            }
            else
            {
                RewardFactory.ToRewardAction(tournamentPriceBracket.Rewards[i], RarityEnum.Common).GiveReward();
            }
        }
        ResetTournamentValues();
    }
示例#15
0
        public static Image GetPreview(int id)
        {
            TournamentConfig tournamentConfig = ConfigData.GetTournamentConfig(id);

            int[]         awardData    = tournamentConfig.Awards;
            RLIdValueList resourceData = tournamentConfig.Resource;

            int wid = 175;
            int heg = awardData.Length * 16;

            wid += 5; heg += 5;
            heg += 16 * 4 + 50;
            Bitmap   bmp = new Bitmap(wid, heg);
            Graphics g   = Graphics.FromImage(bmp);

            g.FillRectangle(Brushes.Black, 0, 0, wid, heg);
            g.FillRectangle(new SolidBrush(Color.FromArgb(30, 30, 30)), 0, 0, wid, 18);
            Pen pen = new Pen(Brushes.Gray, 2);

            g.DrawRectangle(pen, 1, 1, wid - 3, heg - 3);
            pen.Dispose();

            int  y         = 3;
            Font fontsong  = new Font("宋体", 9 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel);
            Font fontsongB = new Font("宋体", 9 * 1.33f, FontStyle.Bold, GraphicsUnit.Pixel);

            g.DrawString("赛事名", fontsongB, Brushes.LightGray, 3, y);
            g.DrawString(tournamentConfig.Name, fontsong, Brushes.White, 53, y);
            y += 16;
            g.DrawString("比赛时间", fontsongB, Brushes.LightGray, 3, y);

            //     g.DrawString(string.Format("{0}-{1}", HSTime.GetByDate(begin_date).ToShortString(), HSTime.GetByDate(end_date).ToShortString()), fontsong, Brushes.LightGreen, 66, y);
            y += 16;
            g.DrawString("比赛地图", fontsongB, Brushes.LightGray, 3, y);
            Image mapback = BattleMapBook.GetMapImage(tournamentConfig.Map, TileConfig.Indexer.DefaultTile);

            g.DrawImage(mapback, new Rectangle(70, y, 100, 50), new Rectangle(0, 25, 100, 50), GraphicsUnit.Pixel);
            mapback.Dispose();
            y += 50;
            g.DrawString("等级限制", fontsongB, Brushes.LightGray, 3, y);
            g.DrawString(string.Format("{0}-{1}", tournamentConfig.MinLevel, tournamentConfig.MaxLevel), fontsong, Brushes.LightPink, 66, y);
            y += 16;
            g.DrawString("比赛奖励", fontsongB, Brushes.LightGray, 3, y);
            y += 16;
            for (int i = 0; i < awardData.Length; i++)
            {
                g.DrawString(string.Format("第{0}名 {1}积分", i + 1, awardData[i].ToString().PadLeft(2, ' ')), fontsong, Brushes.White, 33, y);
                if (i < resourceData.Count)
                {
                    if (resourceData[i].Id == 99)
                    {
                        g.DrawString(resourceData[i].Value.ToString().PadLeft(2, ' '), fontsong, Brushes.Cyan, 123, y);
                        g.DrawImage(HSIcons.GetIconsByEName("res8"), 143, y, 16, 16);
                    }
                    else
                    {
                        Brush brush = new SolidBrush(Color.FromName(HSTypes.I2ResourceColor(resourceData[i].Id)));
                        g.DrawString(resourceData[i].Value.ToString().PadLeft(2, ' '), fontsong, brush, 123, y);
                        g.DrawImage(HSIcons.GetIconsByEName("res" + (resourceData[i].Id + 1)), 143, y, 14, 14);
                        brush.Dispose();
                    }
                }
                y += 16;
            }
            fontsong.Dispose();
            fontsongB.Dispose();
            g.Dispose();
            return(bmp);
        }