Example #1
0
        private static double Distance(Model.FastonPosition fp1, Model.FastonPosition fp2)
        {
            double x1, y1;

            CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fp1.Longitude, fp1.Latitde, out x1, out y1);

            double x2, y2;

            CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fp2.Longitude, fp2.Latitde, out x2, out y2);

            return(Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
        }
Example #2
0
        private void EditCarStateWhenBustStartOK(Player player, ref Car car, int to, Model.FastonPosition fp1, SetBust sb, List <Model.MapGo.nyrqPosition> goPath, out int startT, ref List <string> notifyMsg)
        {
            car.targetFpIndex = to;//A.更改小车目标,在其他地方引用。
            car.setPurpose(this._Players[sb.Key], ref notifyMsg, Purpose.attack);
            // car.purpose = Purpose.attack;//B.更改小车目的,小车变为攻击状态!
            //  car.changeState++;//C.更改状态用去前台更新动画

            /*
             * D.更新小车动画参数
             */
            var speed = car.ability.Speed;

            startT = 0;
            List <Data.PathResult> result;

            if (car.state == CarState.waitAtBaseStation)
            {
                result = getStartPositon(fp1, sb.car, ref startT);
            }
            else
            {
                throw new Exception("错误的汽车类型!!!");
            }
            car.setState(this._Players[sb.Key], ref notifyMsg, CarState.roadForAttack);
            //car.state = CarState.roadForAttack;
            //  this.SendStateAndPurpose(this._Players[sa.Key], car, ref notifyMsg);


            Program.dt.GetAFromBPoint(goPath, fp1, speed, ref result, ref startT);
            result.RemoveAll(item => item.t0 == item.t1);

            var animateData = new AnimateData()
            {
                animateData = result,
                recordTime  = DateTime.Now
            };

            car.setAnimateData(player, ref notifyMsg, animateData);
        }
Example #3
0
        /// <summary>
        /// 修改小车相关属性
        /// </summary>
        /// <param name="car"></param>
        /// <param name="to"></param>
        /// <param name="fp1"></param>
        /// <param name="sc"></param>
        /// <param name="goPath"></param>
        private void EditCarStateWhenCollectStartOK(Player player, ref Car car, int to, Model.FastonPosition fp1, SetCollect sc, List <Model.MapGo.nyrqPosition> goPath, ref List <string> notifyMsg, out int startT)
        {
            car.targetFpIndex = to;                                 //A.更改小车目标,在其他地方引用。
            car.setPurpose(player, ref notifyMsg, Purpose.collect); //B.更改小车目的,用户操作控制
                                                                    //car.purpose = Purpose.collect;//B.更改小车目的,用户操作控制
                                                                    //    car.changeState++;//C.更改状态用去前台更新动画

            /*
             * 步骤C已经封装进 car.setAnimateData
             */
            /*
             * D.更新小车动画参数
             */

            var speed = car.ability.Speed;

            startT = 0;
            List <Data.PathResult> result;

            if (car.state == CarState.waitAtBaseStation)
            {
                result = getStartPositon(fp1, sc.car, ref startT);
            }
            else if (car.state == CarState.waitForCollectOrAttack)
            {
                result = new List <Data.PathResult>();
            }
            else if (car.state == CarState.waitOnRoad && car.ability.diamondInCar == "" && (car.purpose == Purpose.@null || car.purpose == Purpose.collect))
            {
                result = new List <Data.PathResult>();
            }
            else
            {
                throw new Exception($"未知情况!{Newtonsoft.Json.JsonConvert.SerializeObject(car)}");
            }
            car.setState(player, ref notifyMsg, CarState.roadForCollect);
            //car.state = CarState.roadForCollect;

            Program.dt.GetAFromBPoint(goPath, fp1, speed, ref result, ref startT);
            result.RemoveAll(item => item.t0 == item.t1);

            car.setAnimateData(player, ref notifyMsg, new AnimateData()
            {
                animateData = result,
                recordTime  = DateTime.Now
            });
            //car.animateData = new AnimateData()
            //{
            //    animateData = result,
            //    recordTime = DateTime.Now
            //};
        }
Example #4
0
        private void EditCarStateWhenPromoteStartOK(Player player, ref Car car, int to, Model.FastonPosition fp1, int to2, SetPromote sp, List <Model.MapGo.nyrqPosition> goPath, ref List <string> nofityMsgs, out int startT)
        {
            car.targetFpIndex = to; //A.更改小车目标,在其他地方引用。
                                    //  car.changeState++;//B.更改状态用去前台更新动画

            /*
             * C.更新小车动画参数
             */
            var speed = car.ability.Speed;

            startT = 0;
            List <Data.PathResult> result;

            if (car.state == CarState.waitOnRoad)
            {
                result = new List <Data.PathResult>();
            }
            else if (car.state == CarState.waitAtBaseStation)
            {
                result = getStartPositon(fp1, sp.car, ref startT);
            }
            else if (car.state == CarState.waitForCollectOrAttack)
            {
                result = new List <Data.PathResult>();
            }
            else if (car.state == CarState.waitForTaxOrAttack)
            {
                result = new List <Data.PathResult>();
            }
            else
            {
                Console.WriteLine($"{Newtonsoft.Json.JsonConvert.SerializeObject(car)}");
                throw new Exception("错误的汽车类型!!!");
            }
            Program.dt.GetAFromBPoint(goPath, fp1, speed, ref result, ref startT);
            result.RemoveAll(item => item.t0 == item.t1);

            var animateData = new AnimateData()
            {
                animateData = result,
                recordTime  = DateTime.Now
            };

            car.setAnimateData(player, ref nofityMsgs, animateData);
            //car.animateData = new AnimateData()
            //{
            //    animateData = result,
            //    recordTime = DateTime.Now
            //};
            car.setState(player, ref nofityMsgs, CarState.buying);
            //  car.state = CarState.buying;//更改汽车状态

            //Thread th = new Thread(() => setDiamondOwner(startT, new commandWithTime.diamondOwner()
            //{
            //    c = "diamondOwner",
            //    key = sp.Key,
            //    car = sp.car,
            //    returnPath = returnPath,
            //    target = to,//新的起点
            //    changeType = sp.pType,
            //    costMile = goMile
            //}));
            //th.Start();
            //car.changeState++;//更改状态

            //getAllCarInfomations(sp.Key, ref notifyMsg);
        }
Example #5
0
        public void EditCarStateWhenActionStartOK(RoleInGame player, ref Car car, int to, Model.FastonPosition fp1, Node goPath, ref List <string> notifyMsg, out int startT)
        {
            car.targetFpIndex = to;//A.更改小车目标,在其他地方引用。

            //car.purpose = Purpose.collect;//B.更改小车目的,用户操作控制
            //    car.changeState++;//C.更改状态用去前台更新动画

            /*
             * 步骤C已经封装进 car.setAnimateData
             */
            /*
             * D.更新小车动画参数
             */

            var speed = car.ability.Speed;

            startT = 0;
            List <int> result;

            Data.PathStartPoint2 startPosition;
            if (car.state == CarState.waitAtBaseStation)
            {
                result = that.getStartPositon(fp1, player.positionInStation, ref startT, out startPosition, player.improvementRecord.speedValue > 0);
            }
            else if (car.state == CarState.waitOnRoad)
            {
                result = new List <int>();
                that.getStartPositionByGoPath(out startPosition, goPath.path[0]);
                // that.getStartPositionByGoPath(out startPosition, goPath);
            }
            else
            {
                throw new Exception($"未知情况!{Newtonsoft.Json.JsonConvert.SerializeObject(car)}");
            }
            car.setState(player, ref notifyMsg, CarState.working);
            //car.state = CarState.roadForCollect;
            //  var position = new Model.MapGo.nyrqPosition(fp1.RoadCode, fp1.RoadOrder, fp1.RoadPercent, fp1.positionLongitudeOnRoad, fp1.positionLatitudeOnRoad, Program.dt.GetItemRoadInfo(fp1.RoadCode, fp1.RoadOrder).MaxSpeed);
            Program.dt.GetAFromBPoint(goPath.path[0].path, goPath.path[0].position, speed, ref result, ref startT, player.improvementRecord.speedValue > 0);
            //  result.RemoveAll(item => item.t == 0);

            car.setAnimateData(player, ref notifyMsg, new AnimateData2(startPosition, result, DateTime.Now, false));
        }
Example #6
0
        private void getEndPositon(Model.FastonPosition fp, string car, ref List <Data.PathResult> animateResult, ref int startTInput)
        {
            double endX, endY;

            CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fp.Longitude, fp.Latitde, out endX, out endY);
            int startT0, startT1;

            double startX, startY;

            CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fp.positionLongitudeOnRoad, fp.positionLatitudeOnRoad, out startX, out startY);
            int endT0, endT1;

            //这里要考虑前台坐标系(左手坐标系)。
            var cc = new Complex(startX - endX, (-startY) - (-endY));

            cc = ToOne(cc);

            var     positon1 = cc * (new Complex(-0.309016994, 0.951056516));
            var     positon2 = positon1 * (new Complex(0.809016994, 0.587785252));
            var     positon3 = positon2 * (new Complex(0.809016994, 0.587785252));
            var     positon4 = positon3 * (new Complex(0.809016994, 0.587785252));
            var     positon5 = positon4 * (new Complex(0.809016994, 0.587785252));
            Complex position;

            switch (car)
            {
            case "carA":
            {
                position = positon1;
            }; break;

            case "carB":
            {
                position = positon2;
            }; break;

            case "carC":
            {
                position = positon3;
            }; break;

            case "carD":
            {
                position = positon4;
            }; break;

            case "carE":
            {
                position = positon5;
            }; break;

            default:
            {
                position = positon1;
            }; break;
            }
            var    percentOfPosition = 0.25;
            double carPositionX      = endX + position.Real * percentOfPosition;
            double carPositionY      = endY - position.Imaginary * percentOfPosition;


            /*
             * 这里由于是返程,为了与getStartPositon 中的命名保持一致性,(位置上)end实际为start,时间上还保持一致
             */
            //  List<Data.PathResult> animateResult = new List<Data.PathResult>();

            /*
             * 上道路的速度为10m/s 即36km/h
             */
            var interview = Convert.ToInt32(CommonClass.Geography.getLengthOfTwoPoint.GetDistance(fp.Latitde, fp.Longitude, fp.positionLatitudeOnRoad, fp.positionLongitudeOnRoad) / 10 * 1000);

            startT1      = startTInput;
            endT1        = startT1 + interview;
            startTInput += interview;
            var animate2 = new Data.PathResult()
            {
                t0 = startT1,
                x0 = startX,
                y0 = startY,
                t1 = endT1,
                x1 = endX,
                y1 = endY
            };

            animateResult.Add(animate2);


            startT0      = startTInput;
            endT0        = startT0 + 500;
            startTInput += 500;
            var animate1 = new Data.PathResult()
            {
                t0 = startT0,
                x0 = endX,
                y0 = endY,
                t1 = endT0,
                x1 = carPositionX,
                y1 = carPositionY
            };

            animateResult.Add(animate1);
        }
Example #7
0
        private void EditCarStateWhenAttackStartOK(RoleInGame player, ref Car car, int to, Model.FastonPosition fp1, SetAttack sa, List <Model.MapGo.nyrqPosition> goPath, out int startT, ref List <string> notifyMsg)
        {
            car.targetFpIndex = to;//A.更改小车目标,在其他地方引用。
            car.setPurpose(this._Players[sa.Key], ref notifyMsg, Purpose.attack);
            // car.purpose = Purpose.attack;//B.更改小车目的,小车变为攻击状态!
            //  car.changeState++;//C.更改状态用去前台更新动画

            /*
             * D.更新小车动画参数
             */
            var speed = car.ability.Speed;

            startT = 0;
            //List<Data.PathResult3> result;
            List <int> result;

            Data.PathStartPoint2 startPosition;
            if (car.state == CarState.waitAtBaseStation)
            {
                getStartPositionByFp(out startPosition, fp1);
                result = getStartPositon(fp1, player.positionInStation, ref startT);
            }
            else if (car.state == CarState.waitForCollectOrAttack)
            {
                result = new List <int>();
                getStartPositionByGoPath(out startPosition, goPath);
            }
            else if (car.state == CarState.waitForTaxOrAttack)
            {
                result = new List <int>();
                getStartPositionByGoPath(out startPosition, goPath);
            }
            else if (car.state == CarState.waitOnRoad)
            {
                result = new List <int>();
                getStartPositionByGoPath(out startPosition, goPath);
            }
            else
            {
                throw new Exception("错误的汽车类型!!!");
            }
            car.setState(this._Players[sa.Key], ref notifyMsg, CarState.roadForAttack);
            //car.state = CarState.roadForAttack;
            //  this.SendStateAndPurpose(this._Players[sa.Key], car, ref notifyMsg);


            Program.dt.GetAFromBPoint(goPath, fp1, speed, ref result, ref startT);
            //  result.RemoveAll(item => item.t == 0);

            var animateData = new AnimateData2()
            {
                start       = startPosition,
                animateData = result,
                recordTime  = DateTime.Now
            };

            car.setAnimateData(player, ref notifyMsg, animateData);
            //car.animateData = new AnimateData()
            //{
            //    animateData = result,
            //    recordTime = DateTime.Now
            //};
        }
Example #8
0
        /// <summary>
        /// 获取从基地出来时的路径!
        /// </summary>
        /// <param name="fp">初始地点</param>
        /// <param name="car">carA?-carE</param>
        /// <param name="startTInput">时间</param>
        /// <returns></returns>
        private List <int> getStartPositon(Model.FastonPosition fp, int positionInStation, ref int startTInput)
        {
            double startX, startY;

            CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fp.Longitude, fp.Latitde, out startX, out startY);
            int startT0, startT1;

            double endX, endY;

            CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fp.positionLongitudeOnRoad, fp.positionLatitudeOnRoad, out endX, out endY);
            int endT0, endT1;

            //这里要考虑前台坐标系(左手坐标系)。
            var cc = new Complex(endX - startX, (-endY) - (-startY));

            cc = ToOne(cc);

            var     positon1 = cc * (new Complex(-0.309016994, 0.951056516));
            var     positon2 = positon1 * (new Complex(0.809016994, 0.587785252));
            var     positon3 = positon2 * (new Complex(0.809016994, 0.587785252));
            var     positon4 = positon3 * (new Complex(0.809016994, 0.587785252));
            var     positon5 = positon4 * (new Complex(0.809016994, 0.587785252));
            Complex position;

            switch (positionInStation)
            {
            case 0:
            {
                position = positon1;
            }; break;

            case 1:
            {
                position = positon2;
            }; break;

            case 2:
            {
                position = positon3;
            }; break;

            case 3:
            {
                position = positon4;
            }; break;

            case 4:
            {
                position = positon5;
            }; break;

            default:
            {
                position = positon1;
            }; break;
            }
            var    percentOfPosition = 0.25;
            double carPositionX      = startX + position.Real * percentOfPosition;
            double carPositionY      = startY - position.Imaginary * percentOfPosition;

            List <int> animateResult = new List <int>();

            startT0      = startTInput;
            endT0        = startT0 + 500;
            startTInput += 500;
            var animate1 = new Data.PathResult3()
            {
                x = Convert.ToInt32((startX - carPositionX) * 256),
                y = Convert.ToInt32((startY - carPositionY) * 256),
                t = endT0 - startT0
            };

            //var animate1 = new Data.PathResult()
            //{
            //    t0 = startT0,
            //    x0 = carPositionX,
            //    y0 = carPositionY,
            //    t1 = endT0,
            //    x1 = startX,
            //    y1 = startY
            //};
            if (animate1.t != 0)
            {
                animateResult.Add(animate1.x);
                animateResult.Add(animate1.y);
                animateResult.Add(animate1.t);
            }
            // animateResult.Add(animate1);

            /*
             * 上道路的速度为10m/s 即36km/h
             */
            var interview = Convert.ToInt32(CommonClass.Geography.getLengthOfTwoPoint.GetDistance(fp.Latitde, fp.Longitude, fp.positionLatitudeOnRoad, fp.positionLongitudeOnRoad) / 10 * 1000);

            startT1      = startTInput;
            endT1        = startT1 + interview;
            startTInput += interview;

            var animate2 = new Data.PathResult3()
            {
                x = Convert.ToInt32((endX - startX) * 256),
                y = Convert.ToInt32((endY - startY) * 256),
                t = interview
            };

            //var animate2 = new Data.PathResult()
            //{
            //    t0 = startT1,
            //    x0 = startX,
            //    y0 = startY,
            //    t1 = endT1,
            //    x1 = endX,
            //    y1 = endY
            //};
            if (animate2.t != 0)
            {
                animateResult.Add(animate2.x);
                animateResult.Add(animate2.y);
                animateResult.Add(animate2.t);
            }
            //  animateResult.Add(animate2);
            return(animateResult);
        }