Пример #1
0
        public void GiveReward()
        {
            if (!(GameMain.GameSession.GameMode is CampaignMode campaign))
            {
                return;
            }
            campaign.Money += GetReward(Submarine.MainSub);

            foreach (KeyValuePair <string, float> reputationReward in ReputationRewards)
            {
                if (reputationReward.Key.Equals("location", StringComparison.OrdinalIgnoreCase))
                {
                    Locations[0].Reputation.Value += reputationReward.Value;
                    Locations[1].Reputation.Value += reputationReward.Value;
                }
                else
                {
                    Faction faction = campaign.Factions.Find(faction1 => faction1.Prefab.Identifier.Equals(reputationReward.Key, StringComparison.OrdinalIgnoreCase));
                    if (faction != null)
                    {
                        faction.Reputation.Value += reputationReward.Value;
                    }
                }
            }

            if (Prefab.DataRewards != null)
            {
                foreach (var(identifier, value, operation) in Prefab.DataRewards)
                {
                    SetDataAction.PerformOperation(campaign.CampaignMetadata, identifier, value, operation);
                }
            }
        }
Пример #2
0
        public void GiveReward()
        {
            if (!(GameMain.GameSession.GameMode is CampaignMode campaign))
            {
                return;
            }
            int reward = GetReward(Submarine.MainSub);

            float baseExperienceGain = reward * 0.09f;

            float difficultyMultiplier = 1 + level.Difficulty / 100f;

            baseExperienceGain *= difficultyMultiplier;

            IEnumerable <Character> crewCharacters = GameSession.GetSessionCrewCharacters();

            // use multipliers here so that we can easily add them together without introducing multiplicative XP stacking
            var experienceGainMultiplier = new AbilityValue(1f);

            crewCharacters.ForEach(c => c.CheckTalents(AbilityEffectType.OnAllyGainMissionExperience, experienceGainMultiplier));
            crewCharacters.ForEach(c => experienceGainMultiplier.Value += c.GetStatValue(StatTypes.MissionExperienceGainMultiplier));

            int experienceGain = (int)(baseExperienceGain * experienceGainMultiplier.Value);

#if CLIENT
            foreach (Character character in crewCharacters)
            {
                character.Info?.GiveExperience(experienceGain, isMissionExperience: true);
            }
#else
            foreach (Barotrauma.Networking.Client c in GameMain.Server.ConnectedClients)
            {
                //give the experience to the stored characterinfo if the client isn't currently controlling a character
                (c.Character?.Info ?? c.CharacterInfo)?.GiveExperience(experienceGain, isMissionExperience: true);
            }
#endif

            // apply money gains afterwards to prevent them from affecting XP gains
            var moneyGainMission = new AbilityValueMission(1f, this);
            crewCharacters.ForEach(c => c.CheckTalents(AbilityEffectType.OnGainMissionMoney, moneyGainMission));
            crewCharacters.ForEach(c => moneyGainMission.Value += c.GetStatValue(StatTypes.MissionMoneyGainMultiplier));

            campaign.Money += (int)(reward * moneyGainMission.Value);

            foreach (Character character in crewCharacters)
            {
                character.Info.MissionsCompletedSinceDeath++;
            }

            foreach (KeyValuePair <string, float> reputationReward in ReputationRewards)
            {
                if (reputationReward.Key.Equals("location", StringComparison.OrdinalIgnoreCase))
                {
                    Locations[0].Reputation.AddReputation(reputationReward.Value);
                    Locations[1].Reputation.AddReputation(reputationReward.Value);
                }
                else
                {
                    Faction faction = campaign.Factions.Find(faction1 => faction1.Prefab.Identifier.Equals(reputationReward.Key, StringComparison.OrdinalIgnoreCase));
                    if (faction != null)
                    {
                        faction.Reputation.AddReputation(reputationReward.Value);
                    }
                }
            }

            if (Prefab.DataRewards != null)
            {
                foreach (var(identifier, value, operation) in Prefab.DataRewards)
                {
                    SetDataAction.PerformOperation(campaign.CampaignMetadata, identifier, value, operation);
                }
            }
        }