A Status subclass that gives the player extra projectiles per shot while applying penalties to attack speed and move speed. It sets title and icon, computes modifiers based on level, and provides description and upgrade text.
using System;
using System.Collections.Generic;
using System.Linq;
using Sandbox;
[Status(4, 0, 0.8f, 0, false )]
public class NumProjectileStatus : Status
{
public NumProjectileStatus()
{
Title = "More Bullets";
IconPath = "textures/icons/more_projectiles.png";
}
public override void Init(Player player)
{
base.Init(player);
}
public override void Refresh()
{
Description = GetDescription(Level);
Player.Modify(this, PlayerStat.NumProjectiles, GetNumProjectilesForLevel(Level), ModifierType.Add);
Player.Modify(this, PlayerStat.AttackSpeed, GetAttackSpeedMultForLevel(Level), ModifierType.Mult);
Player.Modify(this, PlayerStat.MoveSpeed, GetMoveSpeedMultForLevel(Level), ModifierType.Mult);
}
public override string GetDescription(int newLevel)
{
return string.Format("+{0} bullet per shot but reduce attack speed by {1}% and move speed by {2}%", GetNumProjectilesForLevel(Level), GetAttackSpeedPercentForLevel(Level), GetMoveSpeedPercentForLevel(Level));
}
public override string GetUpgradeDescription(int newLevel)
{
return newLevel > 1 ? string.Format("+{0}→+{1} bullet per shot but reduce attack speed by {2}%→{3}% and move speed by {4}%→{5}%", GetNumProjectilesForLevel(newLevel - 1), GetNumProjectilesForLevel(newLevel), GetAttackSpeedPercentForLevel(newLevel - 1), GetAttackSpeedPercentForLevel(newLevel), GetMoveSpeedPercentForLevel(newLevel - 1), GetMoveSpeedPercentForLevel(newLevel)) : GetDescription(newLevel);
}
public float GetNumProjectilesForLevel(int level) { return level; }
public float GetAttackSpeedMultForLevel(int level)
{
switch(level)
{
case 1: default: return 0.65f;
case 2: return 0.5f;
case 3: return 0.35f;
case 4: return 0.25f;
}
}
public float GetAttackSpeedPercentForLevel(int level)
{
switch ( level )
{
case 1: default: return 35;
case 2: return 50;
case 3: return 65;
case 4: return 75;
}
}
public float GetMoveSpeedMultForLevel( int level )
{
switch ( level )
{
case 1: default: return 1f - 0.15f;
case 2: return 1f - 0.3f;
case 3: return 1f - 0.45f;
case 4: return 1f - 0.55f;
}
}
public float GetMoveSpeedPercentForLevel( int level )
{
switch ( level )
{
case 1: default: return 15;
case 2: return 30;
case 3: return 45;
case 4: return 55;
}
}
}