示例#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
        public string New(PlayerServer player, PlayerServer hostPlayer, AttackInitiatorToSrv fromClient, bool testMode)
        {
            if (ServerManager.ServerSettings.GeneralSettings.EnablePVP)
            {
                return("PVP online disable on this server");
            }
            if (!player.Online || !hostPlayer.Online)
            {
                Loger.Log($"Server AttackServer {Attacker.Public.Login} -> {Host.Public.Login} canceled: Attack not possible: player offline");
                return("Attack not possible: player offline");
            }
            var err = AttackUtils.CheckPossibilityAttack(player, hostPlayer, fromClient.InitiatorPlaceServerId, fromClient.HostPlaceServerId
                                                         , ServerManager.ServerSettings.ProtectingNovice);

            if (err != null)
            {
                Loger.Log($"Server AttackServer {Attacker.Public.Login} -> {Host.Public.Login} canceled: {err}");
                return(err);
            }

            TestMode               = testMode;
            Attacker               = player;
            Host                   = hostPlayer;
            Attacker.AttackData    = this;
            Host.AttackData        = this;
            HostPlaceServerId      = fromClient.HostPlaceServerId;
            InitiatorPlaceServerId = fromClient.InitiatorPlaceServerId;
            var data = Repository.GetData;
            var woip = data.WorldObjects.FirstOrDefault(wo => wo.ServerId == InitiatorPlaceServerId);

            if (woip != null)
            {
                InitiatorPlaceTile = woip.Tile;
            }

            NewPawns        = new List <ThingEntry>();
            NewPawnsId      = new List <int>();
            NewThings       = new List <ThingTrade>();
            NewThingsId     = new List <int>();
            NewCorpses      = new List <AttackCorpse>();
            Delete          = new List <int>();
            UpdateState     = new Dictionary <int, AttackThingState>();
            UpdateCommand   = new Dictionary <int, AttackPawnCommand>();
            NeedNewThingIDs = new HashSet <int>();

            CreateTime       = DateTime.UtcNow;
            AttackUpdateTick = 0;

            if (!TestMode)
            {
                Host.Public.LastPVPTime = DateTime.UtcNow;
            }

            Loger.Log($"Server AttackServer {Attacker.Public.Login} -> {Host.Public.Login} New");
            return(null);
        }
示例#3
0
        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);
            }
            //}
        }