Пример #1
0
 internal void setAnimateData(RoleInGame player, ref List <string> notifyMsg, AnimateData2 data)
 {
     this.animateData = data;
     this._changeState++;
     SetAnimateChanged(player, this, ref notifyMsg);
     //  throw new NotImplementedException();
 }
Пример #2
0
        private void EditCarStateWhenBustStartOK(RoleInGame 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 <int> result;

            Data.PathStartPoint2 startPosition;
            if (car.state == CarState.waitAtBaseStation)
            {
                getStartPositionByFp(out startPosition, fp1);
                result = getStartPositon(fp1, player.positionInStation, 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.t == 0);

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

            car.setAnimateData(player, ref notifyMsg, animateData);
        }
Пример #3
0
        protected void carParkOnRoad(int target, ref Car car, RoleInGame player, ref List <string> notifyMsgs)
        {
            var    fp = Program.dt.GetFpByIndex(target);
            double endX, endY;

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


            var animate = new AnimateData2(
                new Data.PathStartPoint2()
            {
                x = Convert.ToInt32(endX * 256), y = Convert.ToInt32(endY * 256)
            },
                new List <int>()
            {
                0, 0, 20000
            },
                DateTime.Now,
                true
                );

            car.setAnimateData(player, ref notifyMsgs, animate);
        }
Пример #4
0
        void DoCollectTaxF(RoleInGame player, Car car, SetTax st, ref List <string> notifyMsg, out MileResultReason reason)
        {
            var from   = this.getFromWhenDoCollectTax(player, car);
            var to     = st.target;
            var fp1    = Program.dt.GetFpByIndex(from);
            var fp2    = Program.dt.GetFpByIndex(to);
            var baseFp = Program.dt.GetFpByIndex(player.StartFPIndex);

            // var goPath = Program.dt.GetAFromB(from, to);
            var goPath = this.GetAFromB(from, to, player, ref notifyMsg);
            // var returnPath = Program.dt.GetAFromB(to, player.StartFPIndex);
            var returnPath = this.GetAFromB(to, player.StartFPIndex, player, ref notifyMsg);

            var goMile     = GetMile(goPath);
            var returnMile = GetMile(returnPath);

            if (car.ability.leftMile >= goMile + returnMile)
            {
                car.targetFpIndex = to;
                Console.WriteLine($"car的目标设置成了{Program.dt.GetFpByIndex(to).FastenPositionName}");

                car.setPurpose(player, ref notifyMsg, Purpose.tax);
                //car.purpose = Purpose.tax;
                var                  speed  = car.ability.Speed;
                int                  startT = 0;
                List <int>           result;
                Data.PathStartPoint2 startPosition;
                if (car.state == CarState.waitAtBaseStation)
                {
                    result = getStartPositon(fp1, player.positionInStation, ref startT);
                    this.getStartPositionByFp(out startPosition, fp1);
                }
                else if (car.state == CarState.waitForTaxOrAttack)
                {
                    result = new List <int>();
                    if (from == to)
                    {
                        startPosition = null;
                        // this.getStartPositionByFp(out startPosition, fp1);
                    }
                    else
                    {
                        this.getStartPositionByGoPath(out startPosition, goPath);
                    }
                }
                else if (car.state == CarState.waitOnRoad && car.ability.diamondInCar == "" && (car.purpose == Purpose.@null || car.purpose == Purpose.tax))
                {
                    result = new List <int>();
                    if (from == to)
                    {
                        startPosition = null;
                    }
                    else
                    {
                        this.getStartPositionByGoPath(out startPosition, goPath);
                    }
                }
                else
                {
                    throw new Exception($"未知情况!{Newtonsoft.Json.JsonConvert.SerializeObject(car)}");
                }
                car.setState(player, ref notifyMsg, CarState.roadForTax);
                //car.state = CarState.roadForTax;
                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
                //};
                Thread th = new Thread(() => setArrive(startT, new commandWithTime.placeArriving()
                {
                    c   = "placeArriving",
                    key = st.Key,
                    //   car = st.car,
                    returnPath = returnPath,
                    target     = to,
                    costMile   = goMile
                }));
                th.Start();


                reason = MileResultReason.Abundant;

                //   car.changeState++;//更改状态
                car.setPurpose(player, ref notifyMsg, Purpose.tax);
                //car.purpose = Purpose.tax;

                //getAllCarInfomations(st.Key, ref notifyMsg);
            }

            else if (car.ability.leftMile >= goMile)
            {
                //当攻击失败,必须返回
                Console.Write($"去程{goMile},回程{returnMile}");
                Console.Write($"你去了回不来");

#warning 这里要在前台进行提示
                reason = MileResultReason.CanNotReturn;
            }
            else
            {
#warning 这里要在web前台进行提示
                //当攻击失败,必须返回
                Console.Write($"去程{goMile},回程{returnMile}");
                Console.Write($"你去不了");
                reason = MileResultReason.CanNotReach;
            }
        }
Пример #5
0
        private void EditCarStateWhenPromoteStartOK(RoleInGame role, 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 <int> result;

            Data.PathStartPoint2 startPosition;
            if (car.state == CarState.waitOnRoad)
            {
                result = new List <int>();
                getStartPositionByGoPath(out startPosition, goPath);
                //startPosition = new Data.PathStartPoint()
                //{
                //    x = goPath.First().BDlongitude,
                //    y = goPath.First().BDlatitude
                //};
            }
            else if (car.state == CarState.waitAtBaseStation)
            {
                result = getStartPositon(fp1, role.positionInStation, ref startT);
                getStartPositionByFp(out startPosition, fp1);
            }
            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
            {
                Console.WriteLine($"{Newtonsoft.Json.JsonConvert.SerializeObject(car)}");
                throw new Exception("错误的汽车类型!!!");
            }
            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(role, ref nofityMsgs, animateData);
            //car.animateData = new AnimateData()
            //{
            //    animateData = result,
            //    recordTime = DateTime.Now
            //};
            car.setState(role, 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);
        }
Пример #6
0
        /// <summary>
        /// 当没有抢到宝石-或者收集、保护费,在路上待命。
        /// </summary>
        /// <param name="target"></param>
        /// <param name="car"></param>
        private void carParkOnRoad(int target, ref Car car, RoleInGame player, ref List <string> notifyMsgs)
        {
            var    fp = Program.dt.GetFpByIndex(target);
            double endX, endY;

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


            var animate = new AnimateData2()
            {
                start = new Data.PathStartPoint2()
                {
                    x = Convert.ToInt32(endX * 256),
                    y = Convert.ToInt32(endY * 256)
                },
                animateData = new List <int>()
                {
                    0, 0, 20000
                },
                //animateData = new List<Data.PathResult3>()
                //        {
                //              new Data.PathResult3()
                //              {
                //                  x=0,
                //                  y=0,
                //                  t=20000
                //              }
                //        },
                recordTime = DateTime.Now
            };

            car.setAnimateData(player, ref notifyMsgs, animate);
            //car.animateData = new AnimateData()
            //{
            //    animateData = new List<Data.PathResult>()
            //            {
            //                  new Data.PathResult()
            //                  {
            //                      t0=0,
            //                      x0=endX,
            //                      y0=endY,
            //                      t1=200000,
            //                      x1=endX,
            //                      y1=endY
            //                  }
            //            },
            //    recordTime = DateTime.Now
            //};

            if (this.debug)
            {
                //var goPath = Program.dt.GetAFromB(car.targetFpIndex, this.collectPosition);
                //var returnPath = Program.dt.GetAFromB(this.collectPosition, player.StartFPIndex);

                //var goMile = GetMile(goPath);
                //var returnMile = GetMile(returnPath);
                //if (goMile + returnMile > car.ability.leftMile)
                //{
                //    for (int i = 0; i < 3; i++)
                //    {
                //        Console.WriteLine($"现在回收是要返回的!");
                //    }
                //}
            }
        }