public int CreatureAttack(Creature creature, Player target) { if (CanAttack(creature, target)) { int dmgDealt = target.ReceiveDamage(creature.Strength, target.TotalDefense()); if (target.Health < 1) { //creature.Experience += 1 + target.Experience; target.Die(); } return dmgDealt; } return -1; }
internal List<DamageObject> CreatureCastSpell(Player target, Spell spell, Creature creature, GameTime gameTime) { List<DamageObject> DamagedPlayers = new List<DamageObject>(); int currentTime = (int)gameTime.TotalGameTime.TotalMilliseconds; if (spell.AreaSpell) { Coordinates TopLeftOfScreen = new Coordinates(creature.Position.X - 7, creature.Position.Y - 5); /* TODO: Make area spell healing possible! */ int n = 1; int y = 0; int x = 0; for (int i = 0; i < spell.Area.Length; i++) { if (n % 15 == 0) { y++; x = -1; } if (spell.Area[i] == 1) { //spriteBatch.Draw(spell.Sprite, new Vector2((float)(SpellDamage[index].Position.X - map.Players[0].Position.X + (Utility.ScreenX) - 7 + x) * Coordinates.Step, (float)(SpellDamage[index].Position.Y - map.Players[0].Position.Y + (Utility.ScreenY) - 5 + y) * Coordinates.Step), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); List<Player> CastOnPlayers = GetPlayersFromTile(new Coordinates(TopLeftOfScreen.X + x, TopLeftOfScreen.Y + y, creature.Position.Z)); for (int c = 0; c < CastOnPlayers.Count; c++) { Player player = CastOnPlayers[c]; if (player.Health > 0) { int DamageDealt = player.ReceiveDamage(spell.Damage + (creature.MagicStrength * 2), 0); int text_type = 0; if (spell.HealSpell) { text_type = DamageObject.Text_Healing; } else { text_type = DamageObject.Text_Damage; } DamagedPlayers.Add(new DamageObject(player, DamageDealt, text_type, currentTime, currentTime + DamageObject.DamageDuration)); if (player.Health < 1) { PlayerDie(creature, player); } } } } n++; x++; } } else { if (spell.HealSpell) { int damage = spell.Damage + (creature.MagicStrength * 2); if (creature.Health + damage > creature.MaxHealth) { damage = creature.MaxHealth - creature.Health; creature.Health = creature.MaxHealth; } else { creature.Health += damage; } int text_type = 0; if (spell.HealSpell) { text_type = DamageObject.Text_Healing; } else { text_type = DamageObject.Text_Damage; } DamagedPlayers.Add(new DamageObject(creature, damage, text_type, currentTime, currentTime + DamageObject.DamageDuration)); } else { int DamageDealt = target.ReceiveDamage(spell.Damage + (creature.MagicStrength * 2), 0); int text_type = 0; if (spell.HealSpell) { text_type = DamageObject.Text_Healing; } else { text_type = DamageObject.Text_Damage; } DamagedPlayers.Add(new DamageObject(target, DamageDealt, text_type, currentTime, currentTime + DamageObject.DamageDuration)); if (target.Health < 1) { PlayerDie(creature, target); } } } return DamagedPlayers; }