예제 #1
0
        //更新小球相关操作的状态、得分
        public void UpdateBallsState()
        {
            NoBall = true;
            bool noBallInCollect = true;
            Camp currCollectCamp = Camp.None;

            //int currBallCntA = 0;
            //BallAtCollect = new Dot(0, 0);
            foreach (Dot ball in BallsDot)
            {
                if (InCollect(ball))
                {
                    BallAtCollect   = ball;
                    noBallInCollect = false;
                }
                //else if (InStorageA(ball)) currBallCntA++;
                //else if (InStorageB(ball)) currBallCntB++;

                if (!InStorageA(ball))
                {
                    BallDot = ball;
                    NoBall  = false;
                }
            }

            //更新CollectCamp:物资收集点处是A车还是B车
            switch (GameCamp)
            {
            case Camp.CampA: if (InCollect(CarA.Pos))
                {
                    currCollectCamp = Camp.CampA;
                }
                break;

            case Camp.CampB: if (InCollect(CarB.Pos))
                {
                    currCollectCamp = Camp.CampB;
                }
                break;

            default: currCollectCamp = Camp.None;  break;
            }

            //进入物资收集点计分
            if (CollectCamp == Camp.None && currCollectCamp != Camp.None)
            {
                switch (currCollectCamp)
                {
                case Camp.CampA:
                    if (Round - CarA.LastInCollectRound > MinGetBallRound)
                    {                                                      //防止重复计分
                        CarA.LastInCollectRound = Round;
                        AddScore(currCollectCamp, Score.BallCollectScore); //小车成功到达物资收集点
                    }
                    break;

                case Camp.CampB:
                    if (Round - CarB.LastInCollectRound > MinGetBallRound)
                    {
                        CarB.LastInCollectRound = Round;
                        AddScore(currCollectCamp, Score.BallCollectScore);     //小车成功到达物资收集点
                    }
                    break;

                default: break;
                }
            }

            RequestNewBall = noBallInCollect && !InCollect(CarA.Pos) && !InCollect(CarB.Pos); //物资收集点处没有车和球时才可请求新球

            //抓取到小球计分
            if (RequestNewBall)
            {
                switch (CollectCamp)
                {
                case Camp.CampA:
                    if (!CarA.HaveBall)
                    {
                        AddScore(Camp.CampA, Score.BallGetScore);
                        CarA.BallGetCnt++;
                        CarA.HaveBall = true;
                    }
                    break;

                case Camp.CampB:
                    if (!CarB.HaveBall)
                    {
                        AddScore(Camp.CampB, Score.BallGetScore);
                        CarB.BallGetCnt++;
                        CarB.HaveBall = true;
                    }
                    break;

                default: break;
                }
                CollectCamp = Camp.None;
            }

            CollectCamp = currCollectCamp;

            ////小球运输至存放点计分
            //if (currBallCntA == BallCntA + 1)
            //{
            //    if (GameCamp == Camp.CampA && CarA.HaveBall)
            //    {
            //        AddScore(Camp.CampA, Score.BallStoreScore);
            //        CarA.BallOwnCnt++;
            //        CarA.HaveBall = false;
            //    }
            //    if (GameCamp == Camp.CampB && CarB.HaveBall)
            //    {
            //        AddScore(Camp.CampB, Score.BallStoreScore);
            //        CarB.BallOwnCnt++;
            //        CarB.HaveBall = false;
            //    }
            //}
            //BallCntA = currBallCntA;
        }
예제 #2
0
 public void ResetInfo(Dot startDot, int number)
 {
     StartPos = startDot;
     Number   = number;
 }
예제 #3
0
 public static double GetDistance(Dot A, Dot B)
 {
     return(Math.Sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y)));
 }
예제 #4
0
 }                               //编号
 public Person(Dot startDot, int number)
 {
     StartPos = startDot;
     Number   = number;
 }