コード例 #1
0
 internal void setDebtT(int startT, Car car, SetAttack sa, int goMile, RoomMainF.RoomMain.commandWithTime.ReturningOjb ro)
 {
     this.startNewThread(startT, new commandWithTime.debtOwner()
     {
         c   = "debtOwner",
         key = sa.Key,
         //  car = sa.car,
         // returnPath = returnPath,
         target       = car.targetFpIndex,//新的起点
         changeType   = returnning.ChangeType.BeforeTax,
         victim       = sa.targetOwner,
         costMile     = goMile,
         returningOjb = ro
     }, this);
     //Thread th = new Thread(() => setDebt(startT,);
     //th.Start();
 }
コード例 #2
0
        internal void StartDiamondOwnerThread(int startT, int step, RoleInGame player, Car car, SetPromote sp, RoomMainF.RoomMain.commandWithTime.ReturningOjb ro, int goMile, Node goPath)
        {
            System.Threading.Thread th = new System.Threading.Thread(() =>
            {
                if (step >= goPath.path.Count - 1)
                {
                    this.startNewThread(startT + 100, new commandWithTime.diamondOwner()
                    {
                        c            = "diamondOwner",
                        key          = sp.Key,
                        target       = car.targetFpIndex,//新的起点
                        changeType   = commandWithTime.returnning.ChangeType.BeforeTax,
                        costMile     = goMile,
                        returningOjb = ro,
                        diamondType  = sp.pType
                    }, this);
                }
                //that.debtE.setDebtT(startT, car, sa, goMile, ro);
                //this.startNewThread(startT, new commandWithTime.defenseSet()
                //{
                //    c = command,
                //    changeType = commandWithTime.returnning.ChangeType.BeforeTax,
                //    costMile = goMile,
                //    key = ms.Key,
                //    returningOjb = ro,
                //    target = car.targetFpIndex,
                //    beneficiary = ms.targetOwner
                //}, this);
                else
                {
                    if (step == 0)
                    {
                        this.ThreadSleep(startT);
                        if (player.playerType == RoleInGame.PlayerType.NPC || player.Bust)
                        {
                        }
                        else
                        {
                            StartSelectThread(goPath.path[step].selections, goPath.path[step].selectionCenter, (Player)player);
                        }

                        List <string> notifyMsg = new List <string>();
                        int newStartT;
                        step++;
                        if (step < goPath.path.Count)
                        {
                            EditCarStateAfterSelect(step, player, ref car, goPath, ref notifyMsg, out newStartT);
                        }
                        else
                        {
                            newStartT = 0;
                        }

                        car.setState(player, ref notifyMsg, CarState.working);
                        this.sendMsg(notifyMsg);
                        //string command, int startT, int step, RoleInGame player, Car car, MagicSkill ms, int goMile, Node goPath, commandWithTime.ReturningOjb ro
                        StartDiamondOwnerThread(newStartT, step, player, car, sp, ro, goMile, goPath);
                    }
                    else
                    {
                        this.ThreadSleep(startT);
                        if (player.playerType == RoleInGame.PlayerType.NPC || player.Bust)
                        {
                        }
                        else if (startT != 0)
                        {
                            StartSelectThread(goPath.path[step].selections, goPath.path[step].selectionCenter, (Player)player);
                        }
                        step++;
                        List <string> notifyMsg = new List <string>();
                        int newStartT;
                        if (step < goPath.path.Count)
                        {
                            EditCarStateAfterSelect(step, player, ref car, goPath, ref notifyMsg, out newStartT);
                        }
                        // else if(step==goPath.path.Count-1)
                        //EditCarStateAfterSelect(step,player,ref car,)
                        else
                        {
                            throw new Exception("这种情况不会出现");
                        }
                        //newStartT = 0;
                        car.setState(player, ref notifyMsg, CarState.working);
                        this.sendMsg(notifyMsg);
                        StartDiamondOwnerThread(newStartT, step, player, car, sp, ro, goMile, goPath);
                    }
                }
            });
            th.Start();
            //throw new NotImplementedException();

            //Thread th = new Thread(() => setDiamondOwner(startT, ));
            //th.Name = $"{sp.Key}-DiamondOwner";
            //th.Start();
        }
コード例 #3
0
ファイル: Engine.cs プロジェクト: sxtgyrq/VRPGame
        internal string updateAction(interfaceOfEngine.tryCatchAction actionDo, Command c, string operateKey)
        {
            string conditionNotReason;

            if (actionDo.conditionsOk(c, out conditionNotReason))
            {
                List <string> notifyMsg = new List <string>();
                lock (that.PlayerLock)
                {
                    if (that._Players.ContainsKey(operateKey))
                    {
                        if (that._Players[operateKey].Bust)
                        {
                        }
                        else
                        {
                            var player = that._Players[operateKey];
                            var car    = that._Players[operateKey].getCar();
                            switch (car.state)
                            {
                            case CarState.waitAtBaseStation:
                            case CarState.waitOnRoad:
                            {
                                if (actionDo.carAbilitConditionsOk(player, car, c))
                                {
                                    MileResultReason mrr;
                                    RoomMainF.RoomMain.commandWithTime.ReturningOjb returningOjb = actionDo.maindDo(player, car, c, ref notifyMsg, out mrr);
                                    if (mrr == MileResultReason.Abundant)
                                    {
                                        player.returningOjb = returningOjb;
                                    }
                                    else if (mrr == MileResultReason.CanNotReach)
                                    {
                                        actionDo.failedThenDo(car, player, c, ref notifyMsg);
                                        this.WebNotify(player, "小车不能到达目的地,被安排返回!");
                                    }
                                    else if (mrr == MileResultReason.CanNotReturn)
                                    {
                                        actionDo.failedThenDo(car, player, c, ref notifyMsg);
                                        this.WebNotify(player, "小车到达目的地后不能返回,在当前地点安排返回!");
                                    }
                                    else if (mrr == MileResultReason.MoneyIsNotEnougt)
                                    {
                                        actionDo.failedThenDo(car, player, c, ref notifyMsg);
                                    }
                                    else if (mrr == MileResultReason.NearestIsMoneyWhenPromote)
                                    {
                                    }
                                    else if (mrr == MileResultReason.NearestIsMoneyWhenAttack)
                                    {
                                        // this.WebNotify(player, $"离宝石最近的是钱,不是你的车。请离宝石再近点儿!");
                                    }
                                }
                                else
                                {
                                    actionDo.failedThenDo(car, player, c, ref notifyMsg);
                                }
                            }; break;

                            case CarState.working:
                            {
                                this.WebNotify(player, "您的小车正在赶往目标!");
                            }; break;

                            case CarState.returning:
                            {
                                WebNotify(player, "您的小车正在返回!");
                            }; break;
                            }
                            //  MeetWithNPC(sa);
                        }
                    }
                }
                this.sendMsg(notifyMsg);
                //for (var i = 0; i < notifyMsg.Count; i += 2)
                //{
                //    var url = notifyMsg[i];
                //    var sendMsg = notifyMsg[i + 1];
                //    //Console.WriteLine($"url:{url}");
                //    if (!string.IsNullOrEmpty(url))
                //    {
                //        Startup.sendMsg(url, sendMsg);
                //    }
                //}
                return("");
            }
            else
            {
                return(conditionNotReason);
            }
        }
コード例 #4
0
        private commandWithTime.ReturningOjb promotePassBossAddress(RoleInGame player, RoleInGame boss, Car car, SetPromote sp, ref List <string> notifyMsg, out MileResultReason mrr)
        {
            switch (sp.pType)
            {
            case "mile":
            case "business":
            case "volume":
            case "speed":
            {
                switch (car.state)
                {
                case CarState.waitAtBaseStation:
                {
                    // if(player.Money<)
                    //int collectIndex;
                    OssModel.FastonPosition fpResult;
                    var distanceIsEnoughToStart = that.theNearestToDiamondIsCarNotMoney(player, car, sp.pType, out fpResult);
                    if (distanceIsEnoughToStart)
                    {
                        var from = this.getFromWhenAction(player, car);
                        var to   = that.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 = that.GetAFromB_v2(from, to, player, ref notifyMsg);
                        // var returnPath = Program.dt.GetAFromB(to, player.StartFPIndex);
                        var returnToBossPath = that.GetAFromB_v2(to, boss.StartFPIndex, player, ref notifyMsg);
                        var returnToSelfPath = that.GetAFromB_v2(boss.StartFPIndex, player.StartFPIndex, player, ref notifyMsg);

                        var goMile           = that.GetMile(goPath);
                        var returnToBossMile = that.GetMile(returnToBossPath);
                        var returnToSelfMile = that.GetMile(returnToSelfPath);

                        //第一步,计算去程和回程。
                        if (car.ability.leftMile >= goMile + returnToBossMile + returnToSelfMile)
                        {
                            int startT;
                            this.EditCarStateWhenActionStartOK(player, ref car, to, fp1, goPath, ref notifyMsg, out startT);
                            RoomMainF.RoomMain.commandWithTime.ReturningOjb ro = commandWithTime.ReturningOjb.ojbWithBoss(returnToBossPath, returnToSelfPath, boss);
                            that.diamondOwnerE.StartDiamondOwnerThread(startT, 0, player, car, sp, ro, goMile, goPath);
                            //  getAllCarInfomations(sp.Key, ref notifyMsg);
                            mrr = MileResultReason.Abundant;
                            return(ro);
                        }

                        else if (car.ability.leftMile >= goMile)
                        {
                            WebNotify(player, $"去程{goMile}km,回程{returnToBossMile + returnToSelfMile}km,去了回不来");
                            mrr = MileResultReason.CanNotReturn;
                            return(player.returningOjb);
                        }
                        else
                        {
                            WebNotify(player, $"去程{goMile}km,回程{returnToBossMile + returnToSelfMile}km,去不了");
                            // printState(player, car, $"去程{goMile},回程{returnMile},去不了");
                            mrr = MileResultReason.CanNotReach;
                            return(player.returningOjb);
                        }
                    }
                    else
                    {
                        mrr = MileResultReason.NearestIsMoneyWhenPromote;
                        this.WebNotify(player, $"离宝石最近的是[{fpResult.FastenPositionName}]处的钱,不是你的车。请离宝石再近点儿!");
                        return(player.returningOjb);
                        //printState(player, car, "钱不够了,由于本身待在基地,不用返回。");
                    }
                };

                case CarState.waitOnRoad:
                {
                    OssModel.FastonPosition fpResult;
                    var distanceIsEnoughToStart = that.theNearestToDiamondIsCarNotMoney(player, car, sp.pType, out fpResult);
                    if (distanceIsEnoughToStart)
                    {
                        var from = this.getFromWhenAction(player, car);
                        var to   = that.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 = that.GetAFromB_v2(from, to, player, ref notifyMsg);

                        var returnToBossPath = that.GetAFromB_v2(to, boss.StartFPIndex, player, ref notifyMsg);
                        var returnToSelfPath = that.GetAFromB_v2(boss.StartFPIndex, player.StartFPIndex, player, ref notifyMsg);

                        var goMile           = that.GetMile(goPath);
                        var returnToBossMile = that.GetMile(returnToBossPath);
                        var returnToSelfMile = that.GetMile(returnToSelfPath);


                        //第一步,计算去程和回程。
                        if (car.ability.leftMile >= goMile + returnToBossMile + returnToSelfMile)
                        {
                            int startT;
                            this.EditCarStateWhenActionStartOK(player, ref car, to, fp1, goPath, ref notifyMsg, out startT);

                            RoomMainF.RoomMain.commandWithTime.ReturningOjb ro = commandWithTime.ReturningOjb.ojbWithBoss(returnToBossPath, returnToSelfPath, boss);
                            that.diamondOwnerE.StartDiamondOwnerThread(startT, 0, player, car, sp, ro, goMile, goPath);
                            mrr = MileResultReason.Abundant;
                            return(ro);
                        }

                        else if (car.ability.leftMile >= goMile)
                        {
                            WebNotify(player, $"去程{goMile}km,回程{returnToBossMile + returnToSelfMile}km,去了回不来");
                            mrr = MileResultReason.CanNotReturn;
                            return(player.returningOjb);
                        }
                        else
                        {
                            WebNotify(player, $"去程{goMile}km,回程{returnToBossMile + returnToSelfMile}km,去不了");
                            mrr = MileResultReason.CanNotReach;
                            return(player.returningOjb);
                        }
                    }
                    else
                    {
                        mrr = MileResultReason.NearestIsMoneyWhenPromote;
                        this.WebNotify(player, $"离宝石最近的是[{fpResult.FastenPositionName}]处的钱,不是你的车。请离宝石再近点儿!");
                        return(player.returningOjb);
                    }
                };

                default:
                {
                    throw new Exception($"{Enum.GetName(typeof(CarState), car.state)}不是注册的类型!");
                }
                }
            };

            default:
            {
                throw new Exception($"{sp.pType}-不是规定的输入!");
            };
            }
        }