Mineplex2018-withcommit/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillCharge.java

69 lines
1.5 KiB
Java
Raw Normal View History

2014-04-02 06:19:58 +02:00
package mineplex.minecraft.game.classcombat.Skill;
2014-04-02 12:22:21 +02:00
import java.util.WeakHashMap;
2014-04-02 06:19:58 +02:00
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
import org.bukkit.entity.Player;
2014-04-02 12:22:21 +02:00
public class SkillCharge extends Skill
2014-04-02 06:19:58 +02:00
{
2014-04-02 12:22:21 +02:00
protected WeakHashMap<Player, Float> _charge = new WeakHashMap<Player, Float>();
protected WeakHashMap<Player, Long> _chargeStart = new WeakHashMap<Player, Long>();
2014-04-02 06:19:58 +02:00
protected float _rateBase;
protected float _rateBoost;
2014-04-02 12:22:21 +02:00
2014-04-02 06:19:58 +02:00
public SkillCharge(SkillFactory skills, String name, ClassType classType,
SkillType skillType, int cost, int maxLevel,
2014-04-02 12:22:21 +02:00
float base, float boost)
2014-04-02 06:19:58 +02:00
{
super(skills, name, classType, skillType, cost, maxLevel);
_rateBase = base;
_rateBoost = boost;
}
2014-04-02 12:22:21 +02:00
public boolean Charge(Player player)
2014-04-02 06:19:58 +02:00
{
//Level
int level = getLevel(player);
2014-04-02 12:22:21 +02:00
if (level == 0)
return false;
2014-04-02 06:19:58 +02:00
2014-04-02 12:22:21 +02:00
//Add & Recharge
if (!_charge.containsKey(player))
_charge.put(player, 0f);
2014-04-02 06:19:58 +02:00
2014-04-02 12:22:21 +02:00
float charge = _charge.get(player);
2014-04-02 06:19:58 +02:00
2014-04-02 12:22:21 +02:00
//Increase Charge
charge = Math.min(1f, charge + _rateBase + (_rateBoost * level));
_charge.put(player, charge);
2014-04-02 06:19:58 +02:00
2014-04-02 12:22:21 +02:00
//Display
DisplayProgress(player, GetName(level), charge);
2014-04-02 06:19:58 +02:00
2014-04-02 12:22:21 +02:00
return charge >= 1;
}
2014-04-02 06:19:58 +02:00
2014-04-02 12:22:21 +02:00
public float GetCharge(Player player)
{
2014-04-02 06:19:58 +02:00
if (!_charge.containsKey(player))
2014-04-02 12:22:21 +02:00
return 0f;
2014-04-02 06:19:58 +02:00
2014-04-02 12:22:21 +02:00
return _charge.get(player);
2014-04-02 06:19:58 +02:00
}
public void Reset(Player player)
{
_charge.remove(player);
_chargeStart.remove(player);
2014-04-02 06:19:58 +02:00
}
2014-04-02 12:22:21 +02:00
public String GetChargeString()
{
return "Charges #"+(int)(0.02*2000)+"#"+(int)(0.005*2000)+" % per Second.";
}
2014-04-02 06:19:58 +02:00
}