private void DamageCommand(string[] input) { Character.HealthManager playerHealthMgr = GameObject.FindGameObjectWithTag("Player").GetComponent <Character.HealthManager>(); Combat.Attack attack = null; bool canAttack = true; if (input.Length <= 2) { attack = new Combat.Attack(1, false, null); } else { int value = 0; try { value = int.Parse(input[2]); } catch { canAttack = false; string hexColour = ColorUtility.ToHtmlStringRGB(Color.red); DevelopperConsole.AddStaticMessageToConsole($"<color=#{hexColour}>Must put a number or nothing after dmg : {input[2]} </color>"); } if (canAttack) { attack = new Combat.Attack(value, false, null); } } if (canAttack) { playerHealthMgr.OnAttack(null, attack); } }
private void HealCommand(string[] input) { Character.HealthManager playerHealthMgr = GameObject.FindGameObjectWithTag("Player").GetComponent <Character.HealthManager>(); bool canHeal = true; int value = 0; if (input.Length <= 2) { value = playerHealthMgr.MaxHealth; } else { try { value = int.Parse(input[2]); } catch { canHeal = false; string hexColour = ColorUtility.ToHtmlStringRGB(Color.red); DevelopperConsole.AddStaticMessageToConsole($"<color=#{hexColour}>Must put a number or nothing after heal : {input[2]} </color>"); } } if (canHeal) { playerHealthMgr.AddCurrentHealth(value); } }