Пример #1
0
        public static void PromptSelection <T>(string showString, object[] list, PromptObjectResponse <T> response) where T : class
        {
            responseType        = typeof(T);
            userResponse        = response;
            selectableObjects   = list;
            awaitedUserResponse = UserResponseType.GameObject;
            var listed = new List <object>();

            listed.AddRange(list);
            var max = listed.Max((a) => { if (a is GameObject)
                                          {
                                              return((a as GameObject).Name.Length);
                                          }
                                          else
                                          {
                                              return(a.ToString().Length);
                                          } });
            var maxContainerName = listed.Max((a) =>
            {
                if (a is GameObject)
                {
                    if ((a as GameObject).container == null || (a as GameObject).container.Owner is Room)
                    {
                        return(0);
                    }
                    return((a as GameObject).container.Owner.Name.Length);
                }
                return(0);
            });

            if (list.Length == 1)
            {
                response.Invoke(list[0] as T, false);
                return;
            }
            else if (list.Length > 1)
            {
                GameScreen.NewLine();
                GameScreen.PrintLine(showString);
                uuid = System.Guid.NewGuid().ToString();
                for (int i = 0; i < list.Length; i++)
                {
                    if (list[i] is GameObject)
                    {
                        awaitedUserResponse = UserResponseType.GameObject;
                        GameObject j = list[i] as GameObject;
                        GameScreen.PrintLine($"[" + (i + 1) + $"] - <{Color.Cyan.ToInteger()},select " + j.ID + " uuid " + uuid + ">" + (j.Name.PadRight(max, ' ')) + "@");
                        if (j.container != null && !(j.container.Owner is Room))
                        {
                            GameScreen.Print(" - Attatched to " + (j.container.Owner.Name.PadRight(maxContainerName, ' ')));
                        }
                        if (j.ShortDescription != "")
                        {
                            GameScreen.Print(" - " + j.ShortDescription);
                        }
                    }
                    else
                    {
                        awaitedUserResponse = UserResponseType.Index;
                        string name = list[i].ToString();
                        GameScreen.PrintLine($"[" + (i + 1) + $"] - <{Color.Cyan.ToInteger()},index select " + i + " uuid " + uuid + ">" + (name.PadRight(max, ' ')) + "@");
                    }
                }
            }
        }
Пример #2
0
 public static void PromptYesNo(PromptYesNoResponse response)
 {
     awaitedUserResponse = UserResponseType.YesNo;
     userResponse        = response;
     GameScreen.PrintLine($"[<{Color.LightGreen.ToInteger()},answer yes>Yes@]  [<{Color.OrangeRed.ToInteger()},answer no>No@]");
 }