Ejemplo n.º 1
0
        public void Save()
        {
            string path = BotDirectory.BotPath(name);

            #if UNITY_EDITOR && !BUILD_MODE && !BUILD_MODE
            BotData existingAsset = AssetDatabase.LoadAssetAtPath <BotData>(path);
            if (existingAsset == null)
            {
                AssetDatabase.CreateAsset(this, path);
            }
            else
            {
                existingAsset.builtInProgram    = builtInProgram;
                existingAsset.customProgramName = customProgramName;
                existingAsset.weaponData        = weaponData;
            }
            #else
            StreamWriter file = File.CreateText(path);
            file.WriteLine(customProgramName);
            if (weaponData == null)
            {
                file.WriteLine();
            }
            else
            {
                file.WriteLine(weaponData.name);
            }
            file.Close();
            #endif
        }
Ejemplo n.º 2
0
        public void DeleteOnDisk()
        {
            string path = BotDirectory.BotPath(name);

            #if UNITY_EDITOR && !BUILD_MODE
            AssetDatabase.DeleteAsset(path);
            #else
            File.Delete(path);
            #endif
        }
Ejemplo n.º 3
0
        public void Rename(string newName)
        {
            string fromPath = BotDirectory.BotPath(name);
            string toPath   = BotDirectory.BotPath(newName);

            #if UNITY_EDITOR && !BUILD_MODE
            AssetDatabase.RenameAsset(fromPath, newName);
            #else
            File.Move(fromPath, toPath);
            #endif
            name = newName;
        }
Ejemplo n.º 4
0
 public BotData GetBotData(int index)
 {
     if (builtInBotDatas != null)
     {
         return(builtInBotDatas[index]);
     }
     else if (customBotNames != null && customBotNames[index] != "")
     {
         return(BotData.Load(BotDirectory.BotPath(customBotNames[index])));
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 5
0
 public void SetBotName(int index, string name)
 {
     #if UNITY_EDITOR && !BUILD_MODE
     if (name == null)
     {
         builtInBotDatas[index] = null;
     }
     else
     {
         string path = BotDirectory.BotPath(name);
         builtInBotDatas[index] = AssetDatabase.LoadAssetAtPath <BotData>(path);
     }
     #else
     customBotNames[index] = name;
     #endif
     Save();
     OnBotChanged?.Invoke(index);
 }