Exemple #1
0
 public float DamageHealth(int raw)
 {
     //TBD
     if (status == Constants.StatusID.dead)
     {
         Debug.Log(this + " is already dead");
         return(0);
     }
     health -= raw;
     Debug.Log("Dealt " + raw + " damage to " + gameObject + ".");
     if (health <= 0)
     {
         health = 0;
         if (isimmortal)
         {
             status = Constants.StatusID.immortality;
             Debug.Log(this + " has been downed");
             return(0);
         }
         else
         {
             status = Constants.StatusID.dead;
             Debug.Log(this + " has been slain");
             UnitDeath();
             return(0);
         }
     }
     else
     {
         Debug.Log("Remaining health: " + health);
     }
     return(health);
 }
Exemple #2
0
 //This can be called in Start() of all derived classes.
 protected void BaseStart()
 {
     BattleManager.highestTurnID += 1;
     turnID = BattleManager.highestTurnID;
     BattleManager.activeunits.Add(BattleManager.highestTurnID, this);
     displayname  = "Unit " + BattleManager.highestTurnID;
     internalname = "Unit " + BattleManager.highestTurnID;
     health       = 100;
     maxhealth    = 100;
     mana         = 100;
     maxmana      = 100;
     stats        = new float[Constants.TOTAL_STATS];
     for (int i = 0; i < Constants.TOTAL_STATS; i++)
     {
         stats[i] = 0;
     }
     status = Constants.StatusID.normal;
     buffs  = new int[Constants.TOTAL_BUFFS];
     for (int i = 0; i < Constants.TOTAL_BUFFS; i++)
     {
         buffs[i] = 0;
     }
     buffDurations = new float[Constants.TOTAL_BUFFS];
     for (int i = 0; i < Constants.TOTAL_BUFFS; i++)
     {
         buffDurations[i] = 0;
     }
     isimmortal = false;
     delay      = Random.Range(Constants.MIN_RANDOM_DELAY, Constants.MAX_RANDOM_DELAY);
     Debug.Log(internalname + ": starting delay " + delay);
     //currentRow
     //positionInRow
     size = 1;
 }