示例#1
0
    public static void GetDummyAABB(this BoosterType type, float scale, out float left, out float top, out float right, out float bottom)
    {
        // Deploy
        if (type == BoosterType.Deploy)
        {
            float halfWidth  = 0.15f * scale;
            float halfHeight = halfWidth;

            left   = -halfWidth;
            right  = halfWidth;
            bottom = -halfHeight;
            top    = halfHeight;
        }
        // Hammer
        else if (type == BoosterType.Hammer)
        {
            left   = -0.7f * scale;
            right  = -0.3f * scale;
            bottom = 0.4f * scale;
            top    = 0.9f * scale;
        }
        else
        {
            left = top = right = bottom = 0;
        }
    }
    public void Show(BoosterType type, float delay = 0.5f, Action callback = null)
    {
        // Set callback
        _callback = callback;

        // Set message
        //message.text = type.GetUnlockMessage();

        // Set icon
        icon.sprite = icons[type.ToInt()];

        // Set description
        description.text = type.GetDescription();

        // Disable interaction
        SetInteractable(false);

        if (delay > 0)
        {
            Invoke("ShowCallback", delay);
        }
        else
        {
            ShowCallback();
        }
    }
示例#3
0
        public IBooster Build(BoosterType type)
        {
            switch (type)
            {
            case BoosterType.Slice: return(new SliceBooster());

            case BoosterType.Burst: return(new BurstBooster());

            case BoosterType.BigBurst: return(new BigBurstBooster());

            case BoosterType.SameSlot: return(new SameSlotBooster());

            case BoosterType.CrossSlice: return(new CrossSliceBooster());

            case BoosterType.BigSlice: return(new BigSliceBooster());

            case BoosterType.BigCrossSlice: return(new BigCrossSliceBooster());

            case BoosterType.BurstAll: return(new BurstAllBooster());

            case BoosterType.None: return(new NoEffect());

            default: return(new NoEffect());
            }
        }
示例#4
0
 internal BoosterData(BoosterType type, float rate, DateTime?expiresOn, int?usesRemaining)
 {
     Type          = type;
     Rate          = rate;
     ExpiresOn     = expiresOn;
     UsesRemaining = UsesRemaining;
 }
        public void Remove(BoosterType boosterType)
        {
            switch ((short)boosterType)
            {
            case BoosterTypeModule.DMGM_1:
            case BoosterTypeModule.DMG_B01:
            case BoosterTypeModule.DMG_B02:
                if (DamageTypes.Count >= 2)
                {
                    DamageTypes.Remove(DamageTypes.FirstOrDefault(x => x.typeValue == (short)boosterType));
                }
                break;

            case BoosterTypeModule.SHD_B01:
            case BoosterTypeModule.SHD_B02:
                if (ShieldTypes.Count >= 2)
                {
                    ShieldTypes.Remove(ShieldTypes.FirstOrDefault(x => x.typeValue == (short)boosterType));
                }
                break;

            case BoosterTypeModule.HP_B01:
            case BoosterTypeModule.HP_B02:
                if (MaxHpTypes.Count >= 2)
                {
                    MaxHpTypes.Remove(MaxHpTypes.FirstOrDefault(x => x.typeValue == (short)boosterType));
                }
                break;
            }

            Update();
        }
        private Rgba32 GetColor(BoosterType boosterType)
        {
            switch (boosterType)
            {
            case BoosterType.Extension:
                return(Rgba32.Blue);

            case BoosterType.FastWheels:
                return(Rgba32.Brown);

            case BoosterType.Drill:
                return(Rgba32.Green);

            case BoosterType.Teleport:
                return(Rgba32.Violet);

            case BoosterType.MysteriousPoint:
                return(Rgba32.Yellow);

            case BoosterType.Cloning:
                return(Rgba32.Aqua);

            case BoosterType.TeleportBeacon:
                return(Rgba32.Red);

            default:
                throw new Exception(boosterType.ToString());
            }
        }
        /// <summary>
        ///  Regression learner for XGBoost
        /// </summary>
        /// <param name="maximumTreeDepth">Maximum tree depth for base learners. (default is 3)</param>
        /// <param name="learningRate">Boosting learning rate (xgb's "eta"). 0 indicates no limit. (default is 0.1)</param>
        /// <param name="estimators">Number of estimators to fit. (default is 100)</param>
        /// <param name="silent">Whether to print messages while running boosting. (default is false)</param>
        /// <param name="objective">Specify the learning task and the corresponding learning objective. (default is LinearRegression)</param>
        /// <param name="boosterType"> which booster to use, can be gbtree, gblinear or dart.
        /// gbtree and dart use tree based model while gblinear uses linear function (default is gbtree)</param>
        /// <param name="treeMethod">The tree construction algorithm used in XGBoost. See reference paper: https://arxiv.org/abs/1603.02754. (default is auto)</param>
        /// <param name="samplerType">Type of sampling algorithm for DART. (default is uniform)</param>
        /// <param name="normalizeType">Type of normalization algorithm for DART. (default is tree)</param>
        /// <param name="dropoutRate">Dropout rate for DART (a fraction of previous trees to drop during the dropout). (default is 0.0)</param>
        /// <param name="oneDrop">When this is true, at least one tree is always dropped during the dropout.
        /// Allows Binomial-plus-one or epsilon-dropout from the original DART paper. (default is false)</param>
        /// <param name="skipDrop">Probability of skipping the dropout procedure during a boosting iteration. (default is 0.0)
        /// If a dropout is skipped, new trees are added in the same manner as gbtree.
        /// Note that non-zero skip_drop has higher priority than rate_drop or one_drop.</param>
        /// <param name="numberOfThreads">Number of parallel threads used to run xgboost. -1 means use all thread avialable. (default is -1)</param>
        /// <param name="gamma">Minimum loss reduction required to make a further partition on a leaf node of the tree. (default is 0) </param>
        /// <param name="minChildWeight">Minimum sum of instance weight(hessian) needed in a child. (default is 1)</param>
        /// <param name="maxDeltaStep">Maximum delta step we allow each tree's weight estimation to be. (default is 0)</param>
        /// <param name="subSample">Subsample ratio of the training instance. (default is 1)</param>
        /// <param name="colSampleByTree">Subsample ratio of columns when constructing each tree. (defualt is 1)</param>
        /// <param name="colSampleByLevel">Subsample ratio of columns for each split, in each level. (defualt is 1)</param>
        /// <param name="l1Regularization">L1 regularization term on weights. Also known as RegAlpha. (default is 0)</param>
        /// <param name="l2Reguralization">L2 regularization term on weights. Also known as regLambda. (default is 1)</param>
        /// <param name="scalePosWeight">Balancing of positive and negative weights. (default is 1)</param>
        /// <param name="baseScore">The initial prediction score of all instances, global bias. (default is 0.5)</param>
        /// <param name="seed">Random number seed. (defaukt is 0)</param>
        /// <param name="missing">Value in the data which needs to be present as a missing value. (default is NaN)</param>
        public RegressionXGBoostLearner(int maximumTreeDepth          = 3, double learningRate = 0.1, int estimators = 100,
                                        bool silent                   = true,
                                        RegressionObjective objective = RegressionObjective.LinearRegression,
                                        BoosterType boosterType       = BoosterType.GBTree,
                                        TreeMethod treeMethod         = TreeMethod.Auto,
                                        SamplerType samplerType       = SamplerType.Uniform,
                                        NormalizeType normalizeType   = NormalizeType.Tree,
                                        double dropoutRate            = 0.0,
                                        bool oneDrop                  = false,
                                        double skipDrop               = 0.0,
                                        int numberOfThreads           = -1, double gamma    = 0, int minChildWeight     = 1,
                                        int maxDeltaStep              = 0, double subSample = 1, double colSampleByTree = 1,
                                        double colSampleByLevel       = 1, double l1Regularization = 0, double l2Reguralization = 1,
                                        double scalePosWeight         = 1, double baseScore        = 0.5, int seed = 0,
                                        double missing                = double.NaN)
        {
            ArgumentChecks.ThrowOnArgumentLessThan(nameof(maximumTreeDepth), maximumTreeDepth, 0);
            ArgumentChecks.ThrowOnArgumentLessThanOrHigherThan(nameof(learningRate), learningRate, 0, 1.0);
            ArgumentChecks.ThrowOnArgumentLessThan(nameof(estimators), estimators, 1);
            ArgumentChecks.ThrowOnArgumentLessThan(nameof(numberOfThreads), numberOfThreads, -1);
            ArgumentChecks.ThrowOnArgumentLessThan(nameof(gamma), gamma, 0);
            ArgumentChecks.ThrowOnArgumentLessThan(nameof(minChildWeight), minChildWeight, 0);
            ArgumentChecks.ThrowOnArgumentLessThan(nameof(maxDeltaStep), maxDeltaStep, 0);
            ArgumentChecks.ThrowOnArgumentLessThanOrHigherThan(nameof(subSample), subSample, 0, 1.0);
            ArgumentChecks.ThrowOnArgumentLessThanOrHigherThan(nameof(colSampleByTree), colSampleByTree, 0, 1.0);
            ArgumentChecks.ThrowOnArgumentLessThanOrHigherThan(nameof(colSampleByLevel), colSampleByLevel, 0, 1.0);
            ArgumentChecks.ThrowOnArgumentLessThan(nameof(l1Regularization), l1Regularization, 0);
            ArgumentChecks.ThrowOnArgumentLessThan(nameof(l2Reguralization), l2Reguralization, 0);
            ArgumentChecks.ThrowOnArgumentLessThan(nameof(scalePosWeight), scalePosWeight, 0);

            m_parameters[ParameterNames.MaxDepth]     = maximumTreeDepth;
            m_parameters[ParameterNames.LearningRate] = (float)learningRate;
            m_parameters[ParameterNames.Estimators]   = estimators;
            m_parameters[ParameterNames.Silent]       = silent;
            m_parameters[ParameterNames.objective]    = objective.ToXGBoostString();

            m_parameters[ParameterNames.Threads]          = numberOfThreads;
            m_parameters[ParameterNames.Gamma]            = (float)gamma;
            m_parameters[ParameterNames.MinChildWeight]   = minChildWeight;
            m_parameters[ParameterNames.MaxDeltaStep]     = maxDeltaStep;
            m_parameters[ParameterNames.SubSample]        = (float)subSample;
            m_parameters[ParameterNames.ColSampleByTree]  = (float)colSampleByTree;
            m_parameters[ParameterNames.ColSampleByLevel] = (float)colSampleByLevel;
            m_parameters[ParameterNames.RegAlpha]         = (float)l1Regularization;
            m_parameters[ParameterNames.RegLambda]        = (float)l2Reguralization;
            m_parameters[ParameterNames.ScalePosWeight]   = (float)scalePosWeight;

            m_parameters[ParameterNames.BaseScore]       = (float)baseScore;
            m_parameters[ParameterNames.Seed]            = seed;
            m_parameters[ParameterNames.Missing]         = (float)missing;
            m_parameters[ParameterNames.ExistingBooster] = null;
            m_parameters[ParameterNames.Booster]         = boosterType.ToXGBoostString();
            m_parameters[ParameterNames.TreeMethod]      = treeMethod.ToXGBoostString();

            m_parameters[ParameterNames.SampleType]    = samplerType.ToXGBoostString();
            m_parameters[ParameterNames.NormalizeType] = normalizeType.ToXGBoostString();
            m_parameters[ParameterNames.RateDrop]      = (float)dropoutRate;
            m_parameters[ParameterNames.OneDrop]       = oneDrop ? 1 : 0;
            m_parameters[ParameterNames.SkipDrop]      = (float)skipDrop;
        }
        public void Add(BoosterType boosterType, int hours)
        {
            Player.SendPacket($"0|A|STM|booster_found|%BOOSTERNAME%|{boosterType.ToString()}|%HOURS%|{hours}");

            var   seconds = (int)TimeSpan.FromHours(hours).TotalSeconds;
            short boostedAttributeType = GetBoosterType((short)boosterType);

            if (boostedAttributeType != 0)
            {
                if (!Boosters.ContainsKey((short)boostedAttributeType))
                {
                    Boosters[boostedAttributeType] = new List <BoosterBase>();
                }

                if (Boosters[boostedAttributeType].Where(x => x.Type == (short)boosterType).Count() <= 0)
                {
                    Boosters[boostedAttributeType].Add(new BoosterBase((short)boosterType, seconds));
                }
                else
                {
                    Boosters[boostedAttributeType].Where(x => x.Type == (short)boosterType).FirstOrDefault().Seconds += seconds;
                }

                Update();
                QueryManager.SavePlayer.Boosters(Player);
            }
        }
 public void Set(BoosterType boosterType, double boost)
 {
     lock (_lock) {
         _boosts[boosterType] = boost;
         OnBoostChanged?.Invoke(boosterType, boost);
     }
 }
示例#10
0
        private BoosterType CombineBooster(BoosterType referenceBooster, ICollection <BoosterType> otherBoosters)
        {
            switch (referenceBooster.GetTier())
            {
            case BoosterTier.One:
                if (referenceBooster.AllSame(otherBoosters))
                {
                    return(UpdateSameTier(referenceBooster));
                }

                var otherMaxTier = GetMaxTier(otherBoosters);

                if (otherMaxTier == BoosterTier.One || otherMaxTier == BoosterTier.Two)
                {
                    return(BoosterType.BigCrossSlice);
                }

                return(BoosterType.BurstAll);

            case BoosterTier.Two:
                if (referenceBooster.AllSame(otherBoosters))
                {
                    return(UpdateSameTier(referenceBooster));
                }

                return(GetMaxTier(otherBoosters) < referenceBooster.GetTier() ? BoosterType.BigCrossSlice : BoosterType.BurstAll);

            case BoosterTier.Three:
            case BoosterTier.Four:
                return(BoosterType.BurstAll);

            default:
                return(BoosterType.None);
            }
        }
示例#11
0
        private BoosterType UpdateSameTier(BoosterType referenceBooster)
        {
            switch (referenceBooster)
            {
            case BoosterType.Slice:
                return(BoosterType.CrossSlice);

            case BoosterType.Burst:
                return(BoosterType.BigBurst);

            case BoosterType.SameSlot:
                return(BoosterType.BigSlice);

            case BoosterType.CrossSlice:
            case BoosterType.BigBurst:
            case BoosterType.BigSlice:
            case BoosterType.BigCrossSlice:
            case BoosterType.BurstAll:
                return(BoosterType.BurstAll);

            case BoosterType.None:
                return(BoosterType.None);

            default:
                throw new ArgumentOutOfRangeException(nameof(referenceBooster), referenceBooster, null);
            }
        }
示例#12
0
    private void FillSlot(Slot slot, BoosterType booster)
    {
        slot.boosterType = booster;
        slot.boostersCount++;
        slot.maxBoosters = booster.maxInInventory;

        slot.UpdateSlotText();
    }
示例#13
0
        public Booster(Scene scene, DrawComponent dc, TransformComponent tc, BoosterSpecs specs) : base(scene, tc, dc)
        {
            Scene.Game.PM.CreateBoxComponent(new Size(32.0, 32.0), this);

            Direction = specs.Direction;
            Velocity  = specs.Velocity;
            LifeSpan  = specs.LifeSpan;
            Type      = specs.Type;
        }
示例#14
0
 public void SetBoosterButton(BoosterType type, Boolean isActive)
 {
     UIToggle[] toggle = this.boosterList[(Int32)type].Toggle;
     for (Int32 i = 0; i < (Int32)toggle.Length; i++)
     {
         UIToggle uitoggle = toggle[i];
         uitoggle.value = isActive;
     }
 }
示例#15
0
        public void ExecuteBoosterEffect(int sourceIndex, BoosterType boosterSlotBooster, List <KulaySlot> boardSlots, int boardSideCount)
        {
            _currentSlots          = boardSlots;
            _currentBoardSideCount = boardSideCount;

            var popIndexes = _boosterFactory.Build(boosterSlotBooster)
                             .GetAffectedIndexes(sourceIndex, _currentSlots, _currentBoardSideCount);

            PopSlots(popIndexes, boosterSlotBooster == BoosterType.BurstAll);
        }
示例#16
0
    public static float GetDummyDeltaY(this BoosterType type)
    {
        // Deploy
        if (type == BoosterType.Deploy)
        {
            return(0.75f);
        }

        return(0.5f);
    }
 public double Get(BoosterType boosterType)
 {
     lock (_lock) {
         if (_boosts.TryGetValue(boosterType, out double boost))
         {
             return(boost);
         }
         return(1.0);
     }
 }
示例#18
0
 public Booster GetBoosterOfType(BoosterType boosterType)
 {
     if (boosterType2Booster.ContainsKey(boosterType))
     {
         return(boosterType2Booster[boosterType]);
     }
     else
     {
         return(null);
     }
 }
示例#19
0
    public void ShowWaringDialog(BoosterType type, Action callback = null)
    {
        if (this.needComfirmType == BoosterType.None && (PersistenSingleton <UIManager> .Instance.IsPlayerControlEnable || PersistenSingleton <UIManager> .Instance.State == UIManager.UIState.Config) && EventHUD.CurrentHUD == MinigameHUD.None)
        {
            this.needComfirmType = type;
            String text = String.Empty;
            switch (type)
            {
            case BoosterType.MasterSkill:
                text += Localization.Get("BoosterWarningMaster");
                break;

            case BoosterType.LvMax:
                text += Localization.Get("BoosterWarningLvMax");
                break;

            case BoosterType.GilMax:
                text += Localization.Get("BoosterWarningGilMax");
                break;
            }
            if (FF9StateSystem.aaaaPlatform)
            {
                text += Localization.Get("BoosterWarningaaaa");
            }
            else
            {
                text += Localization.Get("BoosterWarningNotaaaa");
            }
            text       += Localization.Get("BoosterWarningCommonChoice");
            ETb.sChoose = 1;
            Dialog dialog = Singleton <DialogManager> .Instance.AttachDialog(text, 0, 0, Dialog.TailPosition.Center, Dialog.WindowStyle.WindowStylePlain, new Vector2(0f, 0f), Dialog.CaptionType.None);

            ButtonGroupState.SetPointerOffsetToGroup(new Vector2(620f, 0f), Dialog.DialogGroupButton);
            dialog.AfterDialogHidden = new Dialog.DialogIntDelegate(this.OnConfirmDialogHidden);
            this.warningCallback     = callback;
            if (PersistenSingleton <UIManager> .Instance.State != UIManager.UIState.Config)
            {
                PersistenSingleton <UIManager> .Instance.SetPlayerControlEnable(false, (Action)null);

                PersistenSingleton <UIManager> .Instance.SetMenuControlEnable(false);

                PersistenSingleton <UIManager> .Instance.SetEventEnable(false);
            }
            PersistenSingleton <UIManager> .Instance.IsWarningDialogEnable = true;
            if (this.OutsideBoosterHitPoint.activeSelf)
            {
                this.CloseBoosterPanel((UIScene.SceneVoidDelegate)null);
            }
        }
        else
        {
            FF9Sfx.FF9SFX_Play(102);
        }
    }
    public void ShowRewardedVideo(BoosterType boosterType)
    {
        GameManager.pauseBeacuseADS        = true;
        PlayerManager.instance.boosterType = boosterType;

        FirebaseAnalytics.LogEvent("Rewarded_Video_Started", new Parameter("booster_type", boosterType.ToString()));
        if (this.rewardedAd.IsLoaded())
        {
            this.rewardedAd.Show();
        }
    }
示例#21
0
        public void SetIcon(BoosterType booster, Kulay currentKulay)
        {
            primaryImage.sprite = Settings.Booster.GetIcon(booster);
            primaryImage.DOFade(1, 0);
            secondaryImage.DOFade(booster == BoosterType.SameSlot ? 1 : 0, 0);

            if (booster == BoosterType.SameSlot)
            {
                secondaryImage.sprite = Settings.Kulay.GetData(currentKulay).icon;
            }
        }
示例#22
0
 public void ItemSetting(BoosterType type, int price)
 {
     black.SetActive(true);
     if (type == BoosterType.arrow)
     {
         uiItemImg.spriteName = "horizon";
     }
     else
     {
         uiItemImg.spriteName = type.ToString();
     }
     uiPrice.text = price.ToString();
 }
示例#23
0
        public BoosterData(BoosterType type, float rate, TimeSpan?decayLength = null, int?useLimit = null)
        {
            Type = type;
            Rate = rate;

            if (decayLength.HasValue)
            {
                ExpiresOn = DateTime.UtcNow.Add(decayLength.Value);
            }

            if (useLimit.HasValue)
            {
                UsesRemaining = useLimit.Value;
            }
        }
示例#24
0
    public void CallBoosterButtonFuntion(BoosterType buttonType, bool setActive = true)
    {
        switch (buttonType)
        {
        case BoosterType.BattleAssistance:
            FF9StateSystem.Settings.IsBoosterButtonActive[(int)buttonType] = setActive;
            SetATBFull();
            SetHPFull();
            SetTranceBarFull();
            break;

        case BoosterType.HighSpeedMode:
            SetFastForward(setActive);
            break;

        case BoosterType.Rotation:
            FF9StateSystem.Settings.IsBoosterButtonActive[(int)buttonType] = setActive;
            UIManager.Input.SendKeyCode(Control.LeftTrigger, true);
            break;

        case BoosterType.Attack9999:
            FF9StateSystem.Settings.IsBoosterButtonActive[(int)buttonType] = setActive;
            break;

        case BoosterType.NoRandomEncounter:
            FF9StateSystem.Settings.IsBoosterButtonActive[(int)buttonType] = setActive;
            break;

        case BoosterType.Perspective:
            FF9StateSystem.Settings.IsBoosterButtonActive[(int)buttonType] = setActive;
            UIManager.Input.SendKeyCode(Control.RightTrigger, true);
            break;

        case BoosterType.MasterSkill:
            FF9StateSystem.Settings.IsBoosterButtonActive[(int)buttonType] = setActive;
            SetMasterSkill();
            break;

        case BoosterType.LvMax:
            SetLvMax();
            break;

        case BoosterType.GilMax:
            SetGilMax();
            break;
        }
    }
示例#25
0
    int GetIndexOfBooster(BoosterType type)
    {
        switch (type)
        {
        case BoosterType.Speed:
            return(0);

        case BoosterType.Time:
            return(1);

        case BoosterType.Score:
            return(2);

        default:
            return(0);
        }
    }
示例#26
0
        /// <summary>
        /// Convert booster type to the xgboost parameter string.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string ToXGBoostString(this BoosterType type)
        {
            switch (type)
            {
            case BoosterType.GBTree:
                return("gbtree");

            case BoosterType.GBLinear:
                return("gblinear");

            case BoosterType.DART:
                return("dart");

            default:
                throw new ArgumentException("Unknown BoosterType: " + type);
            }
        }
示例#27
0
        public void ItemSetting(BoosterType type, int count, int price)
        {
            SetCoin();
            SetBtn(true);
            black.SetActive(true);
            if (type == BoosterType.arrow)
            {
                uiItemImg.spriteName = "horizon";
            }
            else
            {
                uiItemImg.spriteName = type.ToString();
            }

            uiItemCount.text = string.Format("x{0}", count.ToString());
            uiPrice.text     = (count * price).ToString();
        }
 void SetBoosterAction(Player player, BoosterType type)
 {
     this.GetComponent<BoxCollider2D>().enabled = false;
     if (type == BoosterType.Score)
     {
         player.score += 150;
         Destroy();
     }
     else if(type == BoosterType.Speed)
     {
         StartCoroutine(AddSpeed());
     }
     else if(type == BoosterType.Time)
     {
         player.time += 20;
         Destroy();
     }
 }
示例#29
0
        void CreateBooster()
        {
            Random random = new Random();
            int    key    = random.Next(0, 100);

            if (key > 76 && key <= 100)
            {
                BoosterType  bt    = BoosterType.AddHP;
                BoosterSpecs specs = new BoosterSpecs();
                specs.Direction = new Point(0.0, 1.0);
                specs.LifeSpan  = 4;
                specs.Velocity  = 300.0;

                if (key > 76 && key <= 80)
                {
                    bt = BoosterType.AddHP;
                }
                else if (key > 80 && key <= 84)
                {
                    bt = BoosterType.AddDamage;
                }
                else if (key > 84 && key <= 88)
                {
                    bt = BoosterType.AddLazer;
                }
                else if (key > 88 && key <= 92)
                {
                    bt = BoosterType.Bomb;
                }
                else if (key > 92 && key <= 96)
                {
                    bt = BoosterType.Shield;
                }
                else if (key > 96 && key <= 100)
                {
                    bt = BoosterType.ChainsawShield;
                }

                specs.Type = bt;

                Booster booster = new Booster(Scene, new DrawComponent(Scene.Game.AM.GetTexture(bt + ".png"), new Size(32.0, 32.0)), new TransformComponent(TC.Position), specs);
                Scene.NewActors.Add(booster);
            }
        }
示例#30
0
    //after collide booster handler
    public void TryAddBooster(BoosterType booster, Cell boosterCell, Sprite sprite)
    {
        Slot emptySlot = null;


        for (int i = 0; i < slots.Length; i++)
        {
            if (slots[i].isUnlocked)
            {
                if (slots[i].boosterType == booster)
                {
                    if (slots[i].boostersCount == slots[i].maxBoosters)
                    {
                        booster.Activate(boosterCell);
                    }
                    else
                    {
                        AddToSlot(slots[i]);
                    }
                    return;
                }

                if (emptySlot == null && slots[i].boosterType == null)
                {
                    emptySlot = slots[i];
                }
            }
        }


        if (emptySlot != null && booster.maxInInventory > 0)
        {
            FillSlot(emptySlot, booster);
            artNotch[emptySlot.index].sprite = sprite;
            Color fillerColor = artNotch[emptySlot.index].color;
            fillerColor.a = 1;
            artNotch[emptySlot.index].color = fillerColor;
        }
        else
        {
            booster.Activate(boosterCell);
        }
    }