Exemplo n.º 1
0
 private void CheckStatus(object sender, CurrentHPArgs e)
 {
     if (e.currentHp == maxHp)
     {
         status = $"{name} is in perfect health!";
         Console.WriteLine(status);
     }
     if ((e.currentHp >= maxHp / 2) && (e.currentHp < maxHp))
     {
         status = $"{name} is doing well!";
         Console.WriteLine(status);
     }
     if ((e.currentHp >= maxHp / 4) && (e.currentHp < maxHp / 2))
     {
         status = $"{name} isn't doing too great...";
         Console.WriteLine(status);
     }
     if ((e.currentHp > 0) && (e.currentHp < maxHp / 4))
     {
         status = $"{name} needs help!";
         Console.WriteLine(status);
     }
     if (e.currentHp == 0)
     {
         status = $"{name} is knocked out!";
         Console.WriteLine(status);
     }
 }
Exemplo n.º 2
0
    private void CheckStatus(object sender, CurrentHPArgs e)
    {
        if (e.currentHp == this.maxHp)
        {
            this.status = String.Format("{0} is in perfect health!", this.name);
        }
        else if (e.currentHp >= (this.maxHp / 2) && e.currentHp < this.maxHp)
        {
            this.status = String.Format("{0} is doing well!", this.name);
        }
        else if (e.currentHp >= (this.maxHp * 0.25f) && e.currentHp < (this.maxHp / 2))
        {
            this.status = String.Format("{0} isn't doing too great...", this.name);
        }
        else if (e.currentHp > 0 && e.currentHp <= (this.maxHp / 2))
        {
            this.status = String.Format("{0} needs help!", this.name);
        }
        else
        {
            this.status = String.Format("{0} is knocked out!", this.name);
        }

        System.Console.WriteLine(this.status);
    }
Exemplo n.º 3
0
    ///<summary> Method to check the player status </summary>
    private void CheckStatus(object sender, CurrentHPArgs e)
    {
        if (e.currentHp == maxHp)
        {
            status = $"{name} is in perfect health!";
        }
        else if (maxHp / 2 <= e.currentHp)
        {
            status = $"{name} is doing well!";
        }
        else if (maxHp / 4 <= e.currentHp)
        {
            status = $"{name} isn't doing too great...";
        }
        else if (0 < e.currentHp)
        {
            status = $"{name} needs help!";
        }
        else
        {
            status = $"{name} is knocked out!";
        }

        Console.WriteLine(status);
    }
Exemplo n.º 4
0
    private void CheckStatus(object sender, CurrentHPArgs e)
    {
        if (e.currentHp == this.maxHp)
        {
            this.status = this.name + " is in perfect health!";
        }
        else if (e.currentHp >= (maxHp / 2) && e.currentHp < maxHp)
        {
            this.status = this.name + " is doing well!";
        }
        else if (e.currentHp < (maxHp / 2) && e.currentHp >= (maxHp / 4))
        {
            this.status = this.name + " isn't doing too great...";
        }
        else if (e.currentHp < (maxHp / 4) && e.currentHp > 0)
        {
            this.status = this.name + " needs help!";
        }
        else if (e.currentHp == 0)
        {
            this.status = this.name + " is knocked out!";
        }

        Console.WriteLine(this.status);
    }
Exemplo n.º 5
0
    private void CheckStatus(object sender, CurrentHPArgs e)
    {
        float halfMax  = maxHp / 2;
        float quartMax = maxHp / 4;

        if (e.currentHp == maxHp)
        {
            status = $"{name} is in perfect health!";
        }
        else if (e.currentHp >= halfMax)
        {
            status = $"{name} is doing well!";
        }
        else if (e.currentHp >= quartMax)
        {
            status = $"{name} isn't doing too great...";
        }
        else if (e.currentHp > 0)
        {
            status = $"{name} needs help!";
        }
        else if (e.currentHp == 0)
        {
            status = $"{name} is knocked out!";
        }
        Console.WriteLine(status);
    }
    private void CheckStatus(object sender, CurrentHPArgs e)
    {
        if (e.currentHp == this.maxHp)
        {
            this.status = $"{name} is in perfect health!";
        }
        else if (e.currentHp >= (this.maxHp * 0.5f) && e.currentHp < this.maxHp)
        {
            this.status = $"{name} is doing well!";
        }
        else if (e.currentHp >= (this.maxHp * 0.25f) && e.currentHp < (this.maxHp * 0.5f))
        {
            this.status = $"{name} isn't doing too great...";
        }
        else if (e.currentHp > 0f && e.currentHp < (this.maxHp * 0.25f))
        {
            this.status = $"{name} needs help!";
        }
        else if (e.currentHp == 0)
        {
            this.status = $"{name} is knocked out!";
        }

        Console.WriteLine(this.status);
    }
 /// <sumary> Method to check if currentHp status is less than 1/4 * maxHp </sumary>
 public void OnCheckStatus(CurrentHPArgs e)
 {
     if (e.currentHp < maxHp / 4)
     {
         HPCheck += HPValueWarning;
     }
     HPCheck(this, e);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Checks status and perform event depending on the situation.
 /// </summary>
 /// <param name="e">CurrentHPArgs event</param>
 public void OnCheckStatus(CurrentHPArgs e)
 {
     CheckStatus(HPCheck, e);
     if (e.currentHp <= (this.maxHp * 0.25))
     {
         HPValueWarning(HPCheck, e);
     }
 }
Exemplo n.º 9
0
 // Method that checks currentHP
 private void OnCheckStatus(CurrentHPArgs e)
 {
     if (e.currentHp <= (this.maxHp / 4.0f))
     {
         HPCheck += HPValueWarning;
     }
     HPCheck?.Invoke(this, e);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Hey, listen!
 /// </summary>
 void OnCheckStatus(object sender, CurrentHPArgs e)
 {
     if (e.currentHp < maxHp * 0.25f)
     {
         HPCheck += HPValueWarning;
     }
     HPCheck(this, e);
 }
Exemplo n.º 11
0
 private void OnCheckStatus(CurrentHPArgs e)
 {
     if (e.currentHp < (this.maxHp / 4))
     {
         HPCheck += HPValueWarning;
     }
     HPCheck(this, e);
 }
Exemplo n.º 12
0
 private void HPValueWarning(object sender, CurrentHPArgs e)
 {
     if (e.currentHp == 0)
     {
         Console.WriteLine("Health has reached zero!");
     }
     else
     {
         Console.WriteLine("Health is low!");
     }
 }
Exemplo n.º 13
0
    /// <summary>
    /// Helper function for raising events
    /// </summary>
    /// <param name="e">Event parameters</param>
    public void RaiseHPEvent(CurrentHPArgs e)
    {
        EventHandler <CurrentHPArgs> raiseEvent = HPCheck;

        if (raiseEvent == null)
        {
            return;
        }

        raiseEvent(this, e);
    }
Exemplo n.º 14
0
 private void HPValueWarning(object sender, CurrentHPArgs e)
 {
     Console.ForegroundColor = ConsoleColor.White;
     if (e.currentHp == 0)
     {
         System.Console.WriteLine("Health has reached zero!", Console.ForegroundColor);
     }
     else
     {
         System.Console.WriteLine("Health is low!");
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// this method triggers the warnig if the health is lower than 1/4
 /// </summary>
 /// <param name="e"> the health </param>
 public void OnCheckStatus(CurrentHPArgs e)
 {
     if (e.currentHp <= this.maxHp / 4f)
     {
         HPCheck += HPValueWarning;
     }
     else
     {
         HPCheck -= HPValueWarning;
     }
     HPCheck(this, e);
 }
 private void OnCheckStatus(CurrentHPArgs e)
 {
     if (e.currentHp <= this.maxHp / 4)
     {
         HPCheck += HPValueWarning;
     }
     else
     {
         HPCheck -= HPValueWarning;
     }
     HPCheck.Invoke(this, e);
 }
 /// <summary>Determines which HP status function to use.</summary>
 /// <param name="e">Arguments object containing current HP value.</param>
 private void OnCheckStatus(CurrentHPArgs e)
 {
     if (e.currentHp <= this.maxHp / 4)
     {
         this.CheckStatus(this, e);
         this.HPCheck = this.HPValueWarning;
     }
     else
     {
         this.HPCheck = this.CheckStatus;
     }
     this.HPCheck(this, e);
 }
 /// <sumary> class to handler the events </sumary>
 private void HPValueWarning(object sender, CurrentHPArgs e)
 {
     Console.BackgroundColor = ConsoleColor.Red;
     Console.ForegroundColor = ConsoleColor.White;
     if (e.currentHp == 0)
     {
         Console.WriteLine("Health has reached zero!");
     }
     else
     {
         Console.WriteLine("Health is low!");
     }
     Console.ResetColor();
 }
Exemplo n.º 19
0
 private void HPValueWarning(object sender, CurrentHPArgs e)
 {
     if (e.currentHp == 0f)
     {
         Console.BackgroundColor = ConsoleColor.DarkRed;
         Console.WriteLine("Health has reached zero!");
         Console.BackgroundColor = ConsoleColor.Black;
     }
     else
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Health is low!");
         Console.ForegroundColor = ConsoleColor.Black;
     }
 }
Exemplo n.º 20
0
    /// <summary>
    /// Helper function for raising events
    /// </summary>
    /// <param name="e">Event parameters</param>
    public void OnCheckStatus(CurrentHPArgs e)
    {
        EventHandler <CurrentHPArgs> raiseEvent = HPCheck;

        if (raiseEvent == null)
        {
            return;
        }

        if (e.currentHp <= this.maxHp / 4f)
        {
            raiseEvent += HPValueWarning;
        }

        raiseEvent(this, e);
    }
Exemplo n.º 21
0
    /// <summary>
    /// Sets the new Hp
    /// </summary>
    /// <param name="newHp"></param>
    public void ValidateHP(float newHp)
    {
        if (newHp < 0)
        {
            this.hp = 0;
        }
        else if (newHp >= this.maxHp)
        {
            this.hp = this.maxHp;
        }
        else
        {
            this.hp = newHp;
        }
        CurrentHPArgs myHp = new CurrentHPArgs(this.hp);

        CheckStatus(HPCheck, myHp);
    }
 private void CheckStatus(object sender, CurrentHPArgs e)
 {
     if (e.currentHp == this.maxHp)
     {
         Console.WriteLine($"{this.name} is in perfect health!");
     }
     else if (e.currentHp >= this.maxHp / 2 && e.currentHp != this.maxHp)             // Between 1/2 and max
     {
         Console.WriteLine($"{this.name} is doing well!");
     }
     else if (e.currentHp >= this.maxHp / 4 && e.currentHp <= this.maxHp / 2)             // Between 1/4 and 1/2
     {
         Console.WriteLine($"{this.name} isn't doing too great...");
     }
     else if (e.currentHp > 0 && e.currentHp < this.maxHp / 4)             // Between 1/4 and 0
     {
         Console.WriteLine($"{this.name} needs help!");
     }
     else             // At 0
     {
         Console.WriteLine($"{this.name} is knocked out!");
     }
 }
Exemplo n.º 23
0
 // Method to check the status
 private void CheckStatus(object sender, CurrentHPArgs e)
 {
     if (e.currentHp == maxHp)
     {
         Console.WriteLine($"{this.name} is in perfect health!");
     }
     if (e.currentHp >= (maxHp / 2.0f) && e.currentHp < maxHp)
     {
         Console.WriteLine($"{this.name} is doing well!");
     }
     if (e.currentHp >= (maxHp / 4.0f) && e.currentHp < (maxHp / 2.0f))
     {
         Console.WriteLine($"{this.name} isn't doing too great...");
     }
     if (e.currentHp > 0f && e.currentHp < (maxHp / 4.9f))
     {
         Console.WriteLine($"{this.name} needs help!");
     }
     if (e.currentHp == 0f)
     {
         Console.WriteLine($"{this.name} is knocked out!");
     }
 }
Exemplo n.º 24
0
 private void CheckStatus(object sender, CurrentHPArgs e)
 {
     if (e.currentHp == maxHp)
     {
         this.status = name + " is in perfect health!";
     }
     else if (e.currentHp >= maxHp * 0.5f)
     {
         this.status = name + " is doing well!";
     }
     else if (e.currentHp >= maxHp * 0.25f)
     {
         this.status = name + " isn't doing too great...";
     }
     else if (e.currentHp > 0)
     {
         this.status = name + " needs help!";
     }
     else
     {
         this.status = name + " is knocked out!";
     }
     Console.WriteLine(status);
 }