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); } }
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); } }
public override void RunCommande(string[] input) { if (input.Length <= 1) { string hexColour = ColorUtility.ToHtmlStringRGB(Color.red); DevelopperConsole.AddStaticMessageToConsole($"<color=#{hexColour}>Put something after player : the name of a function </color>"); return; } switch (input[1]) { case "heal": HealCommand(input); break; case "dmg": DamageCommand(input); break; default: string hexColour = ColorUtility.ToHtmlStringRGB(Color.red); DevelopperConsole.AddStaticMessageToConsole($"<color=#{hexColour}>Player command not found : {input[1]} </color>"); break; } }
public override void RunCommande(string[] input) { if (input.Length <= 1) { string hexColour = ColorUtility.ToHtmlStringRGB(Color.red); DevelopperConsole.AddStaticMessageToConsole($"<color=#{hexColour}>Put something after help : the name of a function or 'all'</color>"); return; } StringBuilder builder = new StringBuilder(); Dictionary <string, ConsoleCommand> commands = DevelopperConsole.Commands; if (input[1].Equals("all")) { for (int i = 0; i < commands.Keys.Count; i++) { List <string> s = new List <string>(commands.Keys); ConsoleCommand c = commands[s[i]]; builder.Append(c.Name).Append(" : ").Append(c.Description); if (i != commands.Keys.Count - 1) { builder.AppendLine(); } } } else if (commands.ContainsKey(input[1])) { builder.Append(commands[input[1]].Help); } else { string hexColour = ColorUtility.ToHtmlStringRGB(Color.red); string s = $"<color=#{hexColour}>There are no function called : " + input[1] + "</color>"; builder.Append(s); } DevelopperConsole.AddStaticMessageToConsole(builder.ToString()); }