Exemple #1
0
 public bool Damage(ToolType toolType, ToolMaterial toolMaterial)
 {
     if (toolType.CanHarvest(this.toolType) && toolMaterial.StrongEnough(this.toolMaterial))
     {
         float multiplier = toolType.RightTool(this.toolType) ? toolMaterial.Multiplier : 1;
         currentDamage += Time.deltaTime * multiplier * 0.666666f;
         if (currentDamage >= totalDamage)
         {
             if (destroyed)
             {
                 return(true);
             }
             destroyed = true;
             ItemEntity.Spawn(transform.position, item, 1);
         }
     }
     else
     {
         currentDamage += Time.deltaTime * 0.2f;
     }
     if (currentDamage >= totalDamage)
     {
         destroyed = true;
         OnDestroyed();
         Destroy(gameObject);
         return(true);
     }
     return(false);
 }