Added self-sacrifice upgrade to living armour.

This commit is contained in:
WayofTime 2016-01-05 12:17:05 -05:00
parent dceec15750
commit b74ed8d431
9 changed files with 220 additions and 23 deletions

View file

@ -0,0 +1,57 @@
package WayofTime.bloodmagic.livingArmour;
import net.minecraft.nbt.NBTTagCompound;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
public class LivingArmourUpgradeSelfSacrifice extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 10, 25, 50, 80, 120 };
public static final double[] sacrificeModifier = new double[] { 0.2, 0.4, 0.6, 0.8, 1.0 };
public LivingArmourUpgradeSelfSacrifice(int level)
{
super(level);
}
public double getSacrificeModifier()
{
return sacrificeModifier[this.level];
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.selfSacrifice";
}
@Override
public int getMaxTier()
{
return 5; // Set to here until I can add more upgrades to it.
}
@Override
public int getCostOfUpgrade()
{
return costs[this.level];
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
// EMPTY
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
// EMPTY
}
@Override
public String getUnlocalizedName()
{
return tooltipBase + "selfSacrifice";
}
}

View file

@ -0,0 +1,88 @@
package WayofTime.bloodmagic.livingArmour;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
public class StatTrackerSelfSacrifice extends StatTracker
{
public static HashMap<LivingArmour, Integer> changeMap = new HashMap<LivingArmour, Integer>();
public static int[] sacrificesRequired = new int[] { 50, 200, 400, 600, 800 }; //testing
public int totalSacrifices = 0;
public static void incrementCounter(LivingArmour armour)
{
changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1);
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".tracker.selfSacrifice";
}
@Override
public void resetTracker()
{
this.totalSacrifices = 0;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
totalSacrifices = tag.getInteger(Constants.Mod.MODID + ".tracker.selfSacrifice");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setInteger(Constants.Mod.MODID + ".tracker.selfSacrifice", totalSacrifices);
}
@Override
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (changeMap.containsKey(livingArmour))
{
int change = Math.abs(changeMap.get(livingArmour));
if (change > 0)
{
totalSacrifices += Math.abs(changeMap.get(livingArmour));
changeMap.put(livingArmour, 0);
this.markDirty();
return true;
}
}
return false;
}
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 5; i++)
{
if (totalSacrifices > sacrificesRequired[i])
{
upgradeList.add(new LivingArmourUpgradeSelfSacrifice(i));
}
}
return upgradeList;
}
}