Added "Trick Shot" upgrade to the armour - when trained, your bow will shoot more than one arrow.

This commit is contained in:
WayofTime 2016-01-06 22:07:17 -05:00
parent 2cf7da8603
commit 828edf298e
7 changed files with 258 additions and 1 deletions

View file

@ -0,0 +1,66 @@
package WayofTime.bloodmagic.livingArmour;
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.ILivingArmour;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
public class LivingArmourUpgradeArrowShot extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 20, 50, 90, 160, 290 };
public static final int[] extraArrow = new int[] { 1, 2, 3, 4, 5 };
public LivingArmourUpgradeArrowShot(int level)
{
super(level);
}
@Override
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
{
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.arrowShot";
}
@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)
{
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
}
@Override
public String getUnlocalizedName()
{
return tooltipBase + "arrowShot";
}
public int getExtraArrows()
{
return extraArrow[this.level];
}
}

View file

@ -0,0 +1,87 @@
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 StatTrackerArrowShot extends StatTracker
{
public int totalShots = 0;
public static HashMap<LivingArmour, Integer> changeMap = new HashMap<LivingArmour, Integer>();
public static int[] shotsRequired = new int[] { 50, 200, 700, 1500, 3000 };
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.trickShot";
}
@Override
public void resetTracker()
{
this.totalShots = 0;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
totalShots = tag.getInteger(Constants.Mod.MODID + ".tracker.trickShot");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setInteger(Constants.Mod.MODID + ".tracker.trickShot", totalShots);
}
@Override
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (changeMap.containsKey(livingArmour))
{
int change = Math.abs(changeMap.get(livingArmour));
if (change > 0)
{
totalShots += 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 (totalShots >= shotsRequired[i])
{
upgradeList.add(new LivingArmourUpgradeArrowShot(i));
}
}
return upgradeList;
}
}

View file

@ -56,7 +56,7 @@ public class StatTrackerMovement extends StatTracker
return false;
}
if (player.isAirBorne)
if (!player.onGround)
{
return false;
}