Пример #1
0
        private void OnGenerateListOfMissions(MyGuiControlButton sender)
        {
            foreach(MyMissionID missionID in Enum.GetValues(typeof(MyMissionID))){
                MyMission mission = MyMissions.GetMissionByID(missionID) as MyMission;
                if (mission != null)
                {
                    if (!System.IO.Directory.Exists(MyFileSystemUtils.GetApplicationUserDataFolder() + "\\MissionTexts"))
                    {
                        System.IO.Directory.CreateDirectory(MyFileSystemUtils.GetApplicationUserDataFolder() + "\\MissionTexts");
                    }
                    using (System.IO.StreamWriter output = new System.IO.StreamWriter(System.IO.File.Open(MyFileSystemUtils.GetApplicationUserDataFolder() + "\\MissionTexts\\" + Enum.GetName(typeof(MyMissionID), missionID) + ".txt", System.IO.FileMode.Create)))
                    {
                        output.WriteLine("Mission: " + mission.DebugName);
                        output.WriteLine();
                        output.WriteLine("MyMissionID." + Enum.GetName(typeof(MyMissionID), mission.ID));
                        output.WriteLine("DebugName: \"" + mission.DebugName + "\"");
                        output.WriteLine("Name: \"" + mission.Name + "\"");
                        output.WriteLine("Description: \"" + mission.Description + "\"");
                        output.WriteLine();
                        output.WriteLine("Objectives:");

                        foreach(MyObjective objective in mission.Objectives){
                            output.WriteLine("MyMissionID." + Enum.GetName(typeof(MyMissionID), objective.ID));
                            output.WriteLine("Name: \"" + objective.Name + "\"");
                            output.WriteLine("Description: \"" + objective.Description + "\"");
                            output.WriteLine();
                        }

                        output.Flush();
                        output.Close();
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Server服务实例向Client服务实例Notify当前周期的Mission对象
        /// </summary>
        /// <returns></returns>
        public IEnumerator <ITask> MissionParaNotification()
        {
            // Notify all subscribers.
            MissionPara announce = new MissionPara();

            // 将当前仿真使命的通用Mission对象拷贝一份用于策略调用的参数传递
            Mission mission = (Mission)MyMission.Instance().MissionRef.Clone();

            for (int i = 0; i < mission.CommonPara.TeamCount; i++)
            {// 循环对每条仿真机器鱼施加图像处理干扰 LiYoubing 20110617
                for (int j = 0; j < mission.CommonPara.FishCntPerTeam; j++)
                {
                    RoboFish f = mission.TeamsRef[i].Fishes[j];
                    Interference.ImageProcessInterference(ref f.PositionMm, ref f.BodyDirectionRad,
                                                          f.VelocityMmPs, f.AngularVelocityRadPs);
                }
            }
            for (int i = 0; i < mission.EnvRef.Balls.Count; i++)
            {// 循环对所有仿真水球施加图像处理干扰 LiYoubing 20110617
                Ball  b   = mission.EnvRef.Balls[i];
                float tmp = 0;
                Interference.ImageProcessInterference(ref b.PositionMm, ref tmp, b.VelocityMmPs, b.AngularVelocityRadPs);
            }
            announce.Body = new MissionParaRequest(mission);
            //announce.Body = new MissionParaRequest(MyMission.Instance().MissionRef);//modified 20101203
            base.SendNotification(_submgrPort, announce);

            announce.ResponsePort.Post(DefaultUpdateResponseType.Instance);
            yield break;
        }
Пример #3
0
        /// <summary>
        /// 单鱼推球避障犯规判断
        /// </summary>
        /// <returns></returns>
        private void JudgeFoulingOnPushingBall()
        {
            MyMission myMission = MyMission.Instance();//当前仿真使命的信息

            CollisionType ballCollisionType = myMission.EnvRef.Balls[0].Collision;
            CollisionType fishCollisionType = myMission.TeamsRef[0].Fishes[0].Collision[0];

            if (collisionFlag == false)//3秒之内没有碰撞产生
            {
                //机器鱼与障碍物之间的碰撞
                if (fishCollisionType == CollisionType.FISH_OBSTACLE)
                {
                    collisionFishAndObstacles = true;
                    collisionFlag             = true;
                }
                //球与障碍物之间的碰撞
                else if (ballCollisionType == CollisionType.BALL_OBSTACLE)
                {
                    collisionBallAndObstacles = true;
                    collisionFlag             = true;
                }
            }
            else
            {
                if (CommonPara.RemainingCycles <= (presentCollisionCycle - escapeCollisionTime * 1000 / CommonPara.MsPerCycle))
                {
                    collisionFlag = false;
                }
            }
        }
Пример #4
0
        // Added by LiYoubing 20110518
        /// <summary>
        /// 处理得分即每个球门里仿真水球个数统计任务
        /// </summary>

        private void ScoreCalculationHandler()
        {
            MyMission myMission = MyMission.Instance();

            for (int i = 0; i < 6; i++)
            {
                if (IsBallInHole(i) && scores[i] == 0)
                {
                    scores[i] = 1;
                    ustime[i] = CommonPara.RemainingCycles;
                    string strMsg          = "";
                    int    Shootouttime    = CommonPara.TotalSeconds * 1000 - CommonPara.RemainingCycles * myMission.ParasRef.MsPerCycle;
                    int    ShootouttimeSec = Shootouttime / 1000;

                    strMsg += string.Format("Congradulations!Goal time is: {1:00}:{2:00}:{3:00}.",
                                            Teams[0].Para.Score, ShootouttimeSec / 60, ShootouttimeSec % 60, Shootouttime % 1000);
                    MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef, strMsg,
                                                  "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    lasttime = ustime[i];
                }
            }
            int count = 0;

            for (int i = 0; i < 6; i++)
            {
                if (scores[i] == 1)
                {
                    count++;
                }
            }
            for (int i = 0; i < myMission.TeamsRef.Count; i++)
            {// 更新左/右半场队伍的得分
                myMission.TeamsRef[i].Para.Score = count;
            }
        }
Пример #5
0
        /// <summary>
        /// 单鱼推球过程中的数据记录,记录完成第一次完成各个单程的时间,及共完成单程的个数
        /// </summary>
        private void DataProcessingOnPushingBall()
        {
            MyMission myMission = MyMission.Instance();//当前仿真使命的信息
            FishSingleFishPushBallAvoidObstacles fish = Teams[0].Fishes[0];

            Ball ball = myMission.EnvRef.Balls[0];

            //记录完成每个单程的时间和完成的单程数目
            if ((fish.PositionMm.X > (myMission.EnvRef.ObstaclesRect[0].PositionMm.X + fish.BodyLength) && (finishedCountOneWay == 0)))
            {//判断完成第一次完成第一个单程
                finshedTimeOneWay[0] = myMission.ParasRef.TotalSeconds - myMission.ParasRef.RemainingCycles / myMission.ParasRef.MsPerCycle;
                finishedCountOneWay  = 1;
            }
            else if ((fish.PositionMm.X > (myMission.EnvRef.ObstaclesRect[9].PositionMm.X + fish.BodyLength) && (finishedCountOneWay == 1)))
            {//判断完成第一次完成第二个单程
                finshedTimeOneWay[1] = myMission.ParasRef.TotalSeconds - myMission.ParasRef.RemainingCycles / myMission.ParasRef.MsPerCycle;;
                finishedCountOneWay  = 2;
            }
            else if ((fish.PositionMm.X < (myMission.EnvRef.ObstaclesRect[9].PositionMm.X - fish.BodyLength) && (finishedCountOneWay == 2)) &&
                     (ball.PositionMm.X < (myMission.EnvRef.ObstaclesRect[9].PositionMm.X - ball.RadiusMm * 2)))
            {//判断完成第一次完成第三个单程
                finshedTimeOneWay[2] = myMission.ParasRef.TotalSeconds - myMission.ParasRef.RemainingCycles / myMission.ParasRef.MsPerCycle;;
                finishedCountOneWay  = 3;
            }
            else if ((fish.PositionMm.X < (myMission.EnvRef.ObstaclesRect[0].PositionMm.X - fish.BodyLength) && (finishedCountOneWay == 3)) &&
                     (ball.PositionMm.X < (myMission.EnvRef.ObstaclesRect[0].PositionMm.X - ball.RadiusMm * 2)))
            {//判断完成第一次完成第四个单程
                finshedTimeOneWay[3] = myMission.ParasRef.TotalSeconds - myMission.ParasRef.RemainingCycles / myMission.ParasRef.MsPerCycle;;
                finishedCountOneWay  = 4;
            }
        }
Пример #6
0
        // Added by LiYoubing 20110518
        /// <summary>
        /// 处理得分即每个球门里仿真水球个数统计任务
        /// </summary>
        private void ScoreCalculationHandler()
        {
            MyMission myMission = MyMission.Instance();

            // 当前仿真周期上下球门里仿真水球数量
            int[] ballsCount = { 0, 0 };
            for (int i = 0; i < Env.Balls.Count; i++)
            {
                if (IsBallInSpecialGoal(Env.Balls[i], true) == true)
                {// 仿真水球在上方球门内
                    ballsCount[0]++;
                }
                else if (IsBallInSpecialGoal(Env.Balls[i], false) == true)
                {// 仿真水球在下方球门内
                    ballsCount[1]++;
                }
            }
            for (int i = 0; i < myMission.TeamsRef.Count; i++)
            {// 更新左/右半场队伍的得分
                myMission.TeamsRef[i].Para.Score = ballsCount[i];
            }
            if (CompetitionPeriod == (int)MatchHelper.CompetitionPeriod.ClutchShotTime)
            {                                     // 制胜球阶段
                if (Teams[0].Para.Score != Teams[1].Para.Score)
                {                                 // 双方得分不同,决出胜负
                    CommonPara.IsRunning = false; //比赛停止
                    int winner = (Teams[0].Para.Score > Teams[1].Para.Score) ? 0 : 1;
                    MessageBox.Show(string.Format("Congradulations!\nCompetition is completed.\nWinner:【{0}】 in 【{1}】\n",
                                                  Teams[winner].Para.Name, Teams[winner].Para.MyHalfCourt),
                                    "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// 防守机器鱼在禁区内犯规时最大停留时间(单位:毫秒)
        /// </summary>
        #endregion

        #region 对抗赛5VS5仿真使命控制规则具体处理过程

        #region 进球判断及处理


        // Added by renjing 20110310 Modified by LiYoubing 20110515
        /// <summary>
        /// 进球处理
        /// </summary>
        private void GoalHandler()
        {
            MyMission mymission = MyMission.Instance();
            int       j;

            if (CommonPara.IsExchangedHalfCourt == false)
            {
                RoboFish f1 = Teams[0].Fishes[0];
                for (j = 1; j < 4; j++)
                {
                    RoboFish f2 = Teams[1].Fishes[j];
                    CollisionDetectionResult result = new CollisionDetectionResult();
                    result = CollisionDetection.DetectCollisionBetweenTwoFishes(ref f1, ref f2);
                    if (result.Intersect == true && gool[j - 1] == 0)
                    {
                        Teams[0].Para.Score++;
                        gool[j - 1] = 1;
                        string strMsg          = "";
                        int    Shootouttime    = CommonPara.TotalSeconds * 1000 - CommonPara.RemainingCycles * mymission.ParasRef.MsPerCycle;
                        int    ShootouttimeSec = Shootouttime / 1000;
                        ltime   = Shootouttime;
                        strMsg += string.Format("Congradulations!shootouttime is: {1:00}:{2:00}:{3:00}.",
                                                Teams[0].Para.Score, ShootouttimeSec / 60, ShootouttimeSec % 60, Shootouttime % 1000);
                        MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef, strMsg,
                                                      "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            else
            {
                RoboFish f1 = Teams[1].Fishes[0];
                for (j = 1; j < 4; j++)
                {
                    RoboFish f2 = Teams[0].Fishes[j];
                    CollisionDetectionResult result = new CollisionDetectionResult();
                    result = CollisionDetection.DetectCollisionBetweenTwoFishes(ref f1, ref f2);
                    if (result.Intersect == true && goor[j - 1] == 0)
                    {
                        Teams[1].Para.Score++;
                        goor[j - 1] = 1;
                        string strMsg          = "";
                        int    Shootouttime    = CommonPara.TotalSeconds * 1000 / 2 - CommonPara.RemainingCycles * mymission.ParasRef.MsPerCycle;
                        int    ShootouttimeSec = Shootouttime / 1000;
                        rtime   = Shootouttime;
                        strMsg += string.Format("Congradulations!shootouttime is: {1:00}:{2:00}:{3:00}.",
                                                Teams[0].Para.Score, ShootouttimeSec / 60, ShootouttimeSec % 60, Shootouttime % 1000);
                        MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef, strMsg,
                                                      "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            if (CommonPara.IsExchangedHalfCourt == false && Teams[0].Para.Score == 3)
            {
                CommonPara.RemainingCycles = CommonPara.TotalSeconds * 1000 / CommonPara.MsPerCycle / 2;
            }
            else if (CommonPara.IsExchangedHalfCourt == true && Teams[1].Para.Score == 3)
            {
                CommonPara.RemainingCycles = 0;
            }
        }
Пример #8
0
        // Added by LiYoubing 20110515
        /// <summary>
        /// 处理某支队伍进球的情况
        /// </summary>
        /// <param name="team">待处理的仿真使命参与队伍(仿真机器鱼为具体使命的仿真机器鱼)</param>
        /// <param name="bIsLeftHalfCourt">待判断的是否左球门true判断左球门false判断右球门</param>
        private void GoalHandler(ref Team <Fish1V1> team, bool bIsLeftHalfCourt)
        {
            MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef,
                                          string.Format("Congradulations! \nGoaled:【{0}】 in 【{1}】\n",
                                                        team.Para.Name, team.Para.MyHalfCourt),
                                          "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            for (int i = 0; i < CommonPara.TeamCount; i++)
            {// 解除犯规状态
                for (int j = 0; j < CommonPara.FishCntPerTeam; j++)
                {
                    team.Fishes[j].FoulFlag           = FoulType.NONE;
                    team.Fishes[j].CountCyclesFouled  = 0;
                    team.Fishes[j].CountInOwnGoalArea = 0;
                }
            }

            if (CommonPara.IsRunning == true)
            {                      // 仿真使命运行完毕后Restart之前可以重复按Pause/Continue按钮弹出提示对话框但不必重复计分
                team.Para.Score++; // 累积得分
            }
            if (CompetitionPeriod == (int)MatchHelper.CompetitionPeriod.ClutchShotTime ||
                CompetitionPeriod == (int)MatchHelper.CompetitionPeriod.PenaltyKickTime)
            {// 在点球大战和制胜球阶段进球,比赛结束
                CommonPara.IsRunning = false;
                MessageBox.Show(string.Format("Congradulations!\nCompetition is completed.\nWinner:【{0}】 in 【{1}】\n",
                                              team.Para.Name, team.Para.MyHalfCourt),
                                "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {// 恢复默认场景
                ResetTeamsAndFishes();
                ResetBalls();
                ResetSomeLocomotionPara();
            }
        }
Пример #9
0
        // Added by LiYoubing 20110515
        /// <summary>
        /// 处理某支队伍在己方半场的犯规情况2
        /// </summary>
        /// <param name="team">待处理的仿真使命参与队伍(仿真机器鱼为具体使命的仿真机器鱼)</param>
        /// <param name="bIsLeftHalfCourt">待判断的是否左球门true判断左球门false判断右球门</param>
        private void FoulType2Handler(ref Team <Fish1V1> team, bool bIsLeftHalfCourt)
        {
            // 犯规的仿真机器鱼在队伍中的索引
            List <int> arrFishIndexFouled = new List <int>();

            for (int j = 0; j < team.Fishes.Count; j++)
            {
                if (IsRoboFishInGoal(team.Fishes[j], bIsLeftHalfCourt))
                {// 仿真机器鱼在己方球门内
                    team.Fishes[j].CountInOwnGoalArea++;
                }
                else
                {// 仿真机器鱼不在己方球门内
                    team.Fishes[j].CountInOwnGoalArea = 0;
                }
                if (team.Fishes[j].CountInOwnGoalArea > CyclesInGoalWhileFouled)
                {// 仿真机器鱼在己方球门停留一定周期数以上
                    arrFishIndexFouled.Add(j);
                }
            }
            if (arrFishIndexFouled.Count >= 1)
            {// 犯规情况2提示
                for (int i = 0; i < arrFishIndexFouled.Count; i++)
                {
                    team.Fishes[arrFishIndexFouled[i]].FoulFlag           = FoulType.FOUl2;
                    team.Fishes[arrFishIndexFouled[i]].CountCyclesFouled  = 0;
                    team.Fishes[arrFishIndexFouled[i]].CountInOwnGoalArea = 0;
                    MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef,
                                                  string.Format("FoulType2:\n【{0}】Fish {1} Fouled!\n",
                                                                team.Para.Name, arrFishIndexFouled[i] + 1),
                                                  "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Пример #10
0
        public IEnumerator <ITask> ClientAnnounceTeamNameHandler(ClientAnnounceTeamName announce)
        {
            if (MyMission.Instance().IsRomteMode == false)
            {// 服务端运行于Local模式时,策略从本地加载,不响应AnnounceTeamName消息
                announce.ResponsePort.Post(new Fault());
                yield break;
            }

            // 执行过ClientAnnounceUri保存了Client服务实例的Uri后才允许AnnounceTeamName
            if (_listClientUris.Contains(announce.Body.Service) == true)
            {// 半场交换队伍名称显示错误修正 LiYoubing 20120520
                int teamId = announce.Body.TeamId;
                if (MyMission.Instance().ParasRef.IsExchangedHalfCourt == true &&
                    MyMission.Instance().ParasRef.TeamCount == 2)
                {
                    teamId = (announce.Body.TeamId + 1) % 2;
                }
                MyMission.Instance().TeamsRef[teamId].Para.Name = announce.Body.TeamName;
            }

            // 重绘服务端界面
            Bitmap bmp = MyMission.Instance().IMissionRef.Draw();

            WinFormsServicePort.FormInvoke(delegate() { _serverControlBoard.DrawMatch(bmp); });

            yield break;
        }
 public MyHarvestOreSubmission(MyTextsWrapperEnum name, MyMissionID id, MyTextsWrapperEnum description, MyTexture2D icon, MyMission parentMission, MyMissionID[] requiredMissions, MyMissionLocation location, MyMwcObjectBuilder_Ore_TypesEnum ore, float amount, MyDialogueEnum successDialogId)
     : base(name, id, description, icon, parentMission, requiredMissions, null, successDialogId: successDialogId)
 {
     Location = location;
     m_amount = amount;
     m_ore = ore;
 }
Пример #12
0
        // added by liushu 20110314 Modified by LiYoubing 20110516
        /// <summary>
        /// 处理半场交换任务
        /// 交换半场的基础及思想:
        /// 1.仿真使命基类对象的通用队伍列表成员实际指向具体仿真使命类对象的具体队伍列表成员
        /// 2.策略调用及与客户端通信所用的temId为Mission.TeamsRef各成员的索引
        /// 3.策略调用及与客户端通信时左/右半场队伍分别为Mission.TeamsRef[0]/[1]
        /// 4.交换半场前后TeamsRef[0]/[1]始终代表左/右半场队伍
        /// 5.交换半场前Mission.TeamsRef[0]/[1]分别指向Match3V3.Teams[0]/[1]
        /// 6.交换半场后Mission.TeamsRef[0]/[1]分别指向Match3V3.Teams[1]/[0]
        /// 7.ResetTeamsAndFishes方法中对半场标志及各队伍仿真机器鱼初始位姿的设置
        ///   必须针对Mission.TeamsRef[0]/[1]而非Match3V3.Teams[0]/[1]
        /// 8.Mission.CommonPara中设置一个标志量IsExchangedHalfCourt表示是否交换过半场
        /// 9.处理进球/犯规等情况必须根据半场交换标志量来确定目标队伍
        /// 10.在界面Restart按钮的响应中对标志量进行复位
        /// </summary>
        private void HalfCourtExchangeHandler()
        {
            MyMission myMission = MyMission.Instance();

            if (CommonPara.RemainingCycles == CommonPara.TotalSeconds * 1000 / CommonPara.MsPerCycle / 2)
            {
                //CommonPara.IsExchangedHalfCourt = true;
                // LiYoubing 20110702
                // 制胜球阶段也有可能需要交换半场 对交换半场的标志量取反而不是直接赋值可以满足这个要求
                CommonPara.IsExchangedHalfCourt = !CommonPara.IsExchangedHalfCourt;
                MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef,
                                              "Time to Exchange Half-Court.", "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                // 交换半场前TeamsRef[0]/[1]分别指向Teams[0]/[1]
                // 交换半场使用List<Team<RoboFish>>的Reverse方法将TeamsRef[0]/[1]的指向对调
                // 交换半场前后TeamsRef[0]/[1]始终代表左/右半场队伍
                myMission.TeamsRef.Reverse();

                // 重置仿真障碍物状态实现构成上下球门的障碍物边框颜色交换 LiYoubing 20110726
                ResetObstacles();
                ResetTeamsAndFishes();
                ResetSomeLocomotionPara();

                for (int i = 0; i < Env.Balls.Count; i++)
                {// 把所有仿真水球的位置沿原点翻转
                    Env.Balls[i].PositionMm.Z = -Env.Balls[i].PositionMm.Z;
                    Env.Balls[i].PositionMm.X = -Env.Balls[i].PositionMm.X;
                }
            }
        }
Пример #13
0
        private void HalfCourtExchangeHandler()
        {
            MyMission myMission = MyMission.Instance();

            if (CommonPara.RemainingCycles == CommonPara.TotalSeconds * 1000 / CommonPara.MsPerCycle / 2)
            {
                //CommonPara.IsExchangedHalfCourt = true;
                // LiYoubing 20110702
                // 制胜球阶段也有可能需要交换半场 对交换半场的标志量取反而不是直接赋值可以满足这个要求
                CommonPara.IsExchangedHalfCourt = !CommonPara.IsExchangedHalfCourt;
                MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef,
                                              "Time to Exchange Half-Court.", "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //    exchScore();

                // 交换半场前TeamsRef[0]/[1]分别指向Teams[0]/[1]
                // 交换半场使用List<Team<RoboFish>>的Reverse方法将TeamsRef[0]/[1]的指向对调
                // 交换半场前后TeamsRef[0]/[1]始终代表左/右半场队伍

                myMission.TeamsRef.Reverse();

                ResetTeamsAndFishes();
                ResetBalls();
                ResetSomeLocomotionPara();
            }
        }
Пример #14
0
        //add by liufei 2011.03.17
        /// <summary>
        /// 处理比赛结束的判断和响应任务 包括4个单程任务完成和时间耗完两种情况
        /// </summary>
        private void GameOverHandler()
        {
            MyMission mymission = MyMission.Instance();
            string    strMsg    = "";

            // 使命结束标志 时间耗完或仿真水球进入左球门
            bool bIsCompleted = false;  // 用ParasRef.IsRunning会导致Restart时也弹出对话框

            if (FinishedSingleTripCount == 4)
            {                                                      // 4个单程任务完成
                mymission.ParasRef.IsRunning = false;              // 置比赛结束标志使仿真循环中断
                bIsCompleted = true;
                strMsg       = "Competition task is completed!\n"; // 任务完成提示
            }
            if (mymission.ParasRef.RemainingCycles <= 0)
            {                                                 // 时间耗完 比赛结束标志在仿真主循环里设置此处不管
                bIsCompleted = true;
                strMsg      += "Competition time is over!\n"; // 时间耗完提示
            }
            if (bIsCompleted == true)
            {// 使命结束 弹出提示 记录完成的单程数
                strMsg += string.Format("The SingleTrip count finished: {0}.\n", FinishedSingleTripCount);
                if (FinishedSingleTripCount > 0)
                {// 完成至少1个单程则记录最后一个单程完成时所剩余的时间
                    int iRemainingMs  = FinishedSingleTripTime[FinishedSingleTripCount - 1] * mymission.ParasRef.MsPerCycle;
                    int iRemainingSec = iRemainingMs / 1000;
                    // 按"MM:SS:MsMsMs"格式显示剩余时间
                    strMsg += string.Format("Remaining time when the {0}th SingleTrip is completed: {1:00}:{2:00}:{3:00}.",
                                            FinishedSingleTripCount, iRemainingSec / 60, iRemainingSec % 60, iRemainingMs % 1000);
                }
                MessageBox.Show(strMsg, "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #15
0
        /// <summary>
        /// 犯规处理函数2 added by zhangbo 20111227
        /// 各个单程内,水球只能通过指定通道。
        /// </summary>
        private void FoulType2Handler()
        {
            Field f = Field.Instance();
            Ball  b = Env.Balls[0];

            if (FinishedSingleTripCount == 1 || FinishedSingleTripCount == 3)
            {//第二、四个单程,球进入上方通道,则犯规。
                if (Math.Abs(Env.Balls[0].PositionMm.X) < (f.RightMm - f.GoalDepthMm - 1.5 * f.GoalWidthMm - Env.Balls[0].RadiusMm) &&
                    Env.Balls[0].PositionMm.Z < f.TopMm + f.GoalWidthMm - Env.Balls[0].RadiusMm)
                {
                    Env.Balls[0].PositionMm.X = f.GoalWidthMm / 2 + b.RadiusMm + 10.0f;
                    Env.Balls[0].PositionMm.Z = Convert.ToSingle(f.TopMm + f.GoalWidthMm + f.GoalDepthMm * 1.5 + b.RadiusMm);
                    MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef,
                                                  string.Format("Ball should be pushed through the other channel:\n【{0}】Fish {1} Fouled!\n",
                                                                Teams[0].Para.Name, 1),
                                                  "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            if (FinishedSingleTripCount == 2)
            {
                //第三个单程,球进入下方通道,则犯规。
                if (Math.Abs(Env.Balls[0].PositionMm.X) < (f.RightMm - f.GoalDepthMm - 1.5 * f.GoalWidthMm - Env.Balls[0].RadiusMm) &&
                    Env.Balls[0].PositionMm.Z > f.BottomMm - f.GoalWidthMm + Env.Balls[0].RadiusMm)
                {
                    Env.Balls[0].PositionMm.X = -f.GoalWidthMm / 2 - b.RadiusMm - 10.0f;
                    Env.Balls[0].PositionMm.Z = Convert.ToSingle(f.TopMm + f.GoalWidthMm + f.GoalDepthMm * 1.5 + b.RadiusMm);
                    MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef,
                                                  string.Format("Ball should be pushed through the other channel:\n【{0}】Fish {1} Fouled!\n",
                                                                Teams[0].Para.Name, 2),
                                                  "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Пример #16
0
        /// <summary>
        /// 犯规处理函数1 added by zhangbo 20111220
        /// 规定1号机器鱼只能通过上面通道,机器鱼2只能通过下面通道。
        /// </summary>
        private void FoulType1Handler()
        {
            Field f = Field.Instance();

            //1号鱼进入下方通道,则犯规。将1号机器鱼置于初始位置。
            if (Math.Abs(Teams[0].Fishes[0].PositionMm.X) < (f.RightMm - f.GoalDepthMm - 1.5 * f.GoalWidthMm - Env.Balls[0].RadiusMm) &&
                Teams[0].Fishes[0].PositionMm.Z > f.BottomMm - f.GoalWidthMm + Env.Balls[0].RadiusMm)
            {
                Teams[0].Fishes[0].PositionMm       = new xna.Vector3(f.LeftMm + Teams[0].Fishes[0].BodyLength * 2, 0, 0);
                Teams[0].Fishes[0].BodyDirectionRad = 0;
                MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef,
                                              string.Format("Enter the Channel Not Allowed:\n【{0}】Fish {1} Fouled!\n",
                                                            Teams[0].Para.Name, 1),
                                              "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            //2号鱼进入上方通道,则犯规。将2号机器鱼置于初始位置。
            if (Math.Abs(Teams[0].Fishes[1].PositionMm.X) < (f.RightMm - f.GoalDepthMm - 1.5 * f.GoalWidthMm - Env.Balls[0].RadiusMm) &&
                Teams[0].Fishes[1].PositionMm.Z < f.TopMm + f.GoalWidthMm - Env.Balls[0].RadiusMm)
            {
                Teams[0].Fishes[1].PositionMm       = new xna.Vector3(f.RightMm - Teams[0].Fishes[1].BodyLength * 2, 0, 0);
                Teams[0].Fishes[1].BodyDirectionRad = (float)Math.PI;
                MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef,
                                              string.Format("Enter the Channel Not Allowed:\n【{0}】Fish {1} Fouled!\n",
                                                            Teams[0].Para.Name, 2),
                                              "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #17
0
        /// <summary>
        /// 重启或改变仿真使命类型时将该仿真使命参与队伍及其仿真机器鱼的各项参数设置为默认值
        /// </summary>
        public override void ResetTeamsAndFishes()
        {
            Field     f         = Field.Instance();
            MyMission myMission = MyMission.Instance();

            if (Teams != null)
            {
                for (int i = 0; i < Teams.Count; i++)
                {
                    myMission.TeamsRef[i].Para.MyHalfCourt = (HalfCourt)i;
                    for (int j = 0; j < Teams[i].Fishes.Count; j++)
                    {
                        Teams[i].Fishes[j].CountDrawing = 0;
                        Teams[i].Fishes[j].InitPhase    = i * 5 + j * 5;
                    }
                }

                myMission.TeamsRef[0].Fishes[0].PositionMm = new xna.Vector3(
                    f.LeftMm + myMission.TeamsRef[0].Fishes[0].BodyLength * 3,
                    0, Teams[0].Fishes[0].BodyWidth * 3);
                myMission.TeamsRef[0].Fishes[1].PositionMm = new xna.Vector3(
                    f.LeftMm + myMission.TeamsRef[0].Fishes[1].BodyLength * 3,
                    0, -Teams[0].Fishes[1].BodyWidth * 3);

                for (int j = 0; j < CommonPara.FishCntPerTeam; j++)
                {
                    // 左半场队伍的仿真机器鱼朝右
                    myMission.TeamsRef[0].Fishes[j].BodyDirectionRad = 0;
                }
            }
        }
Пример #18
0
        /// <summary>
        /// 处理对抗赛5VS5具体仿真使命的控制规则
        /// </summary>
        public override void ProcessControlRules()
        {
            // 处理进球判断提示和响应任务 added by renjing 20110310
            GoalHandler();

            // 处理倒计时递减到0比赛结束判断提示和响应任务 added by renjing 20110310
            GameOverHandler();

            // 处理半场交换任务 added by liushu 20110314
            HalfCourtExchangeHandler();

            // 更新当前使命类特有的需要传递给策略的变量名和变量值
            UpdateHtMissionVariables();
            if (CommonPara.IsExchangedHalfCourt == false)
            {     // 点球阶段每支队伍只有第0条仿真机器鱼可以活动
                for (int j = 1; j < MyMission.Instance().ParasRef.FishCntPerTeam; j++)
                { // 留下第0条仿真机器鱼不强制静止
                    Teams[0].Fishes[1].PositionMm = new xna.Vector3(
                        -2115, 0, 1591);
                    Teams[0].Fishes[2].PositionMm           = new xna.Vector3(-1715, 0, 1591);
                    Teams[0].Fishes[3].PositionMm           = new xna.Vector3(-1315, 0, 1591);
                    Teams[0].Fishes[j].BodyDirectionRad     = 0;
                    Teams[0].Fishes[j].VelocityMmPs         = 0;
                    Teams[0].Fishes[j].AngularVelocityRadPs = 0;

                    if (gool[j - 1] == 1)
                    {
                        Teams[1].Fishes[j].PositionMm = new xna.Vector3(2415 - 300 * j, 0, 1591);

                        Teams[1].Fishes[j].BodyDirectionRad     = 0;
                        Teams[1].Fishes[j].VelocityMmPs         = 0;
                        Teams[1].Fishes[j].AngularVelocityRadPs = 0;
                    }
                }
            }
            else
            {
                for (int j = 1; j < MyMission.Instance().ParasRef.FishCntPerTeam; j++)
                {// 留下第0条仿真机器鱼不强制静止
                    Teams[1].Fishes[1].PositionMm = new xna.Vector3(
                        -2115, 0, 1591);
                    Teams[1].Fishes[2].PositionMm           = new xna.Vector3(-1715, 0, 1591);
                    Teams[1].Fishes[3].PositionMm           = new xna.Vector3(-1315, 0, 1591);
                    Teams[1].Fishes[j].BodyDirectionRad     = 0;
                    Teams[1].Fishes[j].VelocityMmPs         = 0;
                    Teams[1].Fishes[j].AngularVelocityRadPs = 0;

                    if (goor[j - 1] == 1)
                    {
                        Teams[0].Fishes[j].PositionMm           = new xna.Vector3(2415 - 300 * j, 0, 1591);
                        Teams[0].Fishes[j].BodyDirectionRad     = 0;
                        Teams[0].Fishes[j].VelocityMmPs         = 0;
                        Teams[0].Fishes[j].AngularVelocityRadPs = 0;
                    }
                }
            }
        }
Пример #19
0
 private void BtnReady_Click(object sender, EventArgs e)
 {
     // 服务端运行于Remote模式时Ready按钮点击无效
     if (MyMission.Instance().IsRomteMode == true)
     {
         return;
     }
     BtnReady.Enabled = false;
 }
Пример #20
0
        /// <summary>
        /// 将当前仿真水球对象详细信息设置到相应界面控件中
        /// </summary>
        public void SetBallInfoToUi()
        {
            Ball ball = MyMission.Instance().EnvRef.Balls[BallId];

            BtnColor.BackColor  = ball.ColorFilled;
            TxtPositionMmX.Text = ((int)ball.PositionMm.X).ToString();
            TxtPositionMmZ.Text = ((int)ball.PositionMm.Z).ToString();
            TxtRadiusMm.Text    = ball.RadiusMm.ToString();
        }
Пример #21
0
        /// <summary>
        /// 球越过黑线的处理函数
        /// </summary>
        private void HandleWhileBallGoOverBlackLine()
        {
            MyMission mymission = MyMission.Instance();

            //球完全越过黑线
            if ((mymission.EnvRef.Balls[0].PositionMm.X + mymission.EnvRef.Balls[0].RadiusMm) <= blackLineX)
            {
                mymission.ParasRef.IsRunning = false;//比赛停止
                System.Windows.Forms.MessageBox.Show("Congradulations! ", "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
            public MyBarthsMoonSubmissionTalkWithThomasBarth(MyTextsWrapperEnum Name, MyMissionID ID, MyTextsWrapperEnum Description, MyMission ParentMission, MyMissionID[] RequiredMissions, MyDialogueEnum? dialogue, bool restartPatrol = true, MyDialogueEnum? startDialogue = null, string pathName = "interior2")
                : base(Name, ID, Description, null, ParentMission, RequiredMissions, null, null, dialogue) 
            {                
                m_botToTalkId = (uint)EntityID.ThomasBartId;

                m_botDetectorId = (uint)EntityID.ThomasBartDetectorId;
                m_distanceToTalk = 100;
                m_restartPatrol = restartPatrol;
                m_pathName = pathName;
                MissionEntityIDs.Add(m_botToTalkId);
            }
Пример #23
0
 public MySabotageSubmission(
     StringBuilder name,
     MyMissionID id,
     StringBuilder description,
     MyTexture2D icon,
     MyMission parentMission,
     MyMissionID[] requiredMissions,
     MyMissionLocation location)
     : this(name, id, description, icon, parentMission, requiredMissions, location, MyTextsWrapperEnum.NotificationSabotageSubmission)
 {
 }
Пример #24
0
        /// <summary>
        /// 指示是否已经发生过策略调用异常true是false否
        /// 20110820废弃 策略代码中存在条件性除零/数组越界等异常时 不必要直接结束掉策略运行
        /// </summary>
        //bool _strategyExceptionFlag = false;

        /// <summary>
        /// 进行策略调用 获取指定id对应队伍的决策数据
        /// </summary>
        /// <param name="teamId">待获取决策数据的队伍id(从0开始)</param>
        void GetLocalDecision(int teamId)
        {
            MyMission myMission = MyMission.Instance();

            Decision[] decisions = null;
            if (_serverControlBoard.TeamStrategyControls[teamId].StrategyInterface != null
                /*&& _strategyExceptionFlag == false*/)
            {// 进行null检查确保不出异常 LiYoubing 20110511
                // 将当前仿真使命的通用Mission对象拷贝一份用于策略调用的参数传递
                Mission mission = (Mission)MyMission.Instance().MissionRef.Clone();
                for (int i = 0; i < mission.CommonPara.TeamCount; i++)
                {// 循环对每条仿真机器鱼施加图像处理干扰 LiYoubing 20110617
                    for (int j = 0; j < mission.CommonPara.FishCntPerTeam; j++)
                    {
                        RoboFish f = mission.TeamsRef[i].Fishes[j];
                        Interference.ImageProcessInterference(ref f.PositionMm, ref f.BodyDirectionRad,
                                                              f.VelocityMmPs, f.AngularVelocityRadPs);
                    }
                }
                for (int i = 0; i < mission.EnvRef.Balls.Count; i++)
                {// 循环对所有仿真水球施加图像处理干扰 LiYoubing 20110617
                    Ball  b   = mission.EnvRef.Balls[i];
                    float tmp = 0;
                    Interference.ImageProcessInterference(ref b.PositionMm, ref tmp, b.VelocityMmPs, b.AngularVelocityRadPs);
                }
                // 交换半场后交换策略处理 LiYoubing 20110711
                // 交换半场后TeamsRef[0]/[1]代表交换前右/左半场的队伍因此应该分别调用第1/0号控件所加载的策略
                int strategyId = myMission.ParasRef.IsExchangedHalfCourt ? (teamId + 1) % 2 : teamId;
                try
                {
                    decisions = _serverControlBoard.TeamStrategyControls[strategyId].StrategyInterface.GetDecision(
                        mission, teamId);
                }
                catch
                {
                    //_strategyExceptionFlag = true;
                    MessageBox.Show("Remoting object timeout.\nThe instance of class Strategy has been released."
                                    + "\nYour simulated robofish will not be controlled.",
                                    "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                //decision = _serverControlBoard.TeamStrategyControls[teamId].StrategyInterface.GetDecision(
                //   mission, teamId);
                //decision = _serverControlBoard.TeamStrategyControls[teamId].StrategyInterface.GetDecision(
                //   myMission.MissionRef, teamId);
            }
            if (decisions == null)
            {
                return;
            }
            for (int j = 0; j < myMission.TeamsRef[teamId].Fishes.Count; j++)
            {
                myMission.DecisionRef[teamId, j] = decisions[j];
            }
        }
Пример #25
0
 public MySabotageSubmission(
     StringBuilder name,
     MyMissionID id,
     StringBuilder description,
     MyTexture2D icon,
     MyMission parentMission,
     MyMissionID[] requiredMissions,
     MyMissionLocation location)
     : this(name, id, description, icon, parentMission, requiredMissions, location, MyTextsWrapperEnum.NotificationSabotageSubmission)
 {
 
 }
Пример #26
0
        /// <summary>
        /// 比赛时间结束的处理
        /// </summary>
        private void GameOverHandler()
        {
            MyMission mymission = MyMission.Instance();

            //比赛时间为0

            if (mymission.ParasRef.RemainingCycles <= 0)
            {
                mymission.ParasRef.IsRunning = false;//比赛停止
                System.Windows.Forms.MessageBox.Show("Sorry !You had only finished" + finishedCountOneWay + "oneway,cost seconds!", "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #27
0
        /// <summary>
        /// 绘制仿真机器鱼和仿真水球轨迹
        /// </summary>
        public void DrawPictureBox()
        {
            MyMission myMission = MyMission.Instance();

            myPen.Width = 2;
            Bitmap bmp = new Bitmap(myMission.EnvRef.FieldInfo.PictureBoxXPix, myMission.EnvRef.FieldInfo.PictureBoxZPix);

            myGraphic = Graphics.FromImage(bmp);

            for (int i = 0; i < myMission.TeamsRef.Count; i++)
            {// 绘制仿真机器鱼轨迹
                for (int j = 0; j < myMission.TeamsRef[i].Fishes.Count; j++)
                {
                    if ((_listComboControls[i].ListChkFishes[j].Checked == true) &&
                        (myMission.TeamsRef[i].Fishes[j].TrajectoryPoints.Count > 1))
                    {
                        myPen.Color = myMission.TeamsRef[i].Fishes[j].ColorFish;
                        int m = 0;
                        for (m = 0; m < myMission.TeamsRef[i].Fishes[j].TrajectoryPoints.Count - 1; m++)
                        {
                            myGraphic.DrawLine(myPen, myMission.TeamsRef[i].Fishes[j].TrajectoryPoints[m],
                                               myMission.TeamsRef[i].Fishes[j].TrajectoryPoints[m + 1]);
                        }
                        myGraphic.DrawString(String.Format("F{0}", j), new Font(Font, FontStyle.Bold),
                                             new SolidBrush(myPen.Color), (PointF)(myMission.TeamsRef[i].Fishes[j].TrajectoryPoints[m]));
                    }
                }
            }

            if (_ballComboControl != null)
            {// 绘制仿真水球的轨迹
                for (int i = 0; i < _ballComboControl.ListChkFishes.Count; i++)
                {
                    if ((_ballComboControl.ListChkFishes[i].Checked == true) &&
                        (myMission.EnvRef.Balls[i].TrajectoryPoints.Count > 1))
                    {
                        myPen.Color = myMission.EnvRef.Balls[i].ColorFilled;
                        int n;
                        for (n = 0; n < myMission.EnvRef.Balls[i].TrajectoryPoints.Count - 1; n++)
                        {
                            myGraphic.DrawLine(myPen, myMission.EnvRef.Balls[i].TrajectoryPoints[n],
                                               myMission.EnvRef.Balls[i].TrajectoryPoints[n + 1]);
                        }
                        string str = (_ballComboControl.ListChkFishes.Count > 1) ? String.Format("Ball{0}", i + 1) : "Ball";
                        myGraphic.DrawString(str, new Font(Font, FontStyle.Bold),
                                             new SolidBrush(myPen.Color), (PointF)(myMission.EnvRef.Balls[0].TrajectoryPoints[n]));
                    }
                }
            }

            picTrajectory.Image = bmp;
        }
Пример #28
0
 public MySabotageSubmission(
     StringBuilder name,
     MyMissionID id,
     StringBuilder description,
     MyTexture2D icon,
     MyMission parentMission,
     MyMissionID[] requiredMissions,
     MyMissionLocation location,
     MyTextsWrapperEnum notificationText)
     : base(name, id, description, icon, parentMission, requiredMissions, location, null)
 {
     m_notificationText = notificationText;
 }
Пример #29
0
 public MySabotageSubmission(
     StringBuilder name, 
     MyMissionID id, 
     StringBuilder description, 
     MyTexture2D icon, 
     MyMission parentMission, 
     MyMissionID[] requiredMissions, 
     MyMissionLocation location, 
     MyTextsWrapperEnum notificationText)
     : base(name, id, description, icon, parentMission, requiredMissions, location, null)
 {
     m_notificationText = notificationText;
 }
Пример #30
0
        //added by LiuShu 20101117
        //modified 20110110
        /// <summary>
        /// Server接收Client发的Decision信息,并处理
        /// </summary>
        void ClientAnnounceDecisionHandler(ClientBase.ClientAnnounceDecision announce)
        {
            // 交换半场后交换策略处理 LiYoubing 20110711
            // 交换半场后TeamsRef[0]/[1]代表交换前右/左半场的队伍因此应该分别接收1/0号客户端发来的策略
            int strategyId = MyMission.Instance().ParasRef.IsExchangedHalfCourt
                ? (announce.Body.TeamId + 1) % 2 : announce.Body.TeamId;

            for (int i = 0; i < MyMission.Instance().ParasRef.FishCntPerTeam; i++)
            {
                MyMission.Instance().DecisionRef[strategyId, i] = announce.Body.Decisions[i];
                //MyMission.Instance().DecisionRef[announce.Body.TeamId, i] = announce.Body.Decisions[i];
            }
        }
Пример #31
0
        /// <summary>
        /// 重启或改变仿真使命类型时将该仿真使命参与队伍及其仿真机器鱼的各项参数设置为默认值
        /// </summary>
        public override void ResetTeamsAndFishes()
        {
            Field     f         = Field.Instance();
            MyMission myMission = MyMission.Instance();

            if (Teams != null)
            {
                myMission.TeamsRef[0].Fishes[0].PositionMm       = new xna.Vector3(1600, 0, 0);
                myMission.TeamsRef[0].Fishes[0].BodyDirectionRad = xna.MathHelper.Pi;

                /* for (int i = 0; i < Teams.Count; i++)
                 * {
                 *   // 左/右半场队伍的半场标志分别为LEFT(0)/RIGHT(1)
                 *   myMission.TeamsRef[i].Para.MyHalfCourt = (HalfCourt)i;
                 *   for (int j = 0; j < Teams[i].Fishes.Count; j++)
                 *   {
                 *       Teams[i].Fishes[j].CountDrawing = 0;
                 *       Teams[i].Fishes[j].InitPhase = i * 5 + j * 5;
                 *
                 *       // 清除犯规标志 LiYoubing 20110726
                 *
                 *   }
                 * }
                 * //   if (CommonPara.IsExchangedHalfCourt == false)
                 * {
                 *   // 左半场队伍的仿真机器鱼位置
                 *   myMission.TeamsRef[0].Fishes[0].PositionMm = new xna.Vector3(
                 *       f.LeftMm + myMission.TeamsRef[0].Fishes[0].BodyLength * 3, 0, 0);
                 *   myMission.TeamsRef[0].Fishes[1].PositionMm = new xna.Vector3(
                 *       -2115, 0, 1591);
                 *   myMission.TeamsRef[0].Fishes[2].PositionMm = new xna.Vector3(-1715, 0, 1591);
                 *   myMission.TeamsRef[0].Fishes[3].PositionMm = new xna.Vector3(-1315, 0, 1591);
                 *
                 *   myMission.TeamsRef[1].Fishes[0].PositionMm = new xna.Vector3(
                 *       450, 0, 0);
                 *   myMission.TeamsRef[1].Fishes[1].PositionMm = new xna.Vector3(1600, 0, -800);
                 *   myMission.TeamsRef[1].Fishes[2].PositionMm = new xna.Vector3(1600, 0, 0);
                 *   myMission.TeamsRef[1].Fishes[3].PositionMm = new xna.Vector3(1600, 0, 800);
                 *
                 *
                 *   for (int j = 0; j < CommonPara.FishCntPerTeam; j++)
                 *   {
                 *       // 左半场队伍的仿真机器鱼朝右
                 *       myMission.TeamsRef[0].Fishes[j].BodyDirectionRad = 0;
                 *       // 右半场队伍的仿真机器鱼朝左
                 *       myMission.TeamsRef[1].Fishes[j].BodyDirectionRad = xna.MathHelper.Pi;
                 *   }
                 * }*/
            }
        }
        /// <summary>
        /// 处理倒计时递减到0比赛结束判断提示和响应任务
        /// </summary>
        private void GameOverHandler()
        {
            if (CommonPara.RemainingCycles > 0)
            {
                return;
            }

            // 比赛时间耗完才接着处理
            string strMsg = "Time Over!";

            //MessageBox.Show(strMsg, "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef, strMsg,
                                          "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
Пример #33
0
        public void SetFishInfo()
        {
            MyMission missionref = MyMission.Instance();

            dgv.Location        = new Point(10, 18);
            dgv.Size            = new Size(710, 230);
            dgv.BackgroundColor = Color.White;
            groupBox1.Controls.Add(dgv);

            int fishes = 0;

            for (int i = 0; i < missionref.TeamsRef.Count; i++)
            {
                for (int j = 0; j < missionref.TeamsRef[i].Fishes.Count; j++)
                {
                    RoboFish f = missionref.TeamsRef[i].Fishes[j];

                    // 第1列第fishes + j个单元格的值为仿真机器鱼的X坐标值
                    dgv[0, fishes + j].Value = (int)(f.PositionMm.X);

                    // 第2列第fishes + j个单元格的值为仿真机器鱼的Z坐标值
                    dgv[1, fishes + j].Value = (int)(f.PositionMm.Z);

                    // 第3列第fishes + j个单元格的值为仿真机器鱼的鱼体方向
                    dgv[2, fishes + j].Value = string.Format("{0:0.0000}", f.BodyDirectionRad);

                    // 第4列第fishes + j个单元格的值为仿真机器鱼的运动速度
                    dgv[3, fishes + j].Value = string.Format("{0:0.0000}", f.VelocityMmPs);

                    // 第5列第fishes + j个单元格的值为仿真机器鱼运动的速度方向
                    dgv[4, fishes + j].Value = string.Format("{0:0.0000}", f.VelocityDirectionRad);

                    // 第6列第fishes + j个单元格的值为机器鱼的角速度
                    dgv[5, fishes + j].Value = string.Format("{0:0.0000}", f.AngularVelocityRadPs);

                    // 第7列第fishes + j个单元格的值为当前时刻机器鱼运动的速度档位
                    dgv[6, fishes + j].Value = f.Tactic.VCode;

                    // 第8列第fishes + j个单元格的值为当前时刻机器鱼运动的方向档位
                    dgv[7, fishes + j].Value = f.Tactic.TCode;

                    // 第9列第fishes + j个单元格的值为前一时刻机器鱼运动的目标决策速度档位
                    dgv[8, fishes + j].Value = f.TargetTactic.VCode;

                    // 第10列第fishes + j个单元格的值为前一时刻机器鱼运动的目标决策方向档位
                    dgv[9, fishes + j].Value = f.TargetTactic.TCode;
                }
                fishes += missionref.TeamsRef[i].Fishes.Count;
            }
        }
Пример #34
0
        // Added by renjing 20110310 Modified by LiYoubing 20110515
        /// <summary>
        /// 处理倒计时递减到0比赛结束判断提示和响应任务
        /// </summary>
        private void GameOverHandler()
        {
            if (CommonPara.RemainingCycles > 0)
            {
                return;
            }


            CommonPara.IsRunning = false;
            string strMsg = string.Format("Competition finished.\n");

            MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef, strMsg,
                                          "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            /*
             * // 比赛时间耗完才接着处理
             * string strMsg = "";
             * if (Teams[0].Para.Score != Teams[1].Para.Score)
             * {// 双方得分不同,决出胜负
             *  CommonPara.IsRunning = false;//比赛停止
             *  int winner = (Teams[0].Para.Score > Teams[1].Para.Score) ? 0 : 1;
             *  strMsg = string.Format("Congradulations!\nCompetition is completed.\nWinner:【{0}】 in 【{1}】\n",
             *      Teams[winner].Para.Name, Teams[winner].Para.MyHalfCourt);
             * }
             * else
             * {
             *  CommonPara.IsRunning = false;
             *  if (ltime < rtime)
             *  {
             *      int winner = 0;
             *      strMsg = string.Format("Congradulations!\nCompetition is completed.\nWinner:【{0}】 in 【{1}】\n",
             * Teams[winner].Para.Name, Teams[winner].Para.MyHalfCourt);
             *  }
             *  else if (ltime > rtime)
             *  {
             *      int winner = 1;
             *      strMsg = string.Format("Congradulations!\nCompetition is completed.\nWinner:【{0}】 in 【{1}】\n",
             * Teams[winner].Para.Name, Teams[winner].Para.MyHalfCourt);
             *  }
             *  else
             *  {
             *      strMsg = string.Format("Competition is tied.\n");
             *  }
             * }
             *
             * MatchHelper.MissionMessageBox(ref MyMission.Instance().MissionRef, strMsg,
             *  "Confirming", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             */
        }
Пример #35
0
 public MySubmissionFlyToAny(StringBuilder Name, MyMissionID ID, StringBuilder Description, MyTexture2D Icon, MyMission ParentMission, MyMissionID[] RequiredMissions, List<MyMissionLocation> Locations, List<uint> MissionEntityIDs = null, Audio.Dialogues.MyDialogueEnum? successDialogId = null)
     : base(Name, ID, Description, Icon, ParentMission, RequiredMissions, null, MissionEntityIDs, successDialogId)
 {
     m_locations = Locations;
 }
Пример #36
0
 public MyObjectiveWatchSigns(StringBuilder Name, MyMissionID ID, StringBuilder Description, MyTexture2D Icon, MyMission ParentMission, MyMissionID[] RequiredMissions, uint target, Audio.Dialogues.MyDialogueEnum? dialogId = null)
     : base(Name, ID, Description, Icon, ParentMission, RequiredMissions, null, null, null, dialogId)
 {
     m_targetId = target;
 }
Пример #37
0
 public MyFollowHostObjective(MyMission parentMission)
     : base(MyTextsWrapperEnum.FollowTarget, MyMissionID.COOP_FOLLOW_HOST_OBJECTIVE, MyTextsWrapperEnum.FollowTarget, null, parentMission, new MyMissionID[] { }, null)
 {
 }
 public MySideMissionAssassinationKillSubmission(MyMission parent)
     :base(new StringBuilder("Kill the enemy"), MyMissionID.SIDE_MISSION_01_ASSASSINATION_KILL, new StringBuilder("Your enemy needs to be terminated"), null, parent, new MyMissionID[0], null) 
 {
     this.IsSideMission = true;
 }
Пример #39
0
 public MyTimedMeetObjective(MyTextsWrapperEnum Name, MyMissionID ID, MyTextsWrapperEnum Description, MyMission ParentMission, MyMissionID[] RequiredMissions, uint? detectorId, uint botId, float distanceToTalk, float slowdown, TimeSpan submissionDuration, MyDialogueEnum? successDialogueId = null, MyDialogueEnum? startDialogueId = null, bool stopFollow = true) 
     : base(Name, ID, Description, ParentMission, RequiredMissions, detectorId, botId, distanceToTalk, slowdown, successDialogueId, startDialogueId, stopFollow)
 {
     m_submissionDuration = submissionDuration;
     m_remainingTime = submissionDuration;
 }