A Status subclass named XpAttractRangeStatus that represents an XP attract range upgrade. It sets a title and icon, applies a multiplicative modifier to the player's CoinAttractRange stat in Refresh, and provides description and upgrade text based on the status level.
using System;
using System.Collections.Generic;
using System.Linq;
using Sandbox;
[Status(5, 0, 1f, 0, false )]
public class XpAttractRangeStatus : Status
{
public XpAttractRangeStatus()
{
Title = "XP Radar";
IconPath = "textures/icons/xp_range.png";
}
public override void Init(Player player)
{
base.Init(player);
}
public override void Refresh()
{
Description = GetDescription(Level);
Player.Modify(this, PlayerStat.CoinAttractRange, GetMultForLevel(Level), ModifierType.Mult);
}
public override string GetDescription(int newLevel)
{
return string.Format("Increase XP attract range by {0}%", GetPercentForLevel(Level));
}
public override string GetUpgradeDescription(int newLevel)
{
return newLevel > 1 ? string.Format("Increase XP attract range by {0}%→{1}%", GetPercentForLevel(newLevel - 1), GetPercentForLevel(newLevel)) : GetDescription(newLevel);
}
public float GetMultForLevel(int level)
{
return 1f + 0.6f * level + (level == 5 ? 1f : 0);
}
public float GetPercentForLevel(int level)
{
return 60 * level + (level == 5 ? 100 : 0);
}
}