public int GetGoldGainsFromKillData(
            MPPerkObject.MPPerkHandler killerPerkHandler,
            MPPerkObject.MPPerkHandler assistingHitterPerkHandler,
            MultiplayerClassDivisions.MPHeroClass victimClass,
            bool isAssist)
        {
            int num1;

            if (isAssist)
            {
                num1 = (killerPerkHandler != null ? killerPerkHandler.GetRewardedGoldOnAssist() : 0) + (assistingHitterPerkHandler != null ? assistingHitterPerkHandler.GetGoldOnAssist() : 0);
            }
            else
            {
                int num2 = this.ControlledAgent != null?MultiplayerClassDivisions.GetMPHeroClassForCharacter(this.ControlledAgent.Character).TroopCost : 0;

                num1 = killerPerkHandler != null?killerPerkHandler.GetGoldOnKill((float)num2, (float)victimClass.TroopCost) : 0;
            }
            if (num1 > 0)
            {
                GameNetwork.BeginModuleEventAsServer(this.Peer);
                GameNetwork.WriteMessage((GameNetworkMessage) new TDMGoldGain(new List <KeyValuePair <ushort, int> >()
                {
                    new KeyValuePair <ushort, int>((ushort)2048, num1)
                }));
                GameNetwork.EndModuleEventAsServer();
            }
            return(num1);
        }
Beispiel #2
0
        public int GetGoldGainsFromKillDataAndUpdateFlags(
            MPPerkObject.MPPerkHandler killerPerkHandler,
            MPPerkObject.MPPerkHandler assistingHitterPerkHandler,
            MultiplayerClassDivisions.MPHeroClass victimClass,
            bool isAssist,
            bool isRanged)
        {
            int num1 = 0;
            List <KeyValuePair <ushort, int> > goldChangeEventList = new List <KeyValuePair <ushort, int> >();

            if (isAssist)
            {
                int num2 = 1;
                int num3 = (killerPerkHandler != null ? killerPerkHandler.GetRewardedGoldOnAssist() : 0) + (assistingHitterPerkHandler != null ? assistingHitterPerkHandler.GetGoldOnAssist() : 0);
                if (num3 > 0)
                {
                    num1 += num3;
                    this._currentGoldGains |= GoldGainFlags.PerkBonus;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)2048, num3));
                }
                switch (this.MissionPeer.AssistCount - this._assistCountOnSpawn)
                {
                case 1:
                    num1 += 10;
                    this._currentGoldGains |= GoldGainFlags.FirstAssist;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)4, 10));
                    break;

                case 2:
                    num1 += 10;
                    this._currentGoldGains |= GoldGainFlags.SecondAssist;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)8, 10));
                    break;

                case 3:
                    num1 += 10;
                    this._currentGoldGains |= GoldGainFlags.ThirdAssist;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)16, 10));
                    break;

                default:
                    num1 += num2;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)256, num2));
                    break;
                }
            }
            else
            {
                int num2 = 0;
                if (this.ControlledAgent != null)
                {
                    num2 = MultiplayerClassDivisions.GetMPHeroClassForCharacter(this.ControlledAgent.Character).TroopCost;
                    int num3 = 2 + Math.Max(0, (victimClass.TroopCost - num2) / 2);
                    num1 += num3;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)128, num3));
                }
                int num4 = killerPerkHandler != null?killerPerkHandler.GetGoldOnKill((float)num2, (float)victimClass.TroopCost) : 0;

                if (num4 > 0)
                {
                    num1 += num4;
                    this._currentGoldGains |= GoldGainFlags.PerkBonus;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)2048, num4));
                }
                switch (this.MissionPeer.KillCount - this._killCountOnSpawn)
                {
                case 5:
                    num1 += 20;
                    this._currentGoldGains |= GoldGainFlags.FifthKill;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)32, 20));
                    break;

                case 10:
                    num1 += 30;
                    this._currentGoldGains |= GoldGainFlags.TenthKill;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)64, 30));
                    break;
                }
                if (isRanged && !this._currentGoldGains.HasAnyFlag <GoldGainFlags>(GoldGainFlags.FirstRangedKill))
                {
                    num1 += 10;
                    this._currentGoldGains |= GoldGainFlags.FirstRangedKill;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)1, 10));
                }
                if (!isRanged && !this._currentGoldGains.HasAnyFlag <GoldGainFlags>(GoldGainFlags.FirstMeleeKill))
                {
                    num1 += 10;
                    this._currentGoldGains |= GoldGainFlags.FirstMeleeKill;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)2, 10));
                }
            }
            int num5 = 0;

            if (this.MissionPeer.Team == Mission.Current.Teams.Attacker)
            {
                num5 = MultiplayerOptions.OptionType.GoldGainChangePercentageTeam1.GetIntValue();
            }
            else if (this.MissionPeer.Team == Mission.Current.Teams.Defender)
            {
                num5 = MultiplayerOptions.OptionType.GoldGainChangePercentageTeam2.GetIntValue();
            }
            if (num5 != 0 && (num1 > 0 || goldChangeEventList.Count > 0))
            {
                num1 = 0;
                float num2 = (float)(1.0 + (double)num5 * 0.00999999977648258);
                for (int index = 0; index < goldChangeEventList.Count; ++index)
                {
                    int num3 = (int)((double)goldChangeEventList[index].Value * (double)num2);
                    goldChangeEventList[index] = new KeyValuePair <ushort, int>(goldChangeEventList[index].Key, num3);
                    num1 += num3;
                }
            }
            if (goldChangeEventList.Count > 0 && !this.Peer.Communicator.IsServerPeer && this.Peer.Communicator.IsConnectionActive)
            {
                GameNetwork.BeginModuleEventAsServer(this.Peer);
                GameNetwork.WriteMessage((GameNetworkMessage) new TDMGoldGain(goldChangeEventList));
                GameNetwork.EndModuleEventAsServer();
            }
            return(num1);
        }