/** altered attack method to spawn projectiles on ranged attack */ protected override void attack(HittableTarget target, Boolean isMelee, Castle enemy) { if (canAttackType == CharacterEnums.EType.BOTH || canAttackType == target.myType || target.myType == CharacterEnums.EType.BOTH) { attackCounter++; if (attackCounter >= getAttackCount()) { attackCounter = 0; if (isMelee) { Logger.d(ToString() + " attacked " + target.ToString() + "(Melee " + getMeleeDamage() + " dmg)"); target.getHit(getMeleeDamage()); } else { Rectangle r = getLocation(); int bulletHeight = (int)(r.Center.Y + r.Height / getOffSetDivisor()); Logger.d(ToString() + " attacked " + target.ToString() + "(Ranged " + getRangedDamage() + " dmg)"); if (getFrontLocationX() > target.getFrontLocationX()) { projectiles.Add((Projectile)Activator.CreateInstance(getProjectileType(), new object[] { CharacterEnums.EDirection.LEFT, new Vector2(getFrontLocationX(), bulletHeight), getRangedDamage(), target, enemy })); } else { projectiles.Add((Projectile)Activator.CreateInstance(getProjectileType(), new object[] { CharacterEnums.EDirection.RIGHT, new Vector2(getFrontLocationX(), bulletHeight), getRangedDamage(), target, enemy })); } } } } }
/** altered attack method to kill themself on attack */ protected override void attack(HittableTarget target, Boolean isMelee, Castle enemy) { if (canAttackType == CharacterEnums.EType.BOTH || canAttackType == target.myType || target.myType == CharacterEnums.EType.BOTH) { attackCounter++; if (attackCounter >= getAttackCount()) { attackCounter = 0; Logger.d(ToString() + " attacked " + target.ToString() + "(Melee " + getMeleeDamage() + " dmg)"); target.getHit(getMeleeDamage()); this.healthBar.sethealth(0); } } }