예제 #1
0
        /// <summary>
        /// Add to the current experience and adjust the level.
        /// </summary>
        /// <param name="experience">The amount of experience to add.</param>
        public void AddExperience(int experience)
        {
            if (HasMaxExperience)
            {
                return;
            }

            Experience += experience;

            // Clamp experience
            if (Experience > MAX_EXPERIENCE)
            {
                Experience = MAX_EXPERIENCE;
            }

            // Set level
            int previousLevel = level;

            level     = CalculateLevel();
            MaxHealth = CalculateMaxHealth();

            // Check for level up
            if (Level != previousLevel)
            {
                OnLevelUp?.Invoke(this, EventArgs.Empty);
            }
        }
예제 #2
0
 public virtual void LevelUp()
 {
     if (OnLevelUp != null)
     {
         OnLevelUp.Invoke(CurrentValue);
     }
 }
예제 #3
0
    private void OnBubblePopped(int points)
    {
        _score += points;

        var scoreString = _score.ToString();

        _progressBar.value = _score / _nextLevelScore;

        if (_score > 10000)
        {
            var thousands        = _score / 10000;
            var hundreds         = _score - (thousands * 10000);
            var firstTwoHundreds = GetFirstTwoDigits(hundreds);
            scoreString = thousands + "k." + firstTwoHundreds;
        }

        _scoreText.text = scoreString;

        if (_score >= _nextLevelScore)
        {
            if (OnLevelUp != null)
            {
                OnLevelUp.Invoke();
            }
        }
    }
예제 #4
0
 public int LevelUp()
 {
     OnLevelUp?.Invoke(this, new LevelUpEventArgs(this));
     Level     += 1;
     Experience = ExpGroup.ExperienceNeededForLevel(Level);
     OnLevelledUp?.Invoke(this, new LevelledUpEventArgs(this));
     return(Level);
 }
예제 #5
0
 private void Boss_OnDeath(IMonster boss, ulong reward)
 {
     Level++;
     OnMonsterDeath?.Invoke(boss, reward);
     OnLevelUp?.Invoke(Level);
     GenerateMinions();
     GenerateBoss();
 }
예제 #6
0
 public void pbLevelUp(Combat.Pokemon pokemon, Combat.Pokemon battler, int oldtotalhp, int oldattack, int olddefense, int oldspeed, int oldspatk, int oldspdef)
 {
     if (OnLevelUp != null)
     {
         OnLevelUp.Invoke(this, new OnLevelUpEventArgs {
             Pokemon = pokemon, Battler = battler, HP = oldtotalhp, Atk = oldattack, Def = olddefense, Spe = oldspatk, Spa = oldspatk, Spd = oldspdef
         });
     }
 }
    public void LevelUp()
    {
        unitLevel++;
        availableStatPoints++;
        availableSkillPoints++;
        expToLevel = unitLevel * 50;
        OnLevelUp?.Invoke(this, 1000);

        Debug.Log("Player level up");
    }
예제 #8
0
        private void UpdateLevel()
        {
            var newLevel = CalculateLevel();

            if (_currentLevel.value < newLevel)
            {
                _currentLevel.value = newLevel;
                LevelUpEffect();
                OnLevelUp?.Invoke();
            }
        }
예제 #9
0
        private void SetLevelAndMaximumHitPoints()
        {
            int originalLevel = Level;

            Level = (ExperiencePoints / 100) + 1;
            if (Level != originalLevel)
            {
                MaximumHitPoints = Level * 10;
                OnLevelUp.Invoke(this, System.EventArgs.Empty);
            }
        }
예제 #10
0
파일: Player.cs 프로젝트: epham98/C-RPG
        private void SetLevelAndMaxHP()
        {
            int originalLevel = level;

            level = (EXP / 100) + 1;

            if (level != originalLevel)
            {
                maxHP = level * 10;
                OnLevelUp?.Invoke(this, System.EventArgs.Empty);
            }
        }
예제 #11
0
 // Update is called once per frame
 void Update()
 {
     if (/*Input.GetMouseButton(0) &&*/ canFire)
     {
         StartCoroutine(Fire());
     }
     if (canLevelUp && transform.childCount == 0)
     {
         canLevelUp = false;
         OnLevelUp?.Invoke();
     }
 }
예제 #12
0
    public void AddExperience(int amount)
    {
        experience += amount;
        while (experience >= experienceToNextLevel)
        {
            experience -= experienceToNextLevel; //Сначала вычесть, так как experienceToNextLevel зависит от уровня!
            level++;
            experienceToNextLevel = CalculateExperienceToNextLevel(level);

            OnLevelUp?.Invoke();
        }
    }
예제 #13
0
        private void UpdateLevel()
        {
            var newLevel = CalculateLevel();

            if (newLevel <= _currentLevel.value)
            {
                return;
            }
            _currentLevel.value = newLevel;
            LevelUpEffect();
            OnLevelUp?.Invoke();
        }
예제 #14
0
    // Update is called once per frame
    void OnInteractorStay(Interactor interactor)
    {
        if (MaxLevel || DisableShop)
        {
            return;
        }
        if (_currentInteractor == interactor)
        {
            if (!interactor.TryingToBuild())
            {
                interactionTime = 0;
                CancelRadishes();
                return;
            }

            RaddishCarrier carrier = interactor.GetComponentInParent <RaddishCarrier>();
            Debug.Assert(carrier != null, "Need raddishcarrier in interactor parents");

            interactionTime += Time.fixedDeltaTime;
            if (interactionTime >= TimeToAddRaddish)
            {
                Raddish raddish = carrier.RemoveForNewTarget(RaddishTargets[RaddishesWaitingAtTarget.Count]);
                if (raddish != null)
                {
                    RaddishesWaitingAtTarget.Add(raddish);
                    interactionTime = 0;
                }

                if (EnoughRadishesToLevel())
                {
                    foreach (Raddish r in RaddishesWaitingAtTarget)
                    {
                        r.AnimateOutAndHide();
                    }
                    RaddishesUsed.AddRange(RaddishesWaitingAtTarget);
                    RaddishesWaitingAtTarget.Clear();

                    if (CurrentLevel < LevelRequirements.Count - 1)
                    {
                        CurrentLevel += 1;
                        OnLevelUp?.Invoke(CurrentLevel);
                    }
                    else
                    {
                        MaxLevel = true;
                    }

                    SetRaddishTargetsForNewLevel();
                }
            }
        }
    }
예제 #15
0
        private void Awake()
        {
            onScoreUpdate   = new OnScoreUpdate();
            onLevelUp       = new OnLevelUp();
            onFillBarUpdate = new OnFillBarUpdate();

            _score = GetNextLevelUp(_level - 1);

            var matchColors = FindObjectOfType <MatchColors>();

            matchColors.on2048Reached.AddListener(On2048Reached);
            matchColors.onBubblesMatch.AddListener(OnBubblesMatch);
        }
예제 #16
0
        private void LevelUp()
        {
            Level += 1;

            OnLevelUp?.Invoke(Level);

            foreach (var keyValuePair in Attributes)
            {
                keyValuePair.Value.LevelUp();
            }

            PlayLevelUpEffect();
        }
예제 #17
0
 private void Collect(float amount)
 {
     _experience += amount;
     if (_currentWeaponIndex < allWeapons.Length - 1)
     {
         if (_experience >= experienceLevel[_currentWeaponIndex + 1])
         {
             _currentWeaponIndex++;
             _weaponController.SwitchWeapon(GetCurrentWeapon());
             OnLevelUp?.Invoke(_currentWeaponIndex);
         }
     }
     OnExperienceChange?.Invoke(_experience);
 }
예제 #18
0
파일: Levels.cs 프로젝트: phiLyken/RC_1
    public void AddProgress(int amount)
    {
        currentProgress += amount;
        config.UpdateProgress(currentProgress);
        int current_level = GetCurrentLevel();

        OnProgress.AttemptCall(currentProgress);

        if (cachedLevel != current_level)
        {
            cachedLevel = current_level;
            OnLevelUp.AttemptCall(current_level);
        }
    }
예제 #19
0
        private void UpdateLevel()
        {
            int newLevel = CalculateLevel();

            if (newLevel <= m_CurrentLevel.Value)
            {
                return;
            }
            m_CurrentLevel.Value = newLevel;
            if (OnLevelUp?.Invoke() == true)
            {
                LevelUpEffect();
            }
        }
예제 #20
0
            private void CheckForLevelUp()
            {
                if (IsAtMaxLevel)
                {
                    return;
                }

                while (experience > TotalExperienceForNextLevel)
                {
                    experience -= TotalExperienceForNextLevel;
                    level++;
                    OnLevelChange.Invoke(this, level);
                    OnLevelUp.Invoke(this, level);
                }
            }
예제 #21
0
            public void ModifyLevel(int levelDifference, bool resetExperience = true)
            {
                if (levelDifference != 0)
                {
                    int oldLevel = this.level;
                    level = Mathf.Clamp(level + levelDifference, 1, MaxLevel);
                    if (resetExperience)
                    {
                        experience = 0f;
                    }

                    OnLevelChange.Invoke(this, level);
                    if (oldLevel < level)
                    {
                        OnLevelUp.Invoke(this, level);
                    }
                }
            }
예제 #22
0
            public void SetLevel(int level, bool resetExperience = true)
            {
                if (this.level != level)
                {
                    int oldLevel = this.level;
                    this.level = Mathf.Clamp(level, 1, MaxLevel);
                    if (resetExperience)
                    {
                        experience = 0f;
                    }

                    OnLevelChange.Invoke(this, level);
                    if (oldLevel < level)
                    {
                        OnLevelUp.Invoke(this, level);
                    }
                }
            }
예제 #23
0
    public void InitializingLevel(int level)
    {
        if (this.level == 0)
        {
            this.level = level;

            experienceToNextLevel = CalculateExperienceToNextLevel(level);

            for (int i = 0; i < level; i++)
            {
                OnLevelUp?.Invoke();
            }
        }
        else
        {
            Debug.LogError("Try to attempt to ReInitialize");
        }
    }
예제 #24
0
        static EntityEvents()
        {
            var fragment = Platform.CoreFragment?.GetEntityEventsFragment() ?? throw Platform.FragmentException();

            fragment.Notify                      = args => OnNotify.SafeInvoke(args);
            fragment.PlayAnimation               = args => OnPlayAnimation.SafeInvoke(args);
            fragment.ProcessSpellCast            = args => OnProcessSpellCast.SafeInvoke(args);
            fragment.DoCast                      = args => OnDoCast.SafeInvoke(args);
            fragment.NewPath                     = args => OnNewPath.SafeInvoke(args);
            fragment.IssueOrder                  = args => OnIssueOrder.SafeInvoke(args);
            fragment.Teleport                    = args => OnTeleport.SafeInvoke(args);
            fragment.Aggro                       = args => OnAggro.SafeInvoke(args);
            fragment.BuffAdd                     = args => OnBuffAdd.SafeInvoke(args);
            fragment.BuffRemove                  = args => OnBuffRemove.SafeInvoke(args);
            fragment.LevelUp                     = args => OnLevelUp.SafeInvoke(args);
            fragment.SpellbookCastSpell          = args => OnSpellbookCastSpell.SafeInvoke(args);
            fragment.SpellbookStopCast           = args => OnSpellbookStopCast.SafeInvoke(args);
            fragment.SpellbookUpdateChargedSpell = args => OnSpellbookUpdateChargedSpell.SafeInvoke(args);
            fragment.OnIntegerPropertyChange     = args => OnIntegerPropertyChange.SafeInvoke(args);
            fragment.OnFloatPropertyChange       = args => OnFloatPropertyChange.SafeInvoke(args);
        }
예제 #25
0
        public void UpdateExperience(int delta)
        {
            var experienceAmount = AllEffects
                                   .Where(effect => effect is ExperienceEffect)
                                   .Select(effect => effect.Amount.Value)
                                   .Prepend(100f)
                                   .Max();

            Experience += (int)(delta * experienceAmount / 100f);
            if (Experience >= ExperienceRequired)
            {
                Level++;
                Experience         -= ExperienceRequired;
                ExperienceRequired += 100;

                foreach (var effect in Effects)
                {
                    effect.LevelUp();
                }

                UpdateStats();
                OnLevelUp?.Invoke(this, EventArgs.Empty);
            }
        }
예제 #26
0
    /*
     * public void setConstitution(int constitution) { this.constitution = constitution; }
     * public void setStrength(int strength) { this.strength = strength; }
     * public void setResistance(int resistance) { this.resistance = resistance; }
     * public void setAgility(int agility) { this.agility = agility; }
     * public void setAvailablePoints(int availablePoints) { this.availablePoints = availablePoints; }
     * public void setFireResistance(float fireResistance) { this.fireResistance = fireResistance; }
     * public void setPoisonResistance(float poisonResistance) { this.poisonResistance = poisonResistance; }
     * public void setParalyseResistance(float paralyseResistance) { this.paralyseResistance = paralyseResistance; }
     * public void setFearResistance(float fearResistance) { this.fearResistance = fearResistance; }
     */

    public void levelUp()
    {
        level++;
        hitPoints     += 5;
        actualLevelExp = nextLevelExp;
        nextLevelExp   = (nextLevelExp * getMultiplier());

        if (level % 3 == 0)
        {
            attack  += 2;
            defense += 2;
            speed   += 2;
        }
        else
        {
            attack++;
            defense++;
            speed++;
        }

        if (level % 5 == 0)
        {
            availablePoints += 2;
        }
        else
        {
            availablePoints++;
        }

        OnLevelUp?.Invoke();

        if (actualExp > nextLevelExp)
        {
            ObtainExp(0);
        }
    }
예제 #27
0
 internal static void InvokeOnLevelUp(int level)
 {
     OnLevelUp?.Invoke(level);
 }
예제 #28
0
 /// <summary>
 /// Invokes this character feature's OnLevelUp event. Generally, you should not call this yourself.
 /// </summary>
 protected internal void InvokeOnLevelUp(int level)
 {
     OnLevelUp?.Invoke(level);
 }
예제 #29
0
 public void LevelUp()
 {
     AvailablePoints += 1;
     OnLevelUp?.Invoke();
 }
예제 #30
0
 private void LevelUp()
 {
     OnLevelUp?.Invoke(_level);
     StartCoroutine(CoLevelUp());
 }