Ejemplo n.º 1
0
        public override void OnEvent(IBosServiceCollection context, TutorialEventData data)
        {
            Func <bool> isValid = () => IsActive && isDialogShowed && data.EventName == TutorialEventName.ViewOpened;

            BosUtils.If(isValid,
                        trueAction: () => {
                if ((ViewType)data.UserData == ViewType.PlanetsView)
                {
                    RemoveFinger(context, "planets");
                    ForceTutorialDialog(context, new TutorialDialogData {
                        Texts = GetLocalizationStrings(context, "lbl_tut_37"),
                        OnOk  = () => {
                            Finger(context, "moon", 10);
                        }
                    });
                }
            },
                        falseAction: () => {
            });

            BosUtils.If(() => IsActive && isDialogShowed && data.EventName == TutorialEventName.OpenPlanetClicked,
                        trueAction: () => {
                if ((int)data.UserData == 1)
                {
                    RemoveFinger(context, "moon");
                    CompleteSelf(context);
                }
            },
                        falseAction: () => { });
        }
Ejemplo n.º 2
0
 public override void OnUpdate(IBosServiceCollection context, float deltaTime)
 {
     if (IsActive)
     {
         guardTimer.Update(deltaTime);
     }
 }
Ejemplo n.º 3
0
        public override bool IsValid(IBosServiceCollection context)
        {
            var boostState = context.GetService <IX20BoostService>().State;

            return(context.TutorialService.IsStateCompleted(TutorialStateName.BuyBus) &&
                   (boostState == BoostState.Active || boostState == BoostState.ReadyToActivate));
        }
Ejemplo n.º 4
0
 protected bool IsStandardDialogCondition(IBosServiceCollection context)
 {
     return(context.ViewService.ModalCount == 0 &&
            context.ViewService.LegacyCount == 0 &&
            (!context.ViewService.Exists(ViewType.TutorialDialogView)) &&
            context.GameModeService.GameModeName == GameModeName.Game);
 }
Ejemplo n.º 5
0
        public override string GetValidationDescription(IBosServiceCollection services)
        {
            var sb = GetBaseValidationDescription();

            sb.AppendLine($"Product Notifier Available Product(IsProductAvailable): {IsProductAvailable}");
            return(sb.ToString());
        }
Ejemplo n.º 6
0
 private void RemoveCost(IBosServiceCollection services, CostType type, double cost)
 {
     if (currencyRemovers.ContainsKey(type))
     {
         currencyRemovers[type](services, cost);
     }
 }
Ejemplo n.º 7
0
        public override void OnEnter(IBosServiceCollection context)
        {
            if (!IsOnEntered)
            {
                SetStage(START_STAGE);

                if (!isDialogShowed)
                {
                    isDialogShowed = true;

                    context.Execute(() => {
                        context.ViewService.Show(ViewType.TutorialDialogView,
                                                 () => { return(IsStandardDialogCondition(context)); },
                                                 (go) => { /* UnityEngine.Debug.Log($"view {go.name} is showed")*/ },
                                                 new ViewData {
                            UserData = new TutorialDialogData {
                                Texts = context.ResourceService.Localization.GetString("lbl_tut_11").WrapToList(),
                                OnOk  = () => {
                                    context.TutorialService.CreateFinger(kPositionMiniGames, new TutorialFingerData {
                                        Id = kPositionMiniGames,
                                        IsTooltipVisible = false,
                                        Position         = Vector2.zero
                                    });
                                }
                            }
                        });
                    }, 5);
                }
                IsOnEntered = true;
            }
        }
Ejemplo n.º 8
0
        public override void OnUpdate(IBosServiceCollection context, float deltaTime)
        {
            if (IsActive)
            {
                if (Stage == START_STAGE)
                {
                    if (IsValid(context))
                    {
                        /*
                         * Finger(context, "profile", 10);
                         * SetStage(FINGER_ON_PROFILE_SHOWED_STAGE);*/

                        //show first dialog
                        SetStage(DIALOG_FIRST_STAGE);
                    }
                }
                else if (Stage == DIALOG_FIRST_STAGE)
                {
                    if (isNeedShowFirstDialog)
                    {
                        if (context.GameModeService.IsGame)
                        {
                            ShowFirstDialog(services);
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public override string GetValidationDescription(IBosServiceCollection services)
        {
            var sb = GetBaseValidationDescription();

            sb.AppendLine($"Is TutorialStateName.BuyBus completed: {services.TutorialService.IsStateCompleted(TutorialStateName.BuyBus)}");
            return(sb.ToString());
        }
Ejemplo n.º 10
0
        public bool UpdateBroke(float interval, float brokeSpeed, int minLiveCount, IBosServiceCollection services)
        {
            BrokeCounter += interval * brokeSpeed * services.TimeChangeService.TimeMult;

            bool isBroked = false;

            if (LiveCount <= minLiveCount)
            {
                BrokeCounter = 0f;
            }
            else
            {
                int diff    = LiveCount - minLiveCount;
                int brokeI  = (int)BrokeCounter;
                int toBroke = Mathf.Min(diff, brokeI);
                if (toBroke > 0)
                {
                    bool isSuccess = Broke(toBroke);
                    if (isSuccess)
                    {
                        isBroked = true;
                    }
                    BrokeCounter -= brokeI;
                }
            }

            return(isBroked);
        }
Ejemplo n.º 11
0
        protected List <string> GetLocalizationStrings(IBosServiceCollection context, params string[] keys)
        {
            List <string> result = new List <string>();

            keys.ToList().ForEach(s => result.Add(context.ResourceService.Localization.GetString(s)));
            return(result);
        }
Ejemplo n.º 12
0
 public override void OnEnter(IBosServiceCollection context)
 {
     if (!IsOnEntered)
     {
         IsOnEntered = true;
     }
 }
Ejemplo n.º 13
0
 public PlanetInfo(int id, IBosServiceCollection services)
 {
     this.Id            = id;
     this.services      = services;
     this.planetService = services.GetService <IPlanetService>();
     UpdateData();
 }
Ejemplo n.º 14
0
        public override bool IsValid(IBosServiceCollection services)
        {
            bool isModuleNotOpened           = IsModuleNotOpened(services);
            bool isEnoughCurrencyToBuyModule = IsEnoughCurrencyForModule(services);

            return(isEnoughCurrencyToBuyModule && isModuleNotOpened);
        }
Ejemplo n.º 15
0
 public void ForceStart(IBosServiceCollection context)
 {
     IsCompleted = false;
     IsActive    = true;
     Stage       = 0;
     IsOnEntered = false;
     OnEnter(context);
 }
Ejemplo n.º 16
0
        private IEnumerator FingerDelayedImpl(IBosServiceCollection context, string positionName, string tooltipText,
                                              Vector2 tooltipPosition, float tooltipScale, float tooltipWidth, float timeout = -1, Action onShow = null)
        {
            yield return(new WaitUntil(() => IsStandardFingerCondition(context)));

            Finger(context, positionName, tooltipText, tooltipPosition, tooltipScale, tooltipWidth, timeout);
            onShow?.Invoke();
        }
Ejemplo n.º 17
0
        private bool IsMoonOpening(IBosServiceCollection services)
        {
            IPlanetService planets    = services.PlanetService;
            var            moonPlanet = planets.GetPlanet(PlanetConst.MOON_ID);

            return(moonPlanet.State == PlanetState.Opening ||
                   moonPlanet.State == PlanetState.ReadyToOpen);
        }
Ejemplo n.º 18
0
        public override string GetValidationDescription(IBosServiceCollection services)
        {
            var sb = GetBaseValidationDescription();

            sb.AppendLine($"Is Module not opened => {IsModuleNotOpened(services)}");
            sb.AppendLine($"Is Enough currencies for module => {IsEnoughCurrencyForModule(services)}");
            return(sb.ToString());
        }
Ejemplo n.º 19
0
 protected void Finger(IBosServiceCollection context, string positionName, float timeout = -1)
 {
     context.TutorialService.CreateFinger(positionName, new TutorialFingerData
     {
         Id = positionName,
         IsTooltipVisible = false,
         Timeout          = timeout
     });
 }
Ejemplo n.º 20
0
        public override string GetValidationDescription(IBosServiceCollection services)
        {
            var sb         = GetBaseValidationDescription();
            var boostState = services.GetService <IX20BoostService>().State;

            sb.AppendTutorialStateCompletedCondition(TutorialStateName.BuyBus);
            sb.AppendLine($"x20 boost is Active or ReadyToActivate: { boostState == BoostState.Active || boostState == BoostState.ReadyToActivate}");
            return(sb.ToString());
        }
Ejemplo n.º 21
0
        public void AddMaxEfficiency(double value, IBosServiceCollection services)
        {
            double oldValue = MaxEfficiency;

            MaxEfficiency += value;
            if (oldValue != MaxEfficiency)
            {
                GameEvents.OnMaxEfficiencyChanged(oldValue, MaxEfficiency, this);
            }
        }
Ejemplo n.º 22
0
 private void MoveToRepeatFingerState(IBosServiceCollection services)
 {
     services.TutorialService.RemoveFinger(kMegaBoostPosition);
     //CompleteSelf(context);
     if (Stage == STAGE_START)
     {
         UnityEngine.Debug.Log($"Set MegaboostState Stage to VALID".Attrib(bold: true, italic: true, color: "g", size: 20));
         SetStage(STAGE_SHOW_FINGER_OB_BUTTON);
     }
 }
Ejemplo n.º 23
0
 public override void OnEnter(IBosServiceCollection context) {
     this.services = context;
     if(!IsOnEntered ) {
         if (Stage == 0) {
             context.RunCoroutine(ShowFingerOnRickshawCountButtonImpl());
             SetStage(STAGE_WAIT_CLICK);
         }
         IsOnEntered = true;
     }
 }
Ejemplo n.º 24
0
        public override string GetValidationDescription(IBosServiceCollection services)
        {
            var sb = GetBaseValidationDescription();

            sb.AppendLine($"is enough currencies for planet: {IsEnoughCurrenciesForPlanet(services)}");
            sb.AppendLine($"is module opened: {IsModuleOpened(services)}");
            sb.AppendLine($"is planet closed: {IsPlanetLocked(services)}");
            sb.AppendTutorialStateCompletedCondition(TutorialStateName.SpaceShip);
            return(sb.ToString());
        }
Ejemplo n.º 25
0
 public override void Setup(IBosServiceCollection services)
 {
     base.Setup(services);
     UnityEngine.Debug.Log($"PlaySlot State Initialized".Attrib(bold: true, italic: true, color: "g", size: 20));
     if (!IsInitialized)
     {
         GameEvents.TutorialEventObservable.Subscribe(args => {
             if (args.EventName == TutorialEventName.WheelCompleted)
             {
                 if (Stage == CHEST_TAB_STAGE)
                 {
                     //remove previous finger
                     //show finger on CHEST TAB
                     UnityEngine.Debug.Log($"Tutorial event: {args.EventName}".Attrib(bold: true, italic: true, color: "g", size: 20));
                     Finger(services, kTutorialPositionChestTab, timeout: 10);
                     SetStage(CHEST_CLICK_STAGE);
                 }
             }
             else if (args.EventName == TutorialEventName.ChestTabOpened)
             {
                 if (Stage == CHEST_CLICK_STAGE)
                 {
                     //remove previous finger
                     //show finger on CHEST
                     UnityEngine.Debug.Log($"Tutorial event: {args.EventName}".Attrib(bold: true, italic: true, color: "g", size: 20));
                     RemoveFinger(services, kTutorialPositionChestTab);
                     Finger(services, kTutorialPositionChest, timeout: 10);
                     SetStage(WAIT_FOR_CHEST);
                 }
             }
             else if (args.EventName == TutorialEventName.ChestOpened)
             {
                 if (Stage == WAIT_FOR_CHEST)
                 {
                     //remove previous finger
                     UnityEngine.Debug.Log($"Tutorial event: {args.EventName}".Attrib(bold: true, italic: true, color: "g", size: 20));
                     RemoveFinger(services, kTutorialPositionChest);
                     SetStage(END_STAGE);
                 }
             }
             else if (args.EventName == TutorialEventName.ViewHided)
             {
                 ViewType viewType = (ViewType)args.UserData;
                 if (viewType == ViewType.MiniGameView)
                 {
                     if (Stage > 0)
                     {
                         CompleteSelf(services);
                     }
                 }
             }
         }).AddTo(services.Disposables);
         IsInitialized = true;
     }
 }
Ejemplo n.º 26
0
        public static double GetUnitPriceForMechanicSecretaryPrice(GeneratorInfo generator, int unitCount)
        {
            IBosServiceCollection Services = GameServices.Instance;
            int ownedCount = Services.TransportService.GetUnitTotalCount(generator.GeneratorId) - unitCount;

            if (ownedCount <= 0)
            {
                ownedCount = 1;
            }
            return(Services.GenerationService.CalculatePrice(unitCount, ownedCount, generator));
        }
Ejemplo n.º 27
0
 public override void OnEnter(IBosServiceCollection context)
 {
     if (!IsOnEntered)
     {
         if (Stage == START_STAGE)
         {
             SetStage(DIALOG_FIRST);
         }
         IsOnEntered = true;
     }
 }
Ejemplo n.º 28
0
 protected void ForceTutorialDialog(IBosServiceCollection context, TutorialDialogData data, System.Func <IBosServiceCollection, bool> additionalShowPredicate = null)
 {
     context.ViewService.Show(ViewType.TutorialDialogView, () => {
         return((additionalShowPredicate == null) || additionalShowPredicate(context));
     }, (viewObj) => {
         UDBG.Log($"opened dialog on state => {Name}".Colored(ConsoleTextColor.lightblue));
     }, new ViewData
     {
         UserData = data
     });
 }
Ejemplo n.º 29
0
 public override bool IsValid(IBosServiceCollection context)
 {
     context.PlayerService.ProductNotifier.AvailableProduct.Match(() => {
         IsProductAvailable = false;
         return(F.None);
     }, prod => {
         IsProductAvailable = true;
         return(F.Some(prod));
     });
     return(IsProductAvailable);
 }
Ejemplo n.º 30
0
 public void Setup(IBosServiceCollection services)
 {
     this.services       = services;
     ProductAvailability = availabilitySubject.ToReadOnlyReactiveProperty(new ProductAvailableInfo {
         IsAvailableForCurrentCash = false, IsAvailableForTotalCash = false
     });
     Observable.Interval(TimeSpan.FromSeconds(4)).Subscribe(_ => {
         UpdateState();
     }).AddTo(services.Disposables);
     //GameEvents.ProductPurchasedObservable.Subscribe(prod => UpdateState()).AddTo(services.Disposables);
     //GameEvents.OfficialTransferObservable.Value.Subscribe(info => UpdateState()).AddTo(services.Disposables);
     //GameEvents.UnofficialTransferObservable.Value.Subscribe(info => UpdateState()).AddTo(services.Disposables);
 }