Example #1
0
        public void begin(int _roadnum, int _roadlen)
        {
            try
            {
                if (status != RHStatus.None)
                {
                    return;
                }
                //horses = _horses;
                //showScene = handle;
                //getQQNick = getqq;
                roadnum = _roadnum;
                roadlen = _roadlen;
                roads.Clear();
                bets.Clear();
                initHorses(context.getHorseInfos());
                status           = RHStatus.Bet;
                nowTime          = 0;
                skillDescription = "";


                raceLoopThread = new Thread(raceLoop);
                run            = true;
                raceLoopThread.Start();
            }
            catch (Exception ex)
            {
                FileHelper.Log(ex);
            }
        }
Example #2
0
        /// <summary>
        /// 进行下一帧
        /// </summary>
        public void runNextFrame()
        {
            try
            {
                switch (status)
                {
                case RHStatus.None:
                    //  未开始
                    return;

                case RHStatus.Bet:
                    // 下注中
                    if (nowTime == 0)
                    {
                        // 输出马的介绍信息
                        string s = "";
                        s += $"现在是赛🐎比赛下注时间,请下注您看好的马(输入赛道对应数字)。比赛将于{betWaitTime}秒后自动开始\r\n";
                        //showScene(id, -1, s);
                        //s = "";
                        foreach (var road in roads.Values)
                        {
                            s += $"{road.num}号:{road.horse.emoji} {road.horse.name}\r\n";
                        }
                        context.showMessage(id, -1, s);
                    }
                    else if (nowTime >= betWaitTime)
                    {
                        status  = RHStatus.Run;
                        nowTime = 0;
                    }
                    break;

                case RHStatus.Run:
                    // 比赛中
                    if (nowTime == 1)
                    {
                        // 输出比赛开始场景,初始化各赛道

                        context.showMessage(id, -1, "赛🐎比赛正式开始!!");
                        context.showMessage(id, -1, getMatchScene());
                    }
                    else if (nowTime >= turnWaitTime)
                    {
                        nextLoop();
                        context.showMessage(id, -1, getMatchScene());
                        if (winnerRoad > 0)
                        {
                            status = RHStatus.End;
                            context.showMessage(id, -1, $"比赛结束!{winnerRoad}号马赢了!");
                            context.showMessage(id, -1, calBetResult(winnerRoad));
                            winnerRoad = -1;
                        }
                        nowTime = 1;
                    }
                    break;

                case RHStatus.End:
                    // 比赛结束
                    // 重置
                    status  = 0;
                    nowTime = 0;
                    run     = false;
                    break;

                default:
                    break;
                }
                nowTime += 1;
            }
            catch (Exception ex)
            {
                FileHelper.Log(ex);
            }
        }