コード例 #1
0
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan)
        {
            foreach (FloatMenuOption o in base.GetFloatMenuOptions(caravan))
            {
                yield return(o);
            }

            var player = this.Player;

            // Передача товара
            var  minCostForTrade = 25000; // эту цифру изменять вместе с ServerManager.DoWorld()
            bool disTrade        = false;

            if (SessionClientController.Data.ProtectingNovice)
            {
                var costAll = player.CostAllWorldObjects();
                disTrade = player.Public.LastTick < 3600000 / 2 || costAll.MarketValue + costAll.MarketValuePawn < minCostForTrade;
            }
            var fmoTrade = new FloatMenuOption("OCity_Caravan_Trade".Translate(OnlinePlayerLogin + " " + OnlineName)
                                               + (disTrade ? "OCity_Caravan_Abort".Translate().ToString() + " " + minCostForTrade.ToString() : "") // "Вам нет года или стоимость меньше" You are under a year old or cost less than
                                               , delegate
            {
                caravan.pather.StartPath(this.Tile, new CaravanArrivalAction_VisitOnline(this, "exchangeOfGoods"), true);
            }, MenuOptionPriority.Default, null, null, 0f, null, this);

            if (disTrade)
            {
                fmoTrade.Disabled = true;
            }
            yield return(fmoTrade);

            // Атаковать
            if (SessionClientController.My.EnablePVP &&
                this is BaseOnline &&
                GameAttacker.CanStart)
            {
                var dis = AttackUtils.CheckPossibilityAttack(SessionClientController.Data.MyEx
                                                             , player
                                                             , UpdateWorldController.GetMyByLocalId(caravan.ID).ServerId
                                                             , this.OnlineWObject.ServerId
                                                             , SessionClientController.Data.ProtectingNovice
                                                             );
                var fmo = new FloatMenuOption("OCity_Caravan_Attack".Translate(OnlinePlayerLogin + " " + OnlineName)
                                              + (dis != null ? " (" + dis + ")" : "")
                                              , delegate
                {
                    caravan.pather.StartPath(this.Tile, new CaravanArrivalAction_VisitOnline(this, "attack"), true);
                }, MenuOptionPriority.Default, null, null, 0f, null, this);

                if (dis != null)
                {
                    fmo.Disabled = true;
                }

                yield return(fmo);
            }
            //}
        }
コード例 #2
0
ファイル: CaravanOnline.cs プロジェクト: natsfr/OnlineCity
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan)
        {
            foreach (FloatMenuOption o in base.GetFloatMenuOptions(caravan))
            {
                yield return(o);
            }

            yield return(new FloatMenuOption("OCity_Caravan_Trade".Translate(OnlinePlayerLogin + " " + OnlineName), delegate
            {
                caravan.pather.StartPath(this.Tile, new CaravanArrivalAction_VisitOnline(this, "exchangeOfGoods"), true);
            }, MenuOptionPriority.Default, null, null, 0f, null, this));

            if (SessionClientController.My.EnablePVP &&
                this is BaseOnline &&
                GameAttacker.CanStart)
            {
                var dis = AttackUtils.CheckPossibilityAttack(SessionClientController.Data.MyEx
                                                             , this.Player
                                                             , UpdateWorldController.GetMyByLocalId(caravan.ID).ServerId
                                                             , this.OnlineWObject.ServerId
                                                             );
                var fmo = new FloatMenuOption("OCity_Caravan_Attack".Translate(OnlinePlayerLogin + " " + OnlineName)
                                              + (dis != null ? " (" + dis + ")" : "")
                                              , delegate
                {
                    caravan.pather.StartPath(this.Tile, new CaravanArrivalAction_VisitOnline(this, "attack"), true);
                }, MenuOptionPriority.Default, null, null, 0f, null, this);

                if (dis != null)
                {
                    fmo.Disabled = true;
                }

                yield return(fmo);
            }
            //}
        }