示例#1
0
        private void ImportSlot(int slotId)
        {
            System.Console.WriteLine(slotId);

            string text;

            try
            {
                var path = Path.Combine(Application.persistentDataPath, $"GameSettings-Slot{slotId}");
                text = File.ReadAllText(path);
            }
            catch
            {
                Cancel(FlashRed);
                return;
            }


            var splitText = text.Split("\n").ToList();

            while (splitText.Count > 0)
            {
                var name = splitText[0].Trim();
                splitText.RemoveAt(0);
                var option = AllOptions.FirstOrDefault(o => o.Name.Equals(name, StringComparison.Ordinal));
                if (option == null)
                {
                    try
                    {
                        splitText.RemoveAt(0);
                    }
                    catch
                    {
                    }

                    continue;
                }

                var value = splitText[0];
                splitText.RemoveAt(0);
                switch (option.Type)
                {
                case CustomOptionType.Number:
                    option.Set(float.Parse(value), false);
                    break;

                case CustomOptionType.Toggle:
                    option.Set(bool.Parse(value), false);
                    break;

                case CustomOptionType.String:
                    option.Set(int.Parse(value), false);
                    break;
                }
            }

            Rpc.SendRpc();

            Cancel(FlashGreen);
        }
示例#2
0
            public static void Postfix()
            {
                if (PlayerControl.AllPlayerControls.Count < 2 || !AmongUsClient.Instance || !PlayerControl.LocalPlayer || !AmongUsClient.Instance.AmHost)
                {
                    return;
                }

                Rpc.SendRpc();
            }
示例#3
0
        protected internal void Set(object value, bool SendRpc = true)
        {
            System.Console.WriteLine($"{Name} set to {value}");

            Value = value;

            if (Setting != null && AmongUsClient.Instance.AmHost && SendRpc)
            {
                Rpc.SendRpc(this);
            }

            try
            {
                if (Setting is ToggleOption toggle)
                {
                    var newValue = (bool)Value;
                    toggle.oldValue = newValue;
                    if (toggle.CheckMark != null)
                    {
                        toggle.CheckMark.enabled = newValue;
                    }
                }
                else if (Setting is NumberOption number)
                {
                    var newValue = (float)Value;

                    number.Value          = number.oldValue = newValue;
                    number.ValueText.text = ToString();
                }
                else if (Setting is StringOption str)
                {
                    var newValue = (int)Value;

                    str.Value          = str.oldValue = newValue;
                    str.ValueText.text = ToString();
                }
            }
            catch
            {
            }
        }