Beispiel #1
0
        public static double GetCoefficient(this HealthCondition healthCondition)
        {
            var attribute = healthCondition.GetType()
                            .GetMember(healthCondition.ToString())[0]
                            .GetCustomAttributes(typeof(CoefficientAttribute), false)
                            .FirstOrDefault() as CoefficientAttribute;

            return(attribute != null ? attribute.Coefficient : 0);
        }
Beispiel #2
0
        public static string GetDescription(this HealthCondition healthCondition)
        {
            var attribute = healthCondition.GetType()
                            .GetMember(healthCondition.ToString())[0]
                            .GetCustomAttributes(typeof(DescriptionAttribute), false)
                            .FirstOrDefault() as DescriptionAttribute;

            return(attribute != null ? attribute.Description : null);
        }
Beispiel #3
0
    /// <summary>
    /// Consume the food. This function is called when the animal is touching the food
    /// </summary>
    /// <param name="val"></param>
    void EatFood(float val)
    {
        hp += val;

        if (hp > 0.7f * MAX_HP)
        {
            healthCond = HealthCondition.Healthy;
        }

        if (hp > MAX_HP)
            hp = MAX_HP;
    }
Beispiel #4
0
 public void Update(string name, string guardianName, string guardianAddress, string guardianPhone, string reasonHospitalization,
                    HealthCondition healthCondition, string image = null, Accommodation accommodation = null)
 {
     this.Name                  = name;
     this.GuardianName          = guardianName;
     this.GuardianAddress       = guardianAddress;
     this.GuardianPhone         = guardianPhone;
     this.ReasonHospitalization = reasonHospitalization;
     this.HealthCondition       = healthCondition;
     this.Image                 = image;
     this.Accommodation         = accommodation;
 }
Beispiel #5
0
 public Animal(string name, string guardianName, string guardianAddress, string guardianPhone, string reasonHospitalization, HealthCondition healthCondition, Accommodation accommodation, string image = null)
 {
     Id                    = Guid.NewGuid();
     Name                  = name;
     GuardianName          = guardianName;
     GuardianAddress       = guardianAddress;
     GuardianPhone         = guardianPhone;
     ReasonHospitalization = reasonHospitalization;
     HealthCondition       = healthCondition;
     Accommodation         = accommodation;
     Image                 = image;
 }
Beispiel #6
0
    /// <summary>
    /// Takes random amounts of damage and sets the enemy gamobject as the current enemy
    /// </summary>
    /// <param name="enemy"></param>
    void TakeDamage(AnimalController enemy)
    {
        attackTarget = enemy.gameObject;
        float val = Random.Range(1, 3);
        hp -= val;

        if (hp < 0.2f * MAX_HP)
        {
            healthCond = HealthCondition.Fatal;
        }

        if (hp < 0)
        {
            hp = 0;
            Destroy(gameObject);
        }
    }
Beispiel #7
0
    void DisplayHealth(HealthCondition health)
    {
        switch (health)
        {
        case HealthCondition.Healthy:
        {
            Text.text = "You are perfectly healthy.";
        }
        break;

        case HealthCondition.Nauseous:
        {
            Text.text = "You begin to feel a little sick from the smells of the place.";
        }
        break;

        case HealthCondition.Epidemic_Level_Sick:
        {
            Text.text = "You just barfed all over the place. -2 to Immunity";
        }
        break;
        }
    }
Beispiel #8
0
 private void RemoveCondition(HealthCondition condition)
 {
     status |= (int)condition;
     status ^= (int)condition;
 }
Beispiel #9
0
 private void AddCondition(HealthCondition condition)
 {
     status |= (int)condition;
 }