示例#1
0
        private static void GetText(
            LandClaimAreasGroupPublicState publicState,
            bool canDeactivate,
            out string message,
            out string title)
        {
            var time = Api.Client.CurrentGame.ServerFrameTimeApproximated;

            switch (publicState.Status)
            {
            case ShieldProtectionStatus.Active:
            {
                var timeRemains = publicState.ShieldEstimatedExpirationTime - time;
                timeRemains = Math.Max(0, timeRemains);

                title = CoreStrings.ShieldProtection_NotificationBaseUnderShield_Title;

                message = string.Format(CoreStrings.ShieldProtection_NotificationBaseUnderShield_Message_Format,
                                        ClientTimeFormatHelper.FormatTimeDuration(
                                            timeRemains,
                                            appendSeconds: false));

                if (canDeactivate)
                {
                    message += "[br][br]"
                               + CoreStrings.ShieldProtection_NotificationBaseUnderShield_MessageOwner;
                }

                message += "[br][br]"
                           + CoreStrings.ShieldProtection_Description_2
                           + "[br]"
                           + CoreStrings.ShieldProtection_Description_3;
                break;
            }

            case ShieldProtectionStatus.Activating:
            {
                var timeRemains = publicState.ShieldActivationTime - time;
                timeRemains = Math.Max(0, timeRemains);

                title   = CoreStrings.ShieldProtection_NotificationBaseActivatingShield_Title;
                message = string.Format(
                    CoreStrings.ShieldProtection_NotificationBaseActivatingShield_Message_Format,
                    ClientTimeFormatHelper.FormatTimeDuration(timeRemains));

                if (canDeactivate)
                {
                    message += "[br][br]"
                               + CoreStrings.ShieldProtection_NotificationBaseUnderShield_MessageOwner;
                }

                break;
            }

            default:
                title   = null;
                message = null;
                break;
            }
        }
示例#2
0
        public ViewModelShieldProtectionControl(ILogicObject areasGroup)
        {
            this.areasGroup   = areasGroup;
            this.privateState = LandClaimAreasGroup.GetPrivateState(areasGroup);
            this.publicState  = LandClaimAreasGroup.GetPublicState(areasGroup);

            this.privateState.ClientSubscribe(
                _ => _.ShieldProtectionCurrentChargeElectricity,
                _ =>
            {
                this.NotifyPropertyChanged(nameof(this.ElectricityAmount));
                this.NotifyPropertyChanged(nameof(this.CanActivateShield));
                this.NotifyPropertyChanged(nameof(this.HasFullCharge));
                this.UpdateCurrentDurations();
            },
                this);

            this.privateState.ClientSubscribe(
                _ => _.ShieldProtectionCooldownExpirationTime,
                _ => this.RefreshState(),
                this);

            this.publicState.ClientSubscribe(
                _ => _.ShieldActivationTime,
                _ => this.RefreshState(),
                this);

            this.publicState.ClientSubscribe(
                _ => _.Status,
                _ => this.RefreshState(),
                this);

            this.RefreshState();

            this.IsLandClaimInsideAnotherBase = LandClaimShieldProtectionHelper.SharedIsLandClaimInsideAnotherBase(
                areasGroup);

            FactionSystem.ClientCurrentFactionAccessRightsChanged += this.CurrentFactionAccessRightsChangedHandler;

            UpdateCurrentDurationsEverySecond();

            void UpdateCurrentDurationsEverySecond()
            {
                if (this.IsDisposed)
                {
                    return;
                }

                this.UpdateCurrentDurations();
                ClientTimersSystem.AddAction(1, UpdateCurrentDurationsEverySecond);
            }
        }