Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.33 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Trap {
  6.  
  7.     // All Creatures have the following properties:
  8.     protected string trapName; //A "hallway of scything blades" stands before you.
  9.     private int trapDisarmDifficultyValue; //Secretly modifies result of Mechanics roll. -0, -15, -30
  10.     private int trapDisarmDifficultyDescription; //This trap...
  11.         //At -0, "<color=white>looks simple to disarm</color>"
  12.         //At -15, "<color=yellow>is of concerning difficulty to bypass</color>"
  13.         //At -30, "<color=orange>is fiendishly complex to understand, let alone disable</color>"
  14.     private string trapDamageDescription; //Like Creature weapon description. "Whirling blades" | "Crushing stone block" | "fusillade of envenomed darts" etc.
  15.     private int trapDamage; //Numerical damage dealt
  16.     private int trapMaxHealth; //How much damage the trap can endure before being smashed apart.
  17.     private int damageTaken; //As in Creature
  18.  
  19.     // This is the object that'll get called with parameters in order to actually create a trap.
  20.     public Trap (string trapName, int trapDisarmDifficultyValue, int trapDisarmDifficultyDescription, string trapDamageDescription, int trapDamage, int trapMaxHealth, int damageTaken)
  21.     {
  22.         this.trapName = trapName;
  23.         this.trapDisarmDifficultyValue = trapDisarmDifficultyValue;
  24.         this.trapDisarmDifficultyDescription = trapDisarmDifficultyDescription;
  25.         this.trapDamageDescription = trapDamageDescription;
  26.         this.trapDamage = trapDamage;
  27.         this.trapMaxHealth = trapMaxHealth;
  28.         this.damageTaken = 0;
  29.     }
  30.  
  31.     public bool isDead ()
  32.     {
  33.         return damageTaken >= trapMaxHealth;
  34.     }
  35.  
  36.     public int getCurrentHealth ()
  37.     {
  38.         if (isDead ()) {
  39.             return 0;
  40.         } else {
  41.             return trapMaxHealth - damageTaken;
  42.         }
  43.     }
  44.  
  45.     public int getMaxHealth ()
  46.     {
  47.         return trapMaxHealth;
  48.     }
  49.  
  50.     protected void setMaxHealth (int maxHealth)
  51.     {
  52.         this.trapMaxHealth = maxHealth;
  53.     }
  54.  
  55.     public void applyDamage (int damage)
  56.     {
  57.         this.damageTaken += damage;
  58.     }
  59.  
  60.     public void healDamage (int damage)
  61.     {
  62.         this.damageTaken -= damage;
  63.         if (damageTaken < 0) {
  64.             damageTaken = 0;
  65.         }
  66.     }
  67.  
  68.     // functions for getting and setting trapDisarmDifficultyValue
  69.     public int getDisarmDifficulty ()
  70.     {
  71.         return trapDisarmDifficultyValue;
  72.     }
  73.  
  74.     protected void setDisarmDifficulty (int trapDisarmDifficultyValue)
  75.     {
  76.         this.trapDisarmDifficultyValue = trapDisarmDifficultyValue;
  77.     }
  78.  
  79.     // functions for getting and setting trapDisarmDifficultyDescription
  80.     public int getDisarmDifficultyDescription ()
  81.     {
  82.         return trapDisarmDifficultyDescription;
  83.     }
  84.  
  85.     protected void setDisarmDifficultyDescription (int trapDisarmDifficultyDescription)
  86.     {
  87.         this.trapDisarmDifficultyDescription = trapDisarmDifficultyDescription;
  88.     }
  89.  
  90.     // functions for getting and setting trap damage description and damage value
  91.     public string getDamageDescription ()
  92.     {
  93.         return trapDamageDescription;
  94.     }
  95.  
  96.     public void setDamageDescription (string trapDamageDescription)
  97.     {
  98.         this.trapDamageDescription = trapDamageDescription;
  99.     }
  100.  
  101.     public int getTrapDamage ()
  102.     {
  103.         return trapDamage;
  104.     }
  105.  
  106.     protected void setTrapDamage (int trapDamage)
  107.     {
  108.         this.trapDamage = trapDamage;
  109.     }
  110.  
  111.     // Functions for miscellaneous creature stuff that still ought to be encapsulated
  112.     public string getTrapName ()
  113.     {
  114.         //return creatureName;
  115.         return trapName;
  116.     }
  117.  
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement