public void attack(Entity target) { if (playerTurn) { int AttackScore = this.friend.basicAttackHit(); int dodge = target.dodge(); // MessageBox.Show("First: " + AttackScore + " Second:" + dodge); if (AttackScore > dodge) { int damage = this.friend.basicAttackDamage(); target.takeDamage(damage); this.dataOut = "You hit " + target.name + " for " + damage + " damage!\r\n"; } else { this.dataOut = "You Missed!\r\n"; } //foe = target; foes[target.getInstanceID()] = target; } else { this.foe = foes[TurnOrder[turnID]]; if (this.foe.isAlive()) { int AttackScore = this.foe.basicAttackHit(); int dodge = target.dodge(); if (AttackScore > dodge) { int damage = this.foe.basicAttackDamage(); target.takeDamage(damage); this.dataOut = foe.name + " hit you for " + damage + " damage!\r\n"; } else { this.dataOut = foe.name + " Missed!\r\n"; } friend = target; } else { this.dataOut = ""; } } }
public void useEquipItem(Item tmpItem, ref Entity tmpTarget) { bool used = false; foreach (KeyValuePair<Item, int> tmpEntry in this.inventory) { if (!used && tmpItem == tmpEntry.Key) { if(tmpItem.GetType() == typeof(Weapon)){ if (tmpTarget.getEquipedWeapon() != null) { addItemToInventory(tmpTarget.getEquipedWeapon(), 1); tmpTarget.unequipWeapon(); tmpTarget.equipWeapon((Weapon)tmpItem); } } else if (tmpItem.GetType() == typeof(Potion)) { tmpTarget.takeDamage(((Potion)tmpItem).healDamage()); } } } }