status/CurseDashHurtStatus.cs
using System;
using System.Collections.Generic;
using System.Linq;
using Sandbox;
[Status( 7, 0, 1f, 0, true )]
public class CurseDashHurtStatus : Status
{
public CurseDashHurtStatus()
{
Title = "Broken Shin";
IconPath = "textures/icons/curse_dash_hurt.png";
}
public override void Init( Player player )
{
base.Init( player );
}
public override void Refresh()
{
Description = GetDescription( Level );
}
public override string GetDescription( int newLevel )
{
return string.Format( "{0}% chance to lose {1} HP when you dash", GetPercentForLevel( Level ), GetAmountForLevel( Level ) );
}
public override string GetUpgradeDescription( int newLevel )
{
return newLevel > 1 ? string.Format( "{0}%→{1}% chance to lose {2}→{3} HP when you dash", GetPercentForLevel( newLevel - 1 ), GetPercentForLevel( newLevel ), GetAmountForLevel( newLevel - 1 ), GetAmountForLevel( newLevel ) ) : GetDescription( newLevel );
}
public override void OnDashStarted()
{
if(Game.Random.Float(0f, 1f) < GetChanceForLevel( Level ) )
{
Player.Damage( GetAmountForLevel( Level ), PlayerDamageType.Self );
Manager.Instance.PlaySfxNearby( "zombie.attack.player", Player.Position2D, pitch: Game.Random.Float( 1.25f, 1.35f ), volume: 0.9f, maxDist: 3f );
}
}
public float GetChanceForLevel( int level )
{
return 0.05f + 0.05f * level;
}
public float GetPercentForLevel( int level )
{
return 5 + 5 * level;
}
public float GetAmountForLevel( int level )
{
return 10 * level;
}
}