Exemplo n.º 1
0
        private void ApplyUpgradesAndAttributeModifiersForNextLevel()
        {
            if (_nextLevel.Upgrades != null)
            {
                foreach (var upgrade in _nextLevel.Upgrades)
                {
                    upgrade.Value.GrantUpgrade(_gameObject);
                }
            }

            if (_nextLevel.AttributeModifiers != null)
            {
                foreach (var modifierList in _nextLevel.AttributeModifiers)
                {
                    var attributeModifier = new AttributeModifier(modifierList.Value);
                    _gameObject.AddAttributeModifier(modifierList.Value.Name, attributeModifier);
                }
            }
        }
Exemplo n.º 2
0
        internal override void Update(BehaviorUpdateContext context)
        {
            if (_initial && _experienceLevels == null)
            {
                Initialize(context);
            }

            if (_experienceLevels == null ||
                _experienceLevels.Count == 0 ||
                _gameObject.ExperienceValue < _nextLevel.RequiredExperience)
            {
                return;
            }

            _gameObject.ExperienceValue -= _nextLevel.RequiredExperience;
            _gameObject.Rank             = _nextLevel.Rank;

            //remove stuff from current level
            if (_currentLevel != null)
            {
                if (_currentLevel.Upgrades != null)
                {
                    foreach (var upgrade in _currentLevel.Upgrades)
                    {
                        _gameObject.RemoveUpgrade(upgrade.Value);
                    }
                }

                if (_currentLevel.AttributeModifiers != null)
                {
                    foreach (var modifierList in _currentLevel.AttributeModifiers)
                    {
                        _gameObject.RemoveAttributeModifier(modifierList.Value.Name);
                    }
                }
            }


            if (_nextLevel.Upgrades != null)
            {
                foreach (var upgrade in _nextLevel.Upgrades)
                {
                    _gameObject.Upgrade(upgrade.Value);
                }
            }

            if (_nextLevel.AttributeModifiers != null)
            {
                foreach (var modifierList in _nextLevel.AttributeModifiers)
                {
                    var attributeModifier = new AttributeModifier(modifierList.Value);
                    _gameObject.AddAttributeModifier(modifierList.Value.Name, attributeModifier);
                }
            }

            if (_nextLevel.LevelUpFX != null)
            {
                _nextLevel.LevelUpFX.Value?.Execute(new FXListExecutionContext(
                                                        context.GameObject.Rotation,
                                                        context.GameObject.Translation,
                                                        context.GameContext));
            }

            if (_nextLevel.InformUpdateModule)
            {
                _bannerCarrierUpdate?.NotifyLevelChanged();
            }

            if (_nextLevel.SelectionDecal != null)
            {
                _gameObject.SelectionDecal = _nextLevel.SelectionDecal;
            }

            // TODO:
            // ExperienceAwardOwnGuysDie -> what is this?
            // EmotionType

            _experienceLevels.RemoveAt(0);
            if (_experienceLevels.Count > 0)
            {
                _currentLevel = _nextLevel;
                _nextLevel    = _experienceLevels.First();
                _gameObject.ExperienceRequiredForNextLevel = _nextLevel.RequiredExperience;
            }
            else
            {
                _gameObject.ExperienceRequiredForNextLevel = int.MaxValue;
            }
        }