Exemplo n.º 1
0
    void LaunchProjectiles(LaunchConfig config)
    {
        player.GetComponent <CPMPlayer>().playerVelocity -= transform.forward * (float)(config.kickback * kickbackScale);

        Bullet[] bullets = new Bullet[config.numberOfProjectiles];
        bullets[0] = config.bullet;
        for (int i = 1; i < bullets.Length; i++)
        {
            bullets[i] = Instantiate(config.bullet);
        }

        foreach (var bullet in bullets)
        {
            var rb = bullet.GetComponent <Rigidbody>();

            var randomDir =
                ((2 * Random.value - 1) * firePositon.up +
                 (2 * Random.value - 1) * firePositon.right).normalized;
            var perturbation = Random.value * (1 - config.accuracy);
            var error        = randomDir * perturbation;
            var dir          = (firePositon.forward + error).normalized;

            rb.AddForce(dir * default_gun_strength);
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// 根据游戏核心来启动游戏(异步)
        /// <para>
        /// 静态方法
        /// </para>
        /// </summary>
        /// <param name="core">游戏核心</param>
        /// <param name="config">启动配置信息</param>
        /// <returns></returns>
        public static async Task <LaunchResult> LaunchAsync(GameCore core, LaunchConfig config)
        {
            var args = new ArgumentsBuilder(core, config).BulidArguments();

            if (string.IsNullOrEmpty(config.NativesFolder))
            {
                config.NativesFolder = $"{PathHelper.GetVersionFolder(core.Root, core.Id)}{PathHelper.X}natives";
            }

            var process = new ProcessContainer(new ProcessStartInfo
            {
                WorkingDirectory = Directory.Exists(config.WorkingFolder) ? config.WorkingFolder : core.Root,
                Arguments        = args,
                FileName         = config.JavaPath,
            });

            process.Start();
            await process.Process.WaitForExitAsync();

            return(new LaunchResult
            {
                Args = args,
                Errors = process.ErrorData,
                Logs = process.OutputData,
                IsCrashed = process.Process.ExitCode != 0
            });
        }
Exemplo n.º 3
0
        public override void Launch(LaunchConfig config)
        {
            switch (_cmdName.Trim())
            {
            case "RegisterExplorerContextMenu":
            {
                if (ShellIntegration.RegisterContextMenu())
                {
                    ErrorLog.Inst.ShowInfo("Explorer Context Menu Registration Completed.");
                }
            }
            break;

            case "WriteConfigRegistryValues":
            {
                var launchTool = Editors.EditorFactory.Inst.GetEditor(RuntimeInfo.Generic);

                launchTool.UpdateRegistry(Configs_Root.Inst.Configs);

                ErrorLog.Inst.ShowInfo("Environment Registry Integration completed");
            }
            break;

            case "UpdatePythonScriptFolder":
            {
                var pythonEnv = new PythonEnvironment();
                pythonEnv.UpdateScripts(Configs_Root.Inst);

                ErrorLog.Inst.ShowInfo("Updating Python Environment Scripts folder is completed");
            }
            break;
            }
        }
Exemplo n.º 4
0
        public static void LaunchVessel(string craftDirectory, string name, string launchSite, bool recover = true)
        {
            var config = new LaunchConfig(craftDirectory, name, launchSite, recover);

            config.RunPreFlightChecks();
            throw new YieldException(new ParameterizedContinuationVoid <LaunchConfig> (WaitForVesselPreFlightChecks, config));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Wait until pre-flight checks for new vessel are complete.
        /// </summary>
        /// <param name="config">Config.</param>
        static void WaitForVesselPreFlightChecks(LaunchConfig config)
        {
            if (config.error != null)
            {
                throw new InvalidOperationException(config.error);
            }
            if (!config.preFlightChecksComplete)
            {
                throw new YieldException(new ParameterizedContinuationVoid <LaunchConfig>(WaitForVesselPreFlightChecks, config));
            }
            // Check launch site clear
            var vesselsToRecover = ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, config.LaunchSite);

            if (vesselsToRecover.Any())
            {
                // Recover existing vessels if the launch site is not clear
                if (!config.Recover)
                {
                    throw new InvalidOperationException("Launch site not clear");
                }
                foreach (var vessel in vesselsToRecover)
                {
                    ShipConstruction.RecoverVesselFromFlight(vessel, HighLogic.CurrentGame.flightState, true);
                }
            }
            // Do the actual launch - passed pre-flight checks, and launch site is clear.
            FlightDriver.StartWithNewLaunch(config.Path, EditorLogic.FlagURL, config.LaunchSite, config.manifest);
            throw new YieldException(new ParameterizedContinuationVoid <int>(WaitForVesselSwitch, 0));
        }
Exemplo n.º 6
0
        public override void Launch(LaunchConfig config)
        {
            if (RuntimeInfo.Inst.IsOpenFolder)
            {
                DynamicArgument = "\"" + RuntimeInfo.Inst.ToolLaunchDir + "\"";
            }

            base.Launch(config);
        }
Exemplo n.º 7
0
        private LaunchConfig GetLaunchConfig()
        {
            var jsonString   = File.ReadAllText(launchConfigFilePath, Encoding.UTF8);
            var launchConfig = new LaunchConfig
            {
                ConfigJson = jsonString
            };

            return(launchConfig);
        }
Exemplo n.º 8
0
        public ArgumentsBuilder(GameCore core, LaunchConfig config)
        {
            if (core == null || config == null)
            {
                throw new ArgumentNullException(nameof(core));
            }

            this.GameCore     = core;
            this.LaunchConfig = config;
        }
Exemplo n.º 9
0
        public override void Launch(LaunchConfig config)
        {
            if (RuntimeInfo.Inst.IsOpenFolder)
            {
                foreach (var item in Directory.GetFiles(config.WorkingDir, "*.ino"))
                {
                    DynamicArgument = "\"" + item + "\"";
                    break;
                }
            }

            base.Launch(config);
        }
Exemplo n.º 10
0
        public override void Launch(LaunchConfig config)
        {
            string toolPath;

            var foundConfig = config.Configs.FirstOrDefault((item) => item.Type == ConfigType.windbg);

            if (foundConfig == null)
            {
                toolPath = RuntimeInfo.Inst.GetToolPath(ToolName);

                if (!File.Exists(toolPath))
                {
                    ErrorLog.Inst.ShowError("Unable to find Windbg at Path {0}", toolPath);
                    return;
                }
            }
            else
            {
                //means use local path
                if (Tool.Name.Contains("-32Bit"))
                {
                    toolPath = string.Format("{0}\\x86\\windbg.exe", ResolveValue.Inst.ResolveFullPath(foundConfig.InstallPath));
                }
                else
                {
                    toolPath = string.Format("{0}\\x64\\windbg.exe", ResolveValue.Inst.ResolveFullPath(foundConfig.InstallPath));
                }

                if (foundConfig.Envs == null)
                {
                    foundConfig.Envs = new List <EnviromentVariable>();
                }

                EnviromentVariable pathVar = new EnviromentVariable()
                {
                    Name = "PATH", Value = Path.GetDirectoryName(toolPath)
                };
                foundConfig.Envs.Add(pathVar);
                //var foundVar = foundConfig.Envs.FirstOrDefault((item) => string.Compare(item.Name, "Scripts", true) == 0);

                //if(foundVar != null)
                //{
                //    string scriptFolder = ResolveValue.Inst.ResolveFullPath(foundVar.Value);
                //    DynamicArgument = string.Format("-c\".cmdtree {0}\\cmdtree_default.txt\"", scriptFolder);
                //}
            }

            DynamicEditor = toolPath;

            base.Launch(config);
        }
Exemplo n.º 11
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (ProcessContainer != null)
                {
                    this.ProcessContainer.Dispose();
                    this.ProcessContainer = null;
                }

                this.LaunchConfig = null;
                this.CoreLocator  = null;
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Load launch config file
 /// </summary>
 protected void LoadLaunchConfig()
 {
     try {               // FileStream to read the XML document.
         byte[] configFileRawData = GetConfigFileBinaryData();
         if (configFileRawData != null)
         {
             XmlSerializer serializer = new XmlSerializer(typeof(LaunchConfig));
             launchConfig = (LaunchConfig)serializer.Deserialize(new MemoryStream(configFileRawData));
         }
     } catch (Exception e) {
         SystemLogger.Log(SystemLogger.Module.CORE, "Error when loading launch configuration", e);
         launchConfig = new LaunchConfig();                 // reset launch config mapping when the services could not be loaded for any reason
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Wait until vessels on the launchpad have been recovered, then launch new vessel.
        /// </summary>
        static void WaitForVesselRecovery(LaunchConfig config)
        {
            if (config.error != null)
            {
                config.RemoveRecoveryEventHandlers();
                throw new InvalidOperationException(config.error);
            }
            if (config.vesselsToRecover != config.vesselsRecovered)
            {
                throw new YieldException(new ParameterizedContinuationVoid <LaunchConfig> (WaitForVesselRecovery, config));
            }
            config.RemoveRecoveryEventHandlers();

            FlightDriver.StartWithNewLaunch(config.Path, EditorLogic.FlagURL, config.LaunchSite, config.manifest);
            throw new YieldException(new ParameterizedContinuationVoid <int> (WaitForVesselSwitch, 0));
        }
Exemplo n.º 14
0
        public override void Launch(LaunchConfig config)
        {
            if (RuntimeInfo.Inst.IsOpenFolder)
            {
                string pyFileName = "";

                foreach (var item in Directory.GetFiles(config.WorkingDir, "*.py"))
                {
                    pyFileName = item;
                    break;
                }
                DynamicArgument = "\"" + pyFileName + "\"";
            }

            base.Launch(config);
        }
Exemplo n.º 15
0
        /// <summary>
        /// <filename>	Specifies the project *.cbp filename or workspace *.workspace filename.
        /// For instance <filename> may be c:\some\where\a\project.cbp. Place this argument at end of command line, just before output redirection if any.
        /// --file=<filename>[:line]	Open file in Code::Blocks and optionally jump to a specific line.
        /// </summary>
        /// <param name="config"></param>
        public override void Launch(LaunchConfig config)
        {
            if (RuntimeInfo.Inst.IsOpenFolder)
            {
                string openfile = "";

                foreach (var item in Directory.GetFiles(config.WorkingDir, "*.cbp"))
                {
                    openfile = item;
                    break;
                }

                if (string.IsNullOrWhiteSpace(openfile))
                {
                    foreach (var item in Directory.GetFiles(config.WorkingDir, "*.workspace"))
                    {
                        openfile = item;
                        break;
                    }
                }

                if (string.IsNullOrWhiteSpace(openfile))
                {
                    foreach (var item in Directory.GetFiles(config.WorkingDir, "*.c*"))
                    {
                        DynamicArgument = "--file=\"" + item + "\"";
                        break;
                    }
                }
                else
                {
                    DynamicArgument = "\"" + openfile + "\"";
                }
            }

            string userData = string.Format(@"{0}\userdata", Tool.BaseDir);

            if (Directory.Exists(userData))
            {
                string currentDynamicArg = DynamicArgument;

                DynamicArgument = string.Format("{0}{1}--user-data-dir=\"{2}\"", currentDynamicArg, string.IsNullOrWhiteSpace(currentDynamicArg) ? "" : " ", userData);
            }

            base.Launch(config);
        }
Exemplo n.º 16
0
        public override void Launch(LaunchConfig config)
        {
            if (RuntimeInfo.Inst.IsOpenFolder && RuntimeInfo.Inst.VSVersion >= 15)
            {
                //UpdateJsonFiles(config);
                string dynamicArgs = "\"" + RuntimeInfo.Inst.ToolLaunchDir + "\"";
                var    activeEnv   = config.Configs.FirstOrDefault((item) => item.Type == ConfigType.gcc_linux || item.Type == ConfigType.gcc);
                if (activeEnv != null)
                {
                    dynamicArgs += " /useenv";
                }

                DynamicArgument = dynamicArgs;
            }

            base.Launch(config);
        }
        protected override bool LaunchCustom(LaunchConfig config)
        {
            string openfileName = "";

            if (Directory.Exists(RuntimeInfo.Inst.OpenFolder))
            {
                if (string.IsNullOrWhiteSpace(openfileName))
                {
                    foreach (var item in Directory.GetFiles(config.WorkingDir, "*.workspace"))
                    {
                        openfileName = item;
                        break;
                    }
                }

                if (string.IsNullOrWhiteSpace(openfileName))
                {
                    foreach (var item in Directory.GetFiles(config.WorkingDir, "*.c*"))
                    {
                        openfileName = "\"" + item + "\"";
                        break;
                    }
                }
            }

            string toolDir     = string.Format("--basedir=\"{0}\"", Path.GetDirectoryName(Tool.Path));
            string userDataDir = string.Format(@"{0}\userdata", Tool.ToolPath);

            if (Directory.Exists(userDataDir))
            {
                string currentDynamicArg = toolDir;
                DynamicArgument = string.Format("{0}{1}--datadir=\"{2}\"", toolDir, string.IsNullOrWhiteSpace(toolDir) ? "" : " ", userDataDir);
            }
            else
            {
                DynamicArgument = toolDir;
            }

            if (!string.IsNullOrWhiteSpace(openfileName))
            {
                string currentDynamicArg = DynamicArgument;
                DynamicArgument = string.Format("{0} {1}", currentDynamicArg, openfileName);
            }

            return(true);
        }
Exemplo n.º 18
0
 /// <summary>
 /// Load launch config file
 /// </summary>
 protected void LoadLaunchConfig()
 {
     launchConfig = new LaunchConfig(); // reset launch config mapping when the services could not be loaded for any reason
     try
     {   // FileStream to read the XML document.
         byte[] configFileRawData = GetConfigFileBinaryData();
         if (configFileRawData != null && configFileRawData.Length > 0)
         {
             XmlSerializer serializer = new XmlSerializer(typeof(LaunchConfig));
             launchConfig = (LaunchConfig)serializer.Deserialize(new MemoryStream(configFileRawData));
         }
     }
     catch (Exception e)
     {
         SystemLogger.Log(SystemLogger.Module.CORE, "Error when loading launch configuration", e);
     }
 }
Exemplo n.º 19
0
        public virtual void CleanConfig(LaunchConfig config, Config.RegKey regConfig)
        {
            //if (!string.IsNullOrWhiteSpace(regConfig.Key))
            //{
            //    string regKey = regConfig.Key;
            //    WriteKeyEmpty(regKey, regConfig);

            //    if (Environment.Is64BitProcess)
            //    {
            //        int startIndex = regKey.IndexOf(@"HKEY_LOCAL_MACHINE\SOFTWARE\");
            //        if (startIndex == 0)
            //        {
            //            string regWowKey = regKey.Replace(@"HKEY_LOCAL_MACHINE\SOFTWARE\", @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\");
            //            WriteKeyEmpty(regWowKey, regConfig);
            //        }
            //    }
            //}
        }
Exemplo n.º 20
0
        public override void Launch(LaunchConfig config)
        {
            var foundEnv = config.Configs.FirstOrDefault((item) => item.Type == ConfigType.python);

            if (foundEnv != null)
            {
                string pythonPath = string.Format("{0}\\pythonw.exe", ResolveValue.Inst.ResolveFullPath(foundEnv.InstallPath));
                string pythonidle = string.Format("\"{0}\\Lib\\idlelib\\idle.py\"", ResolveValue.Inst.ResolveFullPath(foundEnv.InstallPath));

                DynamicArgument = pythonidle;
                DynamicEditor   = pythonPath;

                base.Launch(config);
            }
            else
            {
                ErrorLog.Inst.ShowError("Unable to find the python environment");
            }
        }
        private LaunchConfig BuildLaunchConfig()
        {
            LaunchConfig config = new LaunchConfig();

            config.WorkingDir = RuntimeInfo.Inst.OpenFolder;
            config.Configs    = new List <Config.Config>();

            for (int index = 0; index < _configListBox.Items.Count; index++)
            {
                if (_configListBox.GetItemChecked(index))
                {
                    string envName = _configListBox.Items[index] as string;
                    if (envName != null)
                    {
                        var item = Configs_Root.Inst.Configs.FirstOrDefault((a) => string.Compare(a.Name, envName, true) == 0);
                        if (item != null)
                        {
                            config.Configs.Add(item);
                        }
                    }
                }
            }

            if (config.Configs.Count == 0)
            {
                if (_configListBox.SelectedItem != null)
                {
                    string envName = _configListBox.SelectedItem as string;
                    if (envName != null)
                    {
                        var item = Configs_Root.Inst.Configs.FirstOrDefault((a) => string.Compare(a.Name, envName, true) == 0);
                        if (item != null)
                        {
                            config.Configs.Add(item);
                        }
                    }
                }
            }

            return(config);
        }
Exemplo n.º 22
0
        protected void AddConfig(LaunchConfig config)
        {
            comboFamily.SetExpanded(false);

            if (maxNewConfigs <= newConfigs.Count())
            {
                return;
            }

            isAddingConfig = true;

            // Add config and all editing controls
            var newRemoveButton = new GUIButton("Remove", DoRemoveLaunchConfig, new GUILayoutOption[] { GUILayout.Width(80) });
            var newTextPayload  = new GUITextBox("Max payload: ", "", "t   to ", 50, 180);
            var newDestCombo    = new klvGUI.DropDown(new Vector2(200, 130), KLVCore.GetAllDestinationName(), newRemoveButton);

            if (config != null)
            {
                newDestCombo.SetSelection(config.Target.Name);
            }

            newDestCombo.SetExpandAction(DoExpandCombo);
            RegisterCombos(newDestCombo);

            if (config != null)
            {
                newTextPayload.SetText(config.PayloadMass.ToString("0.###"));
                newDestCombo.SetSelection(config.Target == null ? "" : config.Target.Name);
                newConfigs.Add(config);
            }
            else
            {
                newConfigs.Add(new LaunchConfig());
            }

            newTextPayload.SetEditing(true);

            buttonAllRemoveConfigs.Add(newRemoveButton);
            comboAllDestinations.Add(newDestCombo);
            textAllPayloads.Add(newTextPayload);
        }
Exemplo n.º 23
0
        private LaunchConfig BuildLaunchConfig()
        {
            LaunchConfig config = new LaunchConfig();

            config.WorkingDir = string.IsNullOrWhiteSpace(RuntimeInfo.Inst.ToolLaunchDir) || (!Directory.Exists(RuntimeInfo.Inst.ToolLaunchDir)) ? Configs_Root.Inst.HomePath : RuntimeInfo.Inst.ToolLaunchDir;
            config.Configs    = new List <Config.Config>();

            for (int index = 0; index < envList.Items.Count; index++)
            {
                if (envList.GetItemChecked(index))
                {
                    string envName = envList.Items[index] as string;
                    if (envName != null)
                    {
                        var item = Configs_Root.Inst.Configs.FirstOrDefault((a) => string.Compare(a.Name, envName, true) == 0);
                        if (item != null)
                        {
                            config.Configs.Add(item);
                        }
                    }
                }
            }

            if (config.Configs.Count == 0)
            {
                if (envList.SelectedItem != null)
                {
                    string envName = envList.SelectedItem as string;
                    if (envName != null)
                    {
                        var item = Configs_Root.Inst.Configs.FirstOrDefault((a) => string.Compare(a.Name, envName, true) == 0);
                        if (item != null)
                        {
                            config.Configs.Add(item);
                        }
                    }
                }
            }

            return(config);
        }
Exemplo n.º 24
0
 /// <summary>
 /// Wait until pre-flight checks for new vessel are complete.
 /// </summary>
 /// <param name="config">Config.</param>
 static void WaitForVesselPreFlightComplete(LaunchConfig config)
 {
     // Recover existing vessels if the launch site is not clear
     if (config.Recover)
     {
         var launchSiteClear = Compatibility.NewLaunchSiteClear(config.LaunchSite, HighLogic.CurrentGame);
         if (!launchSiteClear.Test())
         {
             var vesselsToRecover = launchSiteClear.GetObstructingVessels();
             config.vesselsToRecover = vesselsToRecover.Count;
             foreach (var vessel in vesselsToRecover)
             {
                 config.AddRecoveryEventHandler(vessel);
             }
             foreach (var protoVessel in vesselsToRecover)
             {
                 GameEvents.OnVesselRecoveryRequested.Fire(protoVessel.vesselRef);
             }
         }
     }
     WaitForVesselRecovery(config);
 }
Exemplo n.º 25
0
        protected override bool LaunchCustom(LaunchConfig config)
        {
            switch (Tool.Path.Trim())
            {
            case "RegisterExplorerContextMenu":
            {
                if (ShellIntegration.RegisterContextMenu())
                {
                    ErrorLog.Inst.ShowInfo("Explorer Context Menu Registration Completed.");
                }
            }
            break;

            case "WriteConfigRegistryValues":
            {
                UpdateConfigRegistry(Configs_Root.Inst.Configs);

                ErrorLog.Inst.ShowInfo("Environment Registry Integration completed");
            }
            break;

            case "UpdatePythonScriptFolder":
            {
                UpdatePythonScripts(Configs_Root.Inst);

                ErrorLog.Inst.ShowInfo("Updating Python Environment Scripts folder is completed");
            }
            break;

            default:
            {
                ErrorLog.Inst.ShowError("Unable to find known command: {0}", Tool.Path);
            }
            break;
            }

            return(false);
        }
Exemplo n.º 26
0
        private void StartDeployment(string deploymentName, int retries = 0)
        {
            var launchConfig = new LaunchConfig
            {
                ConfigJson = Utils.GetFileContent(WorkerType, launchConfigFile),
            };

            var snapshotId = DeploymentModifier.UploadSnapshot(workerConfig.ProjectName, deploymentName);
            var template   = new DeploymentTemplate
            {
                AssemblyId     = sessionConfig.AssemblyName,
                DeploymentName = deploymentName,
                LaunchConfig   = launchConfig,
                ProjectName    = workerConfig.ProjectName,
                SnapshotId     = snapshotId,
                RegionCode     = sessionConfig.RegionCode,
            };

            Log.Print(LogLevel.Info, $"Creating deployment {deploymentName}.", serviceConnection);
            var deploymentOperation = DeploymentModifier.CreateDeployment(template).PollUntilCompleted();

            if (deploymentOperation.IsCompleted)
            {
                Log.Print(LogLevel.Info, $"Successfully created deployment {deploymentName}.", serviceConnection);
                ConnectToDeployment(deploymentOperation.Result);
            }
            else if (deploymentOperation.IsFaulted)
            {
                Log.Print(LogLevel.Error, $"Failed to create deployment {deploymentName} with exception {deploymentOperation.Exception}. " +
                          $"Trying again.", serviceConnection);

                if (retries < Utils.MaxRetries)
                {
                    Task.Run(() => StartDeployment(deploymentName, retries + 1));
                }
            }
        }
Exemplo n.º 27
0
 /// <summary>
 /// 用游戏目录和启动配置信息来初始化启动器类
 /// </summary>
 /// <param name="coreLocator">.minecraft目录路径</param>
 /// <param name="config">启动配置信息</param>
 public MinecraftLauncher(ICoreLocator coreLocator, LaunchConfig config)
 {
     this.CoreLocator  = coreLocator;
     this.LaunchConfig = config;
 }
Exemplo n.º 28
0
 /// <summary>
 /// 根据游戏核心来启动游戏
 /// <para>
 /// 静态方法
 /// </para>
 /// </summary>
 /// <param name="core">游戏核心</param>
 /// <param name="config">启动配置信息</param>
 /// <returns></returns>
 public static LaunchResult Launch(GameCore core, LaunchConfig config) => LaunchAsync(core, config).GetAwaiter().GetResult();
Exemplo n.º 29
0
        private void UpdateJsonFiles(LaunchConfig config)
        {
            var activeEnv = config.Configs.FirstOrDefault((item) => item.Type == ConfigType.gcc_linux || item.Type == ConfigType.gcc);

            if (RuntimeInfo.Inst.IsOpenFolder && activeEnv != null)
            {
                //.vs dir check
                string vsCodeDir = string.Format(@"{0}\.vs\", RuntimeInfo.Inst.ToolLaunchDir);
                if (!Directory.Exists(vsCodeDir))
                {
                    Directory.CreateDirectory(vsCodeDir);
                }

                if (activeEnv.Type == ConfigType.gcc || activeEnv.Type == ConfigType.gcc_linux)
                {
                    //c_cpp_properties.json
                    string fileName = string.Format(@"{0}\CppProperties.json", RuntimeInfo.Inst.ToolLaunchDir);
                    if (!File.Exists(fileName))
                    {
                        string goldFile = string.Format(@"{0}\OpenFolder_Resource\vs\CppProperties.json", RuntimeInfo.Inst.LaunchEnvExeDir);
                        using (TextWriter writer = new StreamWriter(fileName))
                        {
                            using (TextReader reader = new StreamReader(goldFile))
                            {
                                writer.Write(reader.ReadToEnd());
                            }
                        }
                    }

                    //tasks.json
                    fileName = string.Format(@"{0}\.vs\tasks.vs.json", RuntimeInfo.Inst.ToolLaunchDir);

                    if (!File.Exists(fileName))
                    {
                        string goldFile = string.Format(@"{0}\OpenFolder_Resource\vs\tasks.vs.json", RuntimeInfo.Inst.LaunchEnvExeDir);
                        using (TextWriter writer = new StreamWriter(fileName))
                        {
                            using (TextReader reader = new StreamReader(goldFile))
                            {
                                writer.Write(reader.ReadToEnd());
                            }
                        }
                    }

                    //launch.json
                    fileName = string.Format(@"{0}\.vs\launch.vs.json", RuntimeInfo.Inst.ToolLaunchDir);

                    if (!File.Exists(fileName))
                    {
                        string goldFile = string.Format(@"{0}\OpenFolder_Resource\vs\launch.vs.json", RuntimeInfo.Inst.LaunchEnvExeDir);
                        using (TextWriter writer = new StreamWriter(fileName))
                        {
                            using (TextReader reader = new StreamReader(goldFile))
                            {
                                writer.Write(reader.ReadToEnd());
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 30
0
 static GlobalConfig()
 {
     //with single executables the AppContext.BaseDirectory value is the temp extract dir
     BaseDirectory = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) ?? AppContext.BaseDirectory;
     StartOptions  = new LaunchConfig(); //dummy to avoid nullable warning
 }
Exemplo n.º 31
0
    public override void Init()
    {
        var data = string.Empty;

        if (Application.platform == RuntimePlatform.Android)
        {
            //LogUtils.Log("loading launch cfg at android... path =", CFG_PATH);

            var url = new System.Uri(CFG_PATH.DataPath());
            UnityWebRequest.ClearCookieCache();
            UnityWebRequest reader = UnityWebRequest.Get(url);
            reader.SendWebRequest();

            while (!reader.isDone)
            {
                //.Log("loading launch cfg...");
            }

            data = reader.downloadHandler.text;

            //LogUtils.Log("loading launch cfg at android... data =", data);

            //JsonData jsond = JsonMapper.ToObject(File.ReadAllText(API_PATH));
            //if(jsond.Count > 0 && jsond[0].Count > 0)
            //{
            //    Config.APPID = Convert.ToInt32(jsond[0]["appid"]);
            //    Debug.Log(Config.APPID);
            //}
        }
        else
        {
            var file = new FileInfo(CFG_PATH.DataPath());
            if (file.Exists)
            {
                var fs = file.OpenText();
                data = fs.ReadToEnd();
                fs.Close();
            }
        }

        if (!string.IsNullOrEmpty(data))
        {
            //LogUtils.Log(data);
            Config = JsonMapper.ToObject <LaunchConfig>(data);
        }
        else
        {
            //LogUtils.Log("load launch cfg failed...");
            Config = new LaunchConfig();
        }


        if (Application.platform == RuntimePlatform.Android)
        {
            //LogUtils.Log("loading launch cfg at android... path =", API_PATH);

            var url = new System.Uri(API_PATH.DataPath());
            UnityWebRequest.ClearCookieCache();
            UnityWebRequest reader = UnityWebRequest.Get(url);
            reader.SendWebRequest();

            while (!reader.isDone)
            {
                //LogUtils.Log("loading launch cfg...");
            }

            data = reader.downloadHandler.text;

            //LogUtils.Log("loading launch cfg at android... data =", data);
        }
        else
        {
            var file = new FileInfo(API_PATH.DataPath());
            if (file.Exists)
            {
                var fs = file.OpenText();
                data = fs.ReadToEnd();
                fs.Close();
            }
        }

        if (!string.IsNullOrEmpty(data))
        {
#if BRANCH_TAPTAP
            Config.APPID = 12;
            Debug.Log("Config.APPID = " + Config.APPID);
#else
            //LogUtils.Log(data);
            JsonData deJson = LitJson.JsonMapper.ToObject(data);
            if (deJson.Keys.Contains("appid"))
            {
                Config.APPID = int.Parse(deJson["appid"].ToString());
                //Debug.Log("Config.APPID = " + Config.APPID);
            }
            if (deJson.Keys.Contains("zoneid"))
            {
                Config.ZONEID = int.Parse(deJson["zoneid"].ToString());
                //Debug.Log("Config.APPID = " + Config.ZONEID);
            }
#endif
        }
        else
        {
            //LogUtils.Log("load launch appid failed...");
        }
    }