Ejemplo n.º 1
0
 public static void PrintSceneList()
 {
     SteamPunkConsole.WriteLine("Scene names\n==================");
     for (int i = 0; i < SceneNames.Count; i++)
     {
         SteamPunkConsole.WriteLine(SceneNames[i]);
     }
 }
Ejemplo n.º 2
0
        public static void Load()
        {
            //get saved text from file with key, default null if no file exists
            string text = SaveLoad.LoadText(SAVE_KEY);

            if (text == null)
            {
                return;
            }

            //split text up into lines
            string[] lines = text.Split('\n');

            //iterate over lines
            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];
                //split line up into separate strings
                string[] entry = line.Split('|');
                //ignore line if not correct format
                if (entry.Length != 3)
                {
                    continue;
                }

                //get information about the data entry
                string parameterName     = entry[0].ToLower();
                string parameterTypeName = entry[1];
                Type   parameterType     = Type.GetType(parameterTypeName);
                string valueString       = entry[2];

                //check and make sure a parameter with that name exists
                StatTracker stat = GetTracker(parameterName);
                if (stat == null)
                {
                    SteamPunkConsole.WriteLine($"Error on line {i + 1} \"{line}\": no parameter with name \"{parameterName}\" found.");
                    continue;
                }

                //check and make sure field type matches given type
                if (stat.FieldType != parameterType)
                {
                    SteamPunkConsole.WriteLine($"Error on line {i + 1} \"{line}\": parameter type \"{parameterTypeName}\" does not match the expected type \"{stat.FieldType}\".");
                    continue;
                }

                //set value of matching field
                bool parsedSuccessfully = stat.SetValue(valueString);

                if (!parsedSuccessfully)
                {
                    SteamPunkConsole.WriteLine($"Error on line {i + 1} \"{line}\": value \"{valueString}\" could not be parsed as a \"{parameterType}\".");
                    continue;
                }
            }

            SteamPunkConsole.WriteLine("Load Successful");
        }
Ejemplo n.º 3
0
 public static void StatList()
 {
     StatTracker[] stats = Resources.LoadAll <StatTracker>("StatTrackers");
     SteamPunkConsole.WriteLine($"List of available stat names");
     SteamPunkConsole.WriteLine($"============================");
     for (int i = 0; i < stats.Length; i++)
     {
         SteamPunkConsole.WriteLine(stats[i].name.ToLower().Replace(' ', '_'));
     }
 }
Ejemplo n.º 4
0
        private static StatTracker GetTracker(string parameterName)
        {
            StatTracker stat = Resources.Load <StatTracker>($"StatTrackers/{parameterName.ToLower().Replace('_', ' ')}");

            if (stat == null)
            {
                SteamPunkConsole.WriteLine($"No stat with name \"{parameterName}\" found. Use statList to get a list of available stat names.");
            }

            return(stat);
        }
Ejemplo n.º 5
0
    private void Awake()
    {
        if (instance != this && instance != null)
        {
            Destroy(gameObject);
            return;
        }
        instance = this;

        LoadPrefabs();

        SteamPunkConsole.GetCommandsFromType(GetType());
    }
Ejemplo n.º 6
0
        public override bool SetValue(string valueString)
        {
            bool successful = int.TryParse(valueString, out int intVal);

            if (!successful)
            {
                SteamPunkConsole.WriteLine($"value \"{valueString}\" could not be parsed as a \"{FieldType}\".");
                return(false);
            }

            SetValue(intVal);
            return(true);
        }
Ejemplo n.º 7
0
    protected override void Awake()
    {
        base.Awake();
        itemUseCooldownTimerID = gameObject.GetInstanceID() + "Item Use Cooldown Timer";
        TimerTracker.AddTimer(itemUseCooldownTimerID, 0f, null, null);
        shieldComponent?.SetToUpperLimit();
        if (!inventories.Contains(DefaultInventory))
        {
            inventories.Add(DefaultInventory);
        }

        SteamPunkConsole.GetCommandsFromType(GetType());
    }
Ejemplo n.º 8
0
        public static void ResetAllStats()
        {
            StatTracker[] stats = Resources.LoadAll <StatTracker>("StatTrackers");
            for (int i = 0; i < stats.Length; i++)
            {
                stats[i].ResetToDefault();
            }

            if (!Application.isEditor)
            {
                SteamPunkConsole.WriteLine("Stats have been reset to default values.");
                SaveAll();
            }
        }
Ejemplo n.º 9
0
        public static void SetStat(string statName, string value)
        {
            StatTracker stat = GetTracker(statName);

            if (stat == null)
            {
                return;
            }
            bool successful = stat.SetValue(value);

            if (successful)
            {
                SteamPunkConsole.WriteLine($"{stat.name} set to {value}.");
            }
        }
Ejemplo n.º 10
0
        public static void SaveAll()
        {
            StatTracker[] stats  = Resources.LoadAll <StatTracker>("StatTrackers");
            StringBuilder toSave = new StringBuilder();

            for (int i = 0; i < stats.Length; i++)
            {
                StatTracker stat  = stats[i];
                string      entry = $"{stat.name.ToLower()}|{stat.FieldType}|{stat.ValueString}";
                SteamPunkConsole.WriteLine(entry);
                toSave.AppendLine(entry);
            }

            string result = toSave.ToString();

            SaveLoad.SaveText(SAVE_KEY, result);
            SteamPunkConsole.WriteLine("Save Successful");
        }