Example #1
0
    private string BuildDescription(Item item)
    {
        string description = "\n";

        description += RichText.InColour(RichText.InItalics(item.ShortDescription), Color.black) + "\n\n";
        description += RichText.InColour(item.LongDescription, Color.black) + "\n\n";

        return(description);
    }
Example #2
0
        private void SubmitCommand(string cmd)
        {
            cmd = cmd.Trim();

            LogText(RichText.InItalics(cmd));

            ExecuteCommand(cmd);
            LogHistory(cmd);

            historyIndex = -1;
        }
Example #3
0
    public string GetHelp(bool forPrint = false)
    {
        str.Clear();

        const string INDENT     = "  * ";
        const string SEP        = ", ";
        const string TYPE_START = " (";
        const string TYPE_END   = ") - ";
        const string WHITESPACE = "  ";

        str.Append(forPrint ? RichText.InBold(Name) : Name);
        str.Append(WHITESPACE);
        for (int i = 0; i < ParameterCount; i++)
        {
            var param = Parameters[i];
            str.Append(param.Name.Trim().ToLower());
            if (i != ParameterCount - 1)
            {
                str.Append(SEP);
            }
        }

        str.AppendLine();
        str.Append(Method.DeclaringType.FullName);
        str.Append('.');
        str.Append(Method.Name);

        str.AppendLine();
        str.Append(forPrint ? RichText.InItalics(Description) : Description);
        str.AppendLine();
        for (int i = 0; i < ParameterCount; i++)
        {
            str.Append(INDENT);
            var param = Parameters[i];
            str.Append(param.Name.ToLower().Trim());
            str.Append(TYPE_START);
            str.Append(param.Type.ToString().ToLower());
            str.Append(TYPE_END);
            string desc = param.Description.Trim();
            if (desc.EndsWith("."))
            {
                desc = desc.Remove(desc.Length - 1, 1);
            }
            str.Append(desc);
            if (i != ParameterCount - 1)
            {
                str.Append(SEP);
                str.AppendLine();
            }
        }

        return(str.ToString().TrimEnd());
    }
Example #4
0
 public void Refresh()
 {
     if (Item == null)
     {
         Title.text       = DefaultTitle;
         Description.text = DefaultDescription;
         Image.enabled    = false;
     }
     else
     {
         Image.enabled = true;
         Sprite spr = Atlas.GetSprite(Item.ItemIcon.name);
         Image.sprite      = spr == null ? Item.ItemIcon : spr;
         Title.text        = Item.Name;
         Description.text  = "";
         Description.text += RichText.InBold(RichText.InItalics(Item.ShortDescription)) + "\n";
         Description.text += Item.LongDescription;
     }
 }
    public void UpdateDetailedView()
    {
        if (Ship == null)
        {
            return;
        }

        if (IsEnemy)
        {
            // Do not display any details if this is an enemy ship.
            DetailsText.text = "Cannot see stats or details on this enemy ship...";
            return;
        }

        str.Clear();
        const string BOLD_START    = "<b>";
        const string BOLD_END      = "</b>";
        const string COLON         = " : ";
        const string HYPHEN        = " - ";
        const string RED           = "<b><color=#ff6666>";
        const string ORANGE        = "<b><color=#ffa500ff>";
        const string GREEN         = "<b><color=#70ff77>";
        const string END_COLOUR    = "</color></b>";
        string       DESTROYED     = RichText.InBold(RichText.InItalics("<b><color=#ff6666> [DESTROYED]</color></b>"));
        string       DESTROYED_ESS = RichText.InBold(RichText.InItalics("<b><color=#ff6666> [DESTROYED] [!]</color></b>"));

        if (Ship.Damage.WaterOntake > 0f)
        {
            str.Append(RED);
            string water = ((Ship.Damage.WaterOntake / Ship.Damage.MaxWater) * 100f).ToString("n1");
            str.Append("--> Taking On Water! ");
            str.Append(water);
            str.Append("% /s");
            str.Append(END_COLOUR);
            str.Append('\n');
        }

        if (Ship.Locomotion.GetAgilityMultiplier() != 1f)
        {
            str.Append("Max throttle at ");
            if (Ship.Locomotion.GetAgilityMultiplier() > 1f)
            {
                str.Append("<b><color=#70ff77>");
            }
            else
            {
                str.Append("<b><color=#ff6666>");
            }
            str.Append((Ship.Locomotion.GetAgilityMultiplier() * 100f).ToString("n1"));
            str.Append('%');
            str.Append("</color></b>");
            str.Append('\n');
        }

        str.Append('\n');
        foreach (var part in Ship.DamageModel.Parts)
        {
            str.Append(BOLD_START);
            str.Append(part.Name.Trim());
            str.Append(BOLD_END);
            str.Append(COLON);
            str.Append(Mathf.Ceil(part.CurrentHealth));
            str.Append('/');
            str.Append(Mathf.Ceil(part.MaxHealth));
            str.Append(HYPHEN);
            float  p = part.HealthPercentage;
            string c = null;
            if (p >= 0.7f)
            {
                c = GREEN;
            }
            else if (p >= 0.4f)
            {
                c = ORANGE;
            }
            else
            {
                c = RED;
            }
            str.Append(c);
            str.Append(Mathf.RoundToInt(p * 100f));
            str.Append('%');
            str.Append(END_COLOUR);
            if (part.IsDestroyed)
            {
                if (part.IsEssential)
                {
                    str.Append(DESTROYED_ESS);
                }
                else
                {
                    str.Append(DESTROYED);
                }
            }
            str.Append('\n');
        }

        DetailsText.text = str.ToString().Trim();
    }