Advertisement
WilleMahMille

Exempel - Hero

Sep 27th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Uppgift_Hero {
  8.     class Program {
  9.         static void Main(string[] args) {
  10.  
  11.         }
  12.     }
  13.  
  14.     public class Humanoid {
  15.         public Humanoid() {
  16.         }
  17.  
  18.         void Attack(Humanoid target) {
  19.             int finalDamage = sword.damage;
  20.             int damageReduction = armorPoints / 3;
  21.  
  22.             finalDamage -= damageReduction;
  23.             armor.durability -= 1;
  24.             shield.durability -= 1;
  25.             helmet.durability -= 1;
  26.  
  27.             hp -= finalDamage > 0 ? finalDamage : 0;
  28.         }
  29.         public int hp { get; set; }
  30.         public int armorPoints {
  31.             get {
  32.                 return shield.shieldPoints * 2 + armor.armorPoints + helmet.armorPoints;
  33.             }
  34.  
  35.             set {
  36.                 armorPoints = value;
  37.             }
  38.         }
  39.  
  40.         Sword sword;
  41.         Armor armor;
  42.         Shield shield;
  43.         Helmet helmet;
  44.        
  45.     }
  46.  
  47.     public class Hero : Humanoid {
  48.         Hero() {
  49.         }
  50.  
  51.         public Castle castle;
  52.         List<Equipment> inventory;
  53.  
  54.     }
  55.     public class Enemy : Humanoid {
  56.         public Enemy() {
  57.         }
  58.        
  59.         Hero hero;
  60.  
  61.     }
  62.  
  63.     public class Equipment {
  64.         public Equipment(int durability) {
  65.  
  66.         }
  67.         public int durability { get; set; }
  68.  
  69.     }
  70.  
  71.     public class Shield : Equipment {
  72.         public Shield(int durability) : base(durability) {
  73.  
  74.         }
  75.  
  76.         public int shieldPoints { get; private set; }
  77.  
  78.     }
  79.     public class Armor : Equipment {
  80.         public Armor(int durability) : base(durability) {
  81.  
  82.         }
  83.  
  84.         public int armorPoints { get; private set; }
  85.  
  86.     }
  87.     public class Helmet : Equipment {
  88.         public Helmet(int durability) : base(durability) {
  89.  
  90.         }
  91.         public int armorPoints { get; private set; }
  92.     }
  93.     public class Sword : Equipment {
  94.         public Sword(int durability) : base(durability) {
  95.             Castle.Tower t = new Castle.Tower();
  96.         }
  97.         public int damage { get; private set; }
  98.     }
  99.  
  100.     public class Castle {
  101.         Castle(int towers) {
  102.             this.towers = new List<Tower>();
  103.             for(int i = 0; i < towers; i++) {
  104.                 this.towers.Add(new Tower());
  105.             }
  106.         }
  107.         public void AddEnemy(Enemy enemy) {
  108.             enemies.Add(enemy);
  109.         }
  110.  
  111.         public List<Tower> towers { get; }
  112.         List<Enemy> enemies;
  113.  
  114.         public class Tower {
  115.             public Tower() {
  116.             }
  117.             public void AddEnemy(Enemy enemy) {
  118.                 enemies.Add(enemy);
  119.             }
  120.             List<Enemy> enemies;
  121.         }
  122.  
  123.     }
  124.    
  125.  
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement