I have a bullet that can be one of 4 Types. Depending on which unit it hits the damage will be amplified or decreased.
Here is the code:
if(bullet.bulletType == Bullet.BulletType.AIR)
{
if(unitType == UnitType.AIR)
{
currentHP -= (int)bullet.damage;
} else if(unitType == UnitType.WATER)
{
currentHP -= (int)bullet.damage * 2;
} else if (unitType == UnitType.FIRE)
{
currentHP -= (int)bullet.damage;
}
else if (unitType == UnitType.EARTH)
{
currentHP -= (int)bullet.damage / 2;
}
} else if(bullet.bulletType == Bullet.BulletType.WATER)
{
if (unitType == UnitType.AIR)
{
currentHP -= (int)bullet.damage / 2;
}
else if (unitType == UnitType.WATER)
{
currentHP -= (int)bullet.damage;
}
else if (unitType == UnitType.FIRE)
{
currentHP -= (int)bullet.damage * 2;
}
else if (unitType == UnitType.EARTH)
{
currentHP -= (int)bullet.damage;
}
}
else if (bullet.bulletType == Bullet.BulletType.FIRE)
{
if (unitType == UnitType.AIR)
{
currentHP -= (int)bullet.damage;
}
else if (unitType == UnitType.WATER)
{
currentHP -= (int)bullet.damage / 2;
}
else if (unitType == UnitType.FIRE)
{
currentHP -= (int)bullet.damage;
}
else if (unitType == UnitType.EARTH)
{
currentHP -= (int)bullet.damage * 2;
}
}
else if (bullet.bulletType == Bullet.BulletType.EARTH)
{
if (unitType == UnitType.AIR)
{
currentHP -= (int)bullet.damage * 2;
}
else if (unitType == UnitType.WATER)
{
currentHP -= (int)bullet.damage;
}
else if (unitType == UnitType.FIRE)
{
currentHP -= (int)bullet.damage / 2;
}
else if (unitType == UnitType.EARTH)
{
currentHP -= (int)bullet.damage;
}
}
What is a better way of doing this?