Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualAndy474

Posted 21 May 2013 - 02:46 PM

Well, that would work, but what if the shuriken is build out of different spikes? Maybe one grants firedamage and another armor penetration? Would theses Objects still be waste of space?

 

Well are you really going to need them?

 

if you have todo this every frame to check what type of dmg todo:

if(allSpikesAreFireDmg)
  return 500000000000 fire dmg.

 

then yes, you'll need them.

 

Personally again, i'd go for once an object is made with spikes, have a DamageType enum, and jsut assign it.

public enum DamageType
{
    Common = 1,
    Fire,
    Ice,
    Shadow,
}
public enum WeaponBonus {
    ArmourPen = 1,
    WeaponDamage,
    MaxHealth,
    MagicResistance,
    MagicDamage,
}

So lets say we have a 2x Spikes with the follwing properties, and 1 Core with the follwing property:

 

Spike: 8 WeaponDamge, 1 max Health
Core: 8 WeaponDamage, 4 magic Resistance
 
//We can store in it a Dictionary (HashMap in java?) in each component an just sum it up in the Weapon.
HashMap<WeaponDamage, int> BuffsTable;
 
//Spike
HashMap<WeaponDamage, int> spikeBuffsTable = [WeaponDamage, 8][MaxHealth, 1]
 
//Core
HashMap<WeaponDamage, int> coreBuffsTable = [WeaponDamage, 8][magicResist, 4]
 
//BuffsTable summed
= [WeaponDamage 16, maxhealth 1, magicResist 4]
 

#1Andy474

Posted 21 May 2013 - 02:35 PM

Well, that would work, but what if the shuriken is build out of different spikes? Maybe one grants firedamage and another armor penetration? Would theses Objects still be waste of space?

 

Well are you really going to need them?

 

if you have todo this every frame to check what type of dmg todo:

 

if(allSpikesAreFireDmg)
  return 500000000000 fire dmg.

 

then yes, you'll need them.

 

Personally again, i'd go for once an object is made with spikes, have a DamageType enum, and jsut assign it.

 

public enum DamageType
{
    Common = 1,
    Fire,
    Ice,
    Shadow,
}
public enum WeaponBonus {
    ArmourPen = 1,
    MaxHealth = 2,
    MagicResistance = 4,
    MagicDamage = 8,
}

 

im not sure how possible the last is in java, but in c# you can mark an enum as a Bit Flag, So i could have multiple damage types on a singple weapon;

 

public WeaponBonus MyBonuses;
 
WeaponBonus = WeaponBonus.ArmourPen | WeaponBonus.MaxHealth; // Falg set to 3 or '0011'

 

and we can poll WeaponBonus like

 

public bool HasWeaponBonus(WeaponBonus bonus)
{
   return (MyBonuses & bonus) == bonus;
}

PARTNERS