Exemplo n.º 1
0
        public void DriverSelected(RoleInGame role, Car car, ref List <string> notifyMsg)
        {
            if (role.playerType == RoleInGame.PlayerType.player)
            {
                var player = (Player)role;
                if (car.ability.driver != null)
                {
                    var url = player.FromUrl;

                    DriverNotify mn = new DriverNotify()
                    {
                        c           = "DriverNotify",
                        WebSocketID = player.WebSocketID,
                        index       = car.ability.driver.Index,
                        name        = car.ability.driver.Name,
                        race        = car.ability.driver.race.ToString(),
                        sex         = car.ability.driver.sex.ToString(),
                        skill1Index = car.ability.driver.skill1.Index,
                        skill1Name  = car.ability.driver.skill1.skillName,
                        skill2Index = car.ability.driver.skill2.Index,
                        skill2Name  = car.ability.driver.skill2.skillName,
                    };

                    var sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(mn);
                    notifyMsg.Add(url);
                    notifyMsg.Add(sendMsg);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 让小车进行攻击
        /// </summary>
        /// <param name="player">玩家</param>
        /// <param name="car">小车</param>
        /// <returns>玩家将钱给小车,小车进行攻击。如果攻击不成(如去不了、去了回不来),应该将钱返回</returns>
        private bool giveMoneyFromPlayerToCarForAttack(RoleInGame player, Car car, ref List <string> notifyMsg)
        {
            var needMoney = car.ability.Business;

            //throw new Exception("");
            if (player.MoneyToAttack < needMoney)
            {
                Console.WriteLine($"");
                return(false);
            }
            else if (car.ability.SumMoneyCanForAttack != 0)
            {
                //初始化失败,小车 comeback后,没有完成交接!!!
                throw new Exception("car.ability.SumMoneyCanForAttack != 0");
            }
            else
            {
                // var m1 = player.GetMoneyCanSave();
                //player.Money -= needMoney;
                player.MoneySet(player.Money - needMoney, ref notifyMsg);

                car.ability.setCostBusiness(needMoney, player, car, ref notifyMsg);
                //   car.ability.costBusiness = needMoney;
                // AbilityChanged(player, car, ref notifyMsg, "business");

                //  var m2 = player.GetMoneyCanSave();
                //  if (m1 != m2)
                {
                    // MoneyCanSaveChanged(player, m2, ref notifyMsg);
                }
                return(true);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 从player将钱转移到car
        /// </summary>
        /// <param name="player"></param>
        /// <param name="car"></param>
        /// <param name="pType"></param>
        /// <returns></returns>
        private bool giveMoneyFromPlayerToCarForPromoting(RoleInGame player, Car car, string pType, ref List <string> notifyMsg)
        {
            var needMoney = this.promotePrice[pType];

            if (player.MoneyToPromote < needMoney)
            {
                return(false);
            }
            else if (car.ability.SumMoneyCanForPromote != 0)
            {
                Console.WriteLine("小车从基站出发,身上的钱,没有清零!");
                //初始化失败,小车 comeback后,没有完成交接!!!
                throw new Exception("car.ability.costBusiness != 0m");
            }
            else
            {
                if (player.Money - needMoney < 0)
                {
                    throw new Exception("逻辑错误");
                }
                player.MoneySet(player.Money - needMoney, ref notifyMsg);
                car.ability.setCostBusiness(car.ability.costBusiness + needMoney, player, car, ref notifyMsg);

                return(true);
            }
        }
Exemplo n.º 4
0
        private int getFromWhenUpdatePromote(RoleInGame player, Car car)
        {
            switch (car.state)
            {
            case CarState.waitAtBaseStation:
            {
                return(player.StartFPIndex);
            };

            case CarState.waitOnRoad:
            {
                //上一个的目标
                if (
                    (car.purpose == Purpose.@null || car.purpose == Purpose.collect) &&
                    car.ability.diamondInCar == "")
                {
                    return(car.targetFpIndex);
                }
                else
                {
                    throw new Exception("");
                }
            };

            case CarState.waitForCollectOrAttack:
            {
                return(car.targetFpIndex);
            };

            default:
            {
                throw new Exception("错误的汽车状态");
            }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 收集失败,安排返回。
 /// </summary>
 /// <param name="car"></param>
 /// <param name="player"></param>
 /// <param name="sc"></param>
 /// <param name="notifyMsg"></param>
 private void collectFailedThenReturn(Car car, RoleInGame player, SetCollect sc, ref List <string> notifyMsg)
 {
     if (car.state == CarState.waitForCollectOrAttack || car.state == CarState.waitOnRoad)
     {
         //Console.Write($"现在剩余容量为{car.ability.leftVolume},总容量为{car.ability.Volume}");
         //Console.Write($"你装不下了!");
         Console.Write($"该汽车被安排回去了");
         var from   = GetFromWhenUpdateCollect(this._Players[sc.Key], sc.cType, car);
         int startT = 1;
         //var carKey = $"{sc.car}_{}";
         var returnPath_Record = this._Players[sc.Key].returningRecord;
         // var returnPath_Record = this.returningRecord(carKey];
         Thread th = new Thread(() => setReturn(startT, new commandWithTime.returnning()
         {
             c          = "returnning",
             key        = sc.Key,
             returnPath = returnPath_Record,
             target     = from,
             changeType = CollectReturn,
         }));
         th.Start();
         //car.changeState++;//更改状态
         //getAllCarInfomations(sc.Key, ref notifyMsg);
     }
     else if (car.state == CarState.waitAtBaseStation)
     {
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 各种原因,使小车从基地里没有出发。小车上的钱必须从下车返回为玩家!
        /// </summary>
        /// <param name="role"></param>
        /// <param name="car"></param>
        private void giveMoneyFromCarToPlayer(RoleInGame role, Car car, ref List <string> notifyMsg)
        {
            //   var m1 = player.GetMoneyCanSave();
            role.MoneySet(role.Money + car.ability.leftBusiness + car.ability.leftVolume, ref notifyMsg);
            //player.Money += car.ability.leftBusiness;
            //player.Money += car.ability.leftVolume;

            //if (car.ability.leftBusiness > 0)
            //    printState(role, car, $"返回基站,通过leftBusiness,是流动资金增加{car.ability.leftBusiness}");
            //if (car.ability.leftVolume > 0)
            //    printState(role, car, $"返回基站,通过leftBusiness,是流动资金增加{car.ability.leftVolume}");
            //if (car.ability.subsidize > 0)
            //{
            //    /*
            //     * 从逻辑上,必须要保证car.ability.subsidize>0,player.SupportToPlay!=null
            //     */
            //    player.setSupportToPlayMoney(player.SupportToPlayMoney + car.ability.subsidize, ref notifyMsg);
            //    //player.SupportToPlayMoney += car.ability.subsidize;
            //    printState(player, car, $"返回基站,返还资助{car.ability.subsidize}");
            //}
            car.Refresh(role, ref notifyMsg);

            if (!string.IsNullOrEmpty(car.ability.diamondInCar))
            {
                role.PromoteDiamondCount[car.ability.diamondInCar]++;
            }
            car.ability.Refresh(role, car, ref notifyMsg);
            //  var m2 = player.GetMoneyCanSave();
            //  if (m1 != m2)
            {
                // MoneyCanSaveChanged(player, m2, ref notifyMsg);
            }
        }
Exemplo n.º 7
0
        private List <OssModel.MapGo.nyrqPosition> GetAFromB(int from, int to, RoleInGame player, ref List <string> notifyMsgs)
        {
            var path = Program.dt.GetAFromB(from, to);

            for (var i = 0; i < path.Count; i++)
            {
                player.addUsedRoad(path[i].roadCode, ref notifyMsgs);
            }
            return(path);
        }
Exemplo n.º 8
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(RoleInGame 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 <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.waitOnRoad && car.ability.diamondInCar == "" && (car.purpose == Purpose.@null || car.purpose == Purpose.collect))
            {
                result = new List <int>();
                getStartPositionByGoPath(out startPosition, goPath);
            }
            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.t == 0);

            car.setAnimateData(player, ref notifyMsg, new AnimateData2()
            {
                start       = startPosition,
                animateData = result,
                recordTime  = DateTime.Now
            });
        }
Exemplo n.º 9
0
        private void bust(RoleInGame player, Car car, SetBust sb, ref List <string> notifyMsg, out MileResultReason Mrr)
        {
            {
                //if (this._Players[sa.targetOwner].Bust)


                {
                    var from   = this.getFromWhenAttack(player, car);
                    var to     = sb.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(fp1, fp2.FastenPositionID);
                    var goPath = this.GetAFromB(from, to, player, ref notifyMsg);
                    // var goPath = Program.dt.GetAFromB(from, to);
                    //var returnPath = Program.dt.GetAFromB(fp2, baseFp.FastenPositionID);
                    var returnPath = this.GetAFromB(to, player.StartFPIndex, player, ref notifyMsg);
                    //var returnPath = Program.dt.GetAFromB(to, player.StartFPIndex);

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


                    //第一步,计算去程和回程。
                    if (car.ability.leftMile >= goMile + returnMile)
                    {
                        int startT;
                        EditCarStateWhenBustStartOK(player, ref car, to, fp1, sb, goPath, out startT, ref notifyMsg);
                        SetBustArrivalThread(startT, car, sb, returnPath);
                        // getAllCarInfomations(sa.Key, ref notifyMsg);
                        Mrr = MileResultReason.Abundant;
                    }

                    else if (car.ability.leftMile >= goMile)
                    {
                        //当攻击失败,必须返回
                        Console.Write($"去程{goMile},回程{returnMile}");
                        Console.Write($"你去了回不来");
                        Mrr = MileResultReason.CanNotReturn;
                    }
                    else
                    {
#warning 这里要在web前台进行提示
                        //当攻击失败,必须返回
                        Console.Write($"去程{goMile},回程{returnMile}");
                        Console.Write($"你去不了");
                        Mrr = MileResultReason.CanNotReach;
                    }
                }
            }
        }
Exemplo n.º 10
0
        bool theNearestToObjIsCarNotMoney(RoleInGame player, Car car, interfaceOfHM.GetFPIndex getF, out OssModel.FastonPosition fp)
        {
            fp = null;
            if (car.state == CarState.waitAtBaseStation)
            {
                double distanceToDiamond;
                var    from = Program.dt.GetFpByIndex(getF.GetFPIndex());
                {
                    var fpTo = Program.dt.GetFpByIndex(player.StartFPIndex);; //this.GetPromotePositionTo(pType);

                    distanceToDiamond = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                }
                foreach (var item in this._collectPosition)
                {
                    //  var from = Program.dt.GetFpByIndex(player.StartFPIndex);
                    var fpTo            = Program.dt.GetFpByIndex(item.Value);
                    var distanceToMoney = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                    if (distanceToMoney <= distanceToDiamond)
                    {
                        distanceToDiamond = distanceToMoney;
                        fp = fpTo;
                        //  return false;
                    }
                }
                return(fp == null);
            }
            else if (car.state == CarState.waitOnRoad)
            {
                var    from = Program.dt.GetFpByIndex(getF.GetFPIndex());
                double distanceToDiamond;
                {
                    var fpTo = Program.dt.GetFpByIndex(car.targetFpIndex);
                    distanceToDiamond = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                }
                foreach (var item in this._collectPosition)
                {
                    var fpTo            = Program.dt.GetFpByIndex(item.Value);
                    var distanceToMoney = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                    if (distanceToMoney <= distanceToDiamond)
                    {
                        distanceToDiamond = distanceToMoney;
                        fp = fpTo;
                    }
                }
                return(fp == null);
            }
            else
            {
                throw new Exception("非法调用");
            }
        }
Exemplo n.º 11
0
        private void tellMyRightAndDutyToOther(RoleInGame self, Player other, ref List <string> notifyMsg)
        {
            /*
             * 三种情况下应该被调用。
             * 第一种情况,启动。
             * 第二种情况,攻击。
             * 第三种情况,参数变更。
             */
            long right;
            int  rightPercent;
            long duty;
            int  dutyPercent;

            if (self.DebtsContainsKey(other.Key))
            {
                right        = self.DebtsGet(other.Key);
                rightPercent = self.DebtsPercent(other.Key);
            }
            else
            {
                right        = 0;
                rightPercent = 0;
            }

            if (other.DebtsContainsKey(self.Key))
            {
                duty        = other.DebtsGet(self.Key);
                dutyPercent = other.DebtsPercent(self.Key);
            }
            else
            {
                duty        = 0;
                dutyPercent = 0;
            }

            var obj = new BradCastRightAndDuty
            {
                c            = "BradCastRightAndDuty",
                right        = right,
                duty         = duty,
                WebSocketID  = other.WebSocketID,
                playerKey    = self.Key,
                rightPercent = rightPercent,
                dutyPercent  = dutyPercent
            };
            var json = Newtonsoft.Json.JsonConvert.SerializeObject(obj);

            notifyMsg.Add(other.FromUrl);
            notifyMsg.Add(json);
        }
Exemplo n.º 12
0
 private void NPCAutoControlCollect(RoleInGame role)
 {
     if (role.playerType == RoleInGame.PlayerType.NPC)
     {
         if (role.getCar().ability.costVolume >= role.getCar().ability.Volume)
         {
             SetNPCToDoSomeThing((NPC)role, NPCAction.Attack);
         }
         else
         {
             SetNPCToDoSomeThing((NPC)role, NPCAction.Collect);
         }
     }
 }
Exemplo n.º 13
0
 private void SendMaxHolderInfoMation(RoleInGame player, ref List <string> notifyMsgs)
 {
     foreach (var item in this._Players)
     {
         //  if (player.Key == item.Key) { }
         //else
         {
             if (item.Value.TheLargestHolderKey == item.Key)
             {
                 this.TheLargestHolderKeyChanged(item.Key, player.Key, player.Key, ref notifyMsgs);
             }
         }
     }
 }
Exemplo n.º 14
0
 public static ReturningOjb ojbWithBoss(
     Node returnToBossAddrPath,
     Node returnToSelfAddrPath,
     RoleInGame Boss
     )
 {
     return(new ReturningOjb()
     {
         Boss = Boss,
         NeedToReturnBoss = true,
         returnToBossAddrPath = returnToBossAddrPath,
         returnToSelfAddrPath = returnToSelfAddrPath
     });
 }
Exemplo n.º 15
0
        int getAttackerClosestPositionRankNum(RoleInGame player, Car car, interfaceOfHM.GetFPIndex getF)
        {
            int rank = 0;

            if (car.state == CarState.waitAtBaseStation)
            {
                double distanceToDiamond;
                var    from = Program.dt.GetFpByIndex(getF.GetFPIndex());
                {
                    var fpTo = Program.dt.GetFpByIndex(player.StartFPIndex);; //this.GetPromotePositionTo(pType);

                    distanceToDiamond = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                }
                foreach (var item in this._collectPosition)
                {
                    //  var from = Program.dt.GetFpByIndex(player.StartFPIndex);
                    var fpTo            = Program.dt.GetFpByIndex(item.Value);
                    var distanceToMoney = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                    if (distanceToMoney <= distanceToDiamond)
                    {
                        rank++;
                    }
                }
                return(rank);
            }
            else if (car.state == CarState.waitOnRoad)
            {
                var    from = Program.dt.GetFpByIndex(getF.GetFPIndex());
                double distanceToDiamond;
                {
                    var fpTo = Program.dt.GetFpByIndex(car.targetFpIndex);
                    distanceToDiamond = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                }
                foreach (var item in this._collectPosition)
                {
                    var fpTo            = Program.dt.GetFpByIndex(item.Value);
                    var distanceToMoney = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                    if (distanceToMoney <= distanceToDiamond)
                    {
                        rank++;
                    }
                }
                return(rank);
            }
            else
            {
                throw new Exception("非法调用");
            }
        }
Exemplo n.º 16
0
        private int getFromWhenDoCollectTax(RoleInGame player, Car car)
        {
            switch (car.state)
            {
            case CarState.waitAtBaseStation:
            {
                return(player.StartFPIndex);
            };

            case CarState.waitOnRoad:
            {
                //小车的上一个的目标
                if (car.targetFpIndex == -1)
                {
                    throw new Exception("参数混乱");
                }
                else if (car.purpose == Purpose.tax || car.purpose == Purpose.@null)
                {
                    return(car.targetFpIndex);
                }
                else
                {
                    //出现这种情况,应该是回了基站里没有初始
                    throw new Exception("参数混乱");
                }
            };

            case CarState.waitForTaxOrAttack:
            {
                if (car.targetFpIndex == -1)
                {
                    throw new Exception("参数混乱");
                }
                else if (car.purpose == Purpose.tax)
                {
                    return(car.targetFpIndex);
                }
                else
                {
                    throw new Exception("参数混乱");
                }
            };

            default:
            {
                throw new Exception("错误的汽车状态");
            }
            }
        }
Exemplo n.º 17
0
 private bool CheckIsPartner(NPC npc_Operate, RoleInGame roleItem)
 {
     if (npc_Operate.Key == roleItem.Key)
     {
         return(true);
     }
     else if (roleItem.TheLargestHolderKey == npc_Operate.TheLargestHolderKey)
     {
         return(true);
     }
     else
     {
         return(false);
     }
     //return roleItem.TheLargestHolderKey == npc_Operate.Key || roleItem.Key == npc_Operate.challenger;
 }
Exemplo n.º 18
0
 internal void SetAnimateChanged(RoleInGame player, Car car, ref List <string> notifyMsg)
 {
     lock (this.PlayerLock)
     {
         var key     = player.Key;
         var players = getGetAllRoles();
         for (var i = 0; i < players.Count; i++)
         {
             if (players[i].Key == key)
             {
             }
             else
             {
                 {
                     /*
                      * 告诉自己,场景中有哪些别人的车!
                      * 告诉别人,场景中有哪些车是我的的!
                      */
                     {
                         var self  = this._Players[key];
                         var other = players[i];
                         if (self.playerType == RoleInGame.PlayerType.player)
                         {
                             addPlayerCarRecord((Player)self, other, ref notifyMsg);
                         }
                     }
                     {
                         var self  = players[i];
                         var other = this._Players[key];
                         if (self.playerType == RoleInGame.PlayerType.player)
                         {
                             addPlayerCarRecord((Player)self, other, ref notifyMsg);
                         }
                     }
                 }
             }
         }
         {
             var self = this._Players[key];
             if (self.playerType == RoleInGame.PlayerType.player)
             {
                 addSelfCarSingleRecord((Player)self, car, ref notifyMsg);
             }
         }
     }
 }
Exemplo n.º 19
0
 private string NPCAutoControlTax(RoleInGame role)
 {
     if (role.playerType == RoleInGame.PlayerType.NPC)
     {
         if (role.getCar().ability.costBusiness >= role.getCar().ability.Business)
         {
             return(this.SetNPCToDoSomeThing((NPC)role, NPCAction.Attack));
         }
         else
         {
             return(this.SetNPCToDoSomeThing((NPC)role, NPCAction.Tax));
         }
     }
     else
     {
         return("");
     }
 }
Exemplo n.º 20
0
        private void addPlayerRecord(RoleInGame self, RoleInGame other, ref List <string> msgsWithUrl)
        {
            if (self.Key == other.Key)
            {
                return;
            }
            if (self.othersContainsKey(other.Key))
            {
            }
            else
            {
                var otherPlayer = new OtherPlayers(self.Key, other.Key);
                //   otherPlayer.brokenParameterT1RecordChangedF = self.brokenParameterT1RecordChanged;
                self.othersAdd(other.Key, otherPlayer);
                //otherPlayer.setBrokenParameterT1Record(other.brokenParameterT1, ref msgsWithUrl);

                var fp = Program.dt.GetFpByIndex(other.StartFPIndex);
                // fromUrl = this._Players[getPosition.Key].FromUrl;
                if (self.playerType == RoleInGame.PlayerType.player)
                {
                    var webSocketID = ((Player)self).WebSocketID;
                    //var carsNames = other.ca;

                    //  var fp=  players[i].StartFPIndex
                    CommonClass.GetOthersPositionNotify_v2 notify = new CommonClass.GetOthersPositionNotify_v2()
                    {
                        c                 = "GetOthersPositionNotify_v2",
                        fp                = fp,
                        WebSocketID       = webSocketID,
                        key               = other.Key,
                        PlayerName        = other.PlayerName,
                        fPIndex           = other.StartFPIndex,
                        positionInStation = other.positionInStation,
                        isNPC             = other.playerType == RoleInGame.PlayerType.NPC,
                        isPlayer          = other.playerType == RoleInGame.PlayerType.player,
                        Level             = other.Level

                                            // var xx=  getPosition.Key
                    };
                    msgsWithUrl.Add(((Player)self).FromUrl);
                    msgsWithUrl.Add(Newtonsoft.Json.JsonConvert.SerializeObject(notify));
                }
            }
        }
Exemplo n.º 21
0
        internal void confusePrepareMagicChanged(RoleInGame role, ref List <string> notifyMsgs)
        {
            foreach (var item in this._Players)
            {
                if (item.Value.playerType == RoleInGame.PlayerType.player)
                {
                    var player = (Player)item.Value;
                    var url    = player.FromUrl;
                    var On     = !string.IsNullOrEmpty(role.getCar().isControllingKey);
                    if (this._Players.ContainsKey(role.getCar().isControllingKey))
                    {
                        var victim = this._Players[role.getCar().isControllingKey];
                        if (On)
                        {
                            var    carPosition = Program.dt.GetFpByIndex(role.getCar().targetFpIndex);
                            double startX, startY;
                            CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(carPosition.Longitude, carPosition.Latitde, out startX, out startY);
                            var    targetPosition = Program.dt.GetFpByIndex(victim.StartFPIndex);
                            double endX, endY;
                            CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(targetPosition.Longitude, targetPosition.Latitde, out endX, out endY);

                            ConfusePrepareNotify an = new ConfusePrepareNotify()
                            {
                                c           = "ConfusePrepareNotify",
                                WebSocketID = player.WebSocketID,
                                Key         = role.Key,
                                On          = On,
                                StartX      = Convert.ToInt32(startX * 256),
                                StartY      = Convert.ToInt32(startY * 256),
                                EndX        = Convert.ToInt32(endX * 256),
                                EndY        = Convert.ToInt32(endY * 256)
                            };

                            var sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(an);
                            notifyMsgs.Add(url);
                            notifyMsgs.Add(sendMsg);
                        }
                        else
                        {
                        }
                    }
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="player"></param>
        /// <param name="car"></param>
        /// <param name="sp"></param>
        /// <param name="notifyMsg"></param>
        /// <returns>true:表示已执行;false,表示各种原因(去不了、去了回不来)未执行。</returns>
        bool promote(RoleInGame player, Car car, SetPromote sp, ref List <string> notifyMsg, out MileResultReason reason)
        {
            var from = this.getFromWhenUpdatePromote(player, car);
            var to   = GetPromotePositionTo(sp.pType);//  this.promoteMilePosition;

            var fp1    = Program.dt.GetFpByIndex(from);
            var fp2    = Program.dt.GetFpByIndex(to);
            var baseFp = Program.dt.GetFpByIndex(player.StartFPIndex);

            //var goPath = Program.dt.GetAFromB(fp1, fp2.FastenPositionID);
            //var returnPath = Program.dt.GetAFromB(fp2, baseFp.FastenPositionID);
            // 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)
            {
                int startT;
                EditCarStateWhenPromoteStartOK(player, ref car, to, fp1, to, sp, goPath, ref notifyMsg, out startT);
                StartDiamondOwnerThread(startT, car, sp, returnPath, goMile);
                //  getAllCarInfomations(sp.Key, ref notifyMsg);
                reason = MileResultReason.Abundant;
                return(true);
            }

            else if (car.ability.leftMile >= goMile)
            {
                printState(player, car, $"去程{goMile},回程{returnMile},去了回不来");
                reason = MileResultReason.CanNotReturn;
                return(false);
            }
            else
            {
                printState(player, car, $"去程{goMile},回程{returnMile},去不了");
                reason = MileResultReason.CanNotReach;
                return(false);
            }
        }
Exemplo n.º 23
0
 private async void IfIsNPCBuyThenUseDiamond(RoleInGame player, Car car)
 {
     if (player.playerType == RoleInGame.PlayerType.NPC)
     {
         Buy(new SetBuyDiamond()
         {
             c     = "SetBuyDiamond",
             Key   = player.Key,
             pType = "mile"
         });
         var xx = Program.rm.SetAbility(new CommonClass.SetAbility()
         {
             c     = "SetAbility",
             Key   = player.Key,
             pType = "mile"
         });
     }
     //throw new NotImplementedException();
 }
Exemplo n.º 24
0
        internal void ConfigMagic(RoleInGame role)
        {
            role.confuseRecord              = new Manager_Driver.ConfuseManger();
            role.improvementRecord          = new Manager_Driver.ImproveManager();
            role.speedMagicChanged          = this.speedMagicChanged;
            role.attackMagicChanged         = this.attackMagicChanged;
            role.defenceMagicChanged        = this.defenceMagicChanged;
            role.confusePrepareMagicChanged = this.confusePrepareMagicChanged;
            role.lostPrepareMagicChanged    = this.lostPrepareMagicChanged;
            role.ambushPrepareMagicChanged  = this.ambushPrepareMagicChanged;
            role.controlPrepareMagicChanged = this.controlPrepareMagicChanged;

            role.confuseMagicChanged = this.confuseMagicChanged;
            role.loseMagicChanged    = this.loseMagicChanged;

            role.fireMagicChanged     = this.fireMagicChanged;
            role.waterMagicChanged    = this.waterMagicChanged;
            role.electricMagicChanged = this.electricMagicChanged;
        }
Exemplo n.º 25
0
        internal void ViewPosition(RoleInGame role, FastonPosition fpResult, ref List <string> notifyMsg)
        {
            if (role.playerType == RoleInGame.PlayerType.player)
            {
                var        player = (Player)role;
                var        url    = player.FromUrl;
                ViewSearch sn     = new ViewSearch()
                {
                    c           = "ViewSearch",
                    WebSocketID = player.WebSocketID,
                    mctX        = fpResult.MacatuoX,
                    mctY        = fpResult.MacatuoY
                };

                var sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(sn);
                notifyMsg.Add(url);
                notifyMsg.Add(sendMsg);
            }
        }
Exemplo n.º 26
0
        private int getFromWhenAttack(RoleInGame role, Car car)
        {
            switch (car.state)
            {
            case CarState.waitAtBaseStation:
            {
                return(role.StartFPIndex);
            };

            case CarState.waitOnRoad:
            {
                //小车的上一个的目标
                if (car.targetFpIndex == -1)
                {
                    throw new Exception("参数混乱");
                }
                else if (car.purpose == Purpose.collect || car.purpose == Purpose.@null)
                {
                    return(car.targetFpIndex);
                }
                else
                {
                    //出现这种情况,应该是回了基站里没有初始
                    throw new Exception("参数混乱");
                }
            };

            case CarState.waitForCollectOrAttack:
            {
                return(car.targetFpIndex);
            };

            case CarState.waitForTaxOrAttack:
            {
                return(car.targetFpIndex);
            }; break;

            default:
            {
                throw new Exception($"错误的汽车状态:{car.state.ToString()}");
            }
            }
        }
Exemplo n.º 27
0
 private void addPlayerCarRecord(Player self, RoleInGame other, ref List <string> msgsWithUrl)
 {
     //这是发送给self的消息
     //throw new NotImplementedException();
     if (self.othersContainsKey(other.Key))
     {
         //for (var indexOfCar = 0; indexOfCar < 5; indexOfCar++)
         {
             if (self.GetOthers(other.Key).getCarState() == other.getCar().changeState)
             {
             }
             else
             {
                 if (other.getCar().animateData == null)
                 {
                 }
                 else
                 {
                     var deltaT = (DateTime.Now - other.getCar().animateData.recordTime).TotalMilliseconds;
                     var result = new
                     {
                         deltaT      = deltaT > Int32.MaxValue ? Int32.MaxValue : Convert.ToInt32(deltaT),
                         animateData = other.getCar().animateData.animateData,
                         start       = other.getCar().animateData.start,
                         isParking   = other.getCar().animateData.isParking
                     };
                     var obj = new BradCastAnimateOfOthersCar2
                     {
                         c           = "BradCastAnimateOfOthersCar2",
                         Animate     = result,
                         WebSocketID = self.WebSocketID,
                         carID       = getCarName() + "_" + other.Key,
                         parentID    = other.Key,
                     };
                     var json = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
                     msgsWithUrl.Add(self.FromUrl);
                     msgsWithUrl.Add(json);
                 }
                 self.GetOthers(other.Key).setCarState(other.getCar().changeState);
             }
         }
     }
 }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
0
 public bool isAtTheSameGroup(RoleInGame player, RoleInGame victim)
 {
     if (player.TheLargestHolderKey == victim.Key)
     {
         return(true);
     }
     else if (victim.TheLargestHolderKey == player.Key)
     {
         //Msg = $"[{victim.PlayerName}]是你的小弟,只能发挥出攻击效率的10%";
         return(true);
     }
     else if (victim.TheLargestHolderKey == player.TheLargestHolderKey)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 30
0
 private void BustChangedF(RoleInGame role, bool bustValue, ref List <string> msgsWithUrl)
 {
     foreach (var item in this._Players)
     {
         if (item.Value.playerType == RoleInGame.PlayerType.player)
         {
             var player = (Player)item.Value;
             msgsWithUrl.Add(player.FromUrl);
             BustStateNotify tn = new BustStateNotify()
             {
                 c           = "BustStateNotify",
                 Bust        = bustValue,
                 WebSocketID = player.WebSocketID,
                 Key         = player.Key
             };
             var json = Newtonsoft.Json.JsonConvert.SerializeObject(tn);
             msgsWithUrl.Add(json);
         }
     }
 }