示例#1
0
        public async Task <ScriptsCompileResult> Build(GameProject gameProject, FileInfo mainScript, bool releaseMode)
        {
            string scriptsPath = mainScript.DirectoryName;


            _compilationOptions =
                _compilationOptions.WithSourceReferenceResolver(
                    new SourceFileResolver(ImmutableArray <string> .Empty, scriptsPath));


            if (releaseMode)
            {
                _compilationOptions = _compilationOptions.WithOptimizationLevel(OptimizationLevel.Release);
            }

            if (!releaseMode && mainScript.LastWriteTime < _lastBuildTime)
            {
                return(new ScriptsCompileResult());
            }

            string scriptCode = File.ReadAllText(mainScript.FullName);

            ScriptsCompileResult result = await Task.Run(() => GenerateGameAssembly(scriptCode));

            if (result.Errors == null)
            {
                _lastBuildTime = DateTime.Now;
            }

            return(result);
        }
示例#2
0
    public void ConfirmNewGame()
    {
        if (!IsFormValid())
        {
            Debug.LogWarning("NewGameDialog.ConfirmNewGame : invalid form.");
            return;
        }

        string     gameName       = textfieldName.text.Trim();
        Genre      genre          = database.Genres.FindFirstByName(GetDropdownSelection(dropdownGenre));
        Theme      theme          = database.Themes.FindFirstByName(GetDropdownSelection(dropdownTheme));
        string     platformId     = database.Platforms.FindFirstByName(GetDropdownSelection(dropdownPlatform)).Id;
        GameEngine engine         = null;
        string     selectedEngine = GetDropdownSelection(dropdownEngine);

        foreach (GameEngine e in gameEngines)
        {
            if (e.Name == selectedEngine)
            {
                engine = e;
                break;
            }
        }
        Assert.IsNotNull(engine);
        GameProject newGameProject = new GameProject(gameName, genre, theme, engine,
                                                     new List <string> {
            platformId
        });

        submitNewGameDialog(newGameProject);
    }
示例#3
0
 public void Cleanup(GameProject gameProject)
 {
     if (Directory.Exists(gameProject.BuildDirectory))
     {
         Array.ForEach(Directory.GetFiles(gameProject.BuildDirectory), File.Delete);
     }
 }
示例#4
0
 public void AddProject(GameProject project)
 {
     if (project != null)
     {
         project.SetOwner(this);
         clientProjects.Add(project);
     }
 }
示例#5
0
        public Textures(GameProject project)
        {
            this.project  = project;
            TextureSheets = new List <TextureSheet>();
            textures      = new List <Texture>();

            CompileTextureSheets(project.Config.SheetSize);
        }
示例#6
0
        public async Task <List <AssetCompileResult> > Build(GameProject project)
        {
            _compilationTasks.Clear();

            var assetsDictionary = project.Assets;

            List <AssetCompileResult> compileResults = null;

            foreach (var asset in assetsDictionary)
            {
                var assetRelativePath = asset.Value.Replace(':', Path.DirectorySeparatorChar);

                var assetPath = Path.Combine(project.AssetsDirectory, assetRelativePath);

                FileInfo assetFileInfo = new FileInfo(assetPath);


                if (assetFileInfo.Exists)
                {
                    if (assetFileInfo.LastWriteTime > _lastBuildTime)
                    {
                        if (compileResults == null)
                        {
                            compileResults = new List <AssetCompileResult>();
                        }

                        var assetData = new AssetData()
                        {
                            Name = asset.Key
                        };

                        switch (assetFileInfo.Extension)
                        {
                        case ".png":
                        {
                            assetData.Type = AssetDataType.Pixmap;
                            _compilationTasks.Add(assetData.Name, GetCompileTask(compileResults, assetFileInfo, assetData));
                            break;
                        }
                        }
                    }
                }
            }

            if (_compilationTasks.Count > 0)
            {
                foreach (Task task in _compilationTasks.Values)
                {
                    task.Start();
                }

                await Task.WhenAll(_compilationTasks.Values);
            }

            _lastBuildTime = DateTime.Now;

            return(compileResults);
        }
示例#7
0
    private void OnGameStart()
    {
        string startingDate = gameDateTime.ToString("yyyy/MM/dd");

        Debug.Log($"World.OnGameStart : starting date = {startingDate}");

        GameEngine defaultEngine = new GameEngine("No Game Engine",
                                                  new DateTime(1980, 1, 1),
                                                  new [] { "PC" });

        defaultEngine.AddFeature("Graphics_2D_1");
        defaultEngine.AddFeature("Audio_Mono");
        playerCompany.AddGameEngine(defaultEngine);

        GameEngine basicEngine = new GameEngine("Basic Game Engine",
                                                new DateTime(1982, 1, 1),
                                                new [] { "PC", "NES" });

        basicEngine.AddFeature("Graphics_2D_1");
        basicEngine.AddFeature("Graphics_2D_2");
        basicEngine.AddFeature("Audio_Mono");
        playerCompany.AddGameEngine(basicEngine);

        globalMarket.ReleaseGameEngine(gameDateTime, basicEngine,
                                       database.EngineFeatures);

        for (int i = 1; i <= 5; i++)
        {
            GameProject previousGame = new GameProject($"Previous Game {i}",
                                                       database.Genres.FindById("RPG"),
                                                       database.Themes.FindById("HighFantasy"),
                                                       defaultEngine,
                                                       new List <string> {
                "PC", "NES"
            });
            playerCompany.StartProject(previousGame, gameDateTime);
            playerCompany.CompleteCurrentProject();
            worldController.OnProjectCompleted(playerCompany, previousGame);
        }

        GameProject testGame = new GameProject("Test Game",
                                               database.Genres.FindById("Action"),
                                               database.Themes.FindById("Far West"),
                                               defaultEngine,
                                               new List <string> {
            "PC"
        });

        playerCompany.StartProject(testGame, gameDateTime);

        companyBuilding.InitStartingRooms(database.Rooms);

        firstDay          = false;
        simulationRunning = true;
        worldController.OnSimulationStarted();
    }
示例#8
0
        public GameInstance(GameProject project)
        {
            LogManager.Log("Creating GameInstance...");
            Project = project;
            GraphicsDeviceManager = new GraphicsDeviceManager(this);
            Content.RootDirectory = project.ContentFolderPath;
            _api = new OxyApi();

            // Events must be initialized before Initialize
            InitializeEvents();
        }
示例#9
0
        public Compiler(GameProject project)
        {
            this.project  = project;
            Classes       = new List <Class>();
            scopeStack    = new Stack <List <string> >();
            typeStack     = new Stack <string>();
            breakStack    = new Stack <Label>();
            continueStack = new Stack <Label>();
            random        = new Random();

            LoadEngineLibrary();
        }
 private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
 {
     try
     {
         string path = Configer.Instance.ScriptRootMenu + "\\Scripts\\project.xml";
         GameProject.LoadGameProject(path);
         this.Refresh();
         CurrentProjectText.Text = path;
     }
     catch (Exception ex)
     {
         MessageBox.Show("游戏工程载入错误" + ex.ToString());
     }
 }
示例#11
0
        static async Task Main(string[] args)
        {
            var razor = new RazorLightEngineBuilder()
                        .DisableEncoding()
                        .UseEmbeddedResourcesProject(Assembly.GetExecutingAssembly(), "Templates.BuildSystems")
                        .UseMemoryCachingProvider()
                        .Build();

            var project       = new GameProject();
            var configuration = new Configuration();

            project.Configure(configuration);
            var ninja          = new Ninja();
            var generatedFiles = await ninja.Generate(razor, project, configuration);

            foreach (var file in generatedFiles)
            {
                Directory.CreateDirectory(Path.GetDirectoryName(file.Path));
                File.WriteAllText(file.Path, file.Content);
            }

            {
                var typesAssembly = Assembly.GetAssembly(typeof(TestClassA));
                Debug.Assert(typesAssembly != null);

                var razorEngine = new RazorLightEngineBuilder()
                                  .UseEmbeddedResourcesProject(Assembly.GetExecutingAssembly(), "Templates.CodeGen")
                                  .UseMemoryCachingProvider()
                                  .Build();

                var templates = new[] { "Types.h" };
                foreach (string template in templates)
                {
                    Console.WriteLine($"Rendering template {template}...");
                    string namespacedTemplate = template.Replace('/', '.');
                    string compiledSrc        = await razorEngine.CompileRenderAsync(namespacedTemplate, typesAssembly);

                    string outFilePath  = Path.Combine(Options.CodeGenRoot, template);
                    string outDirectory = Path.GetDirectoryName(outFilePath) ?? "";
                    if (!string.IsNullOrWhiteSpace(outDirectory))
                    {
                        Directory.CreateDirectory(outDirectory);
                    }

                    File.WriteAllText(outFilePath, compiledSrc);
                }
            }
        }
示例#12
0
        public override void Execute(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("swift compile <project-name>");
                return;
            }

            try
            {
                GameProject.Create(args[0]);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        private void OpenProjectButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter           = "游戏工程文件(project.xml)|*.xml";
            dialog.InitialDirectory = (Configer.Instance.ScriptRootMenu + "\\Scripts\\");
            dialog.ShowDialog();

            try
            {
                GameProject.LoadGameProject(dialog.File.FullName);
                this.Refresh();
                CurrentProjectText.Text = dialog.File.FullName;
            }
            catch (Exception ex)
            {
                MessageBox.Show("游戏工程载入错误" + ex.ToString());
            }
        }
示例#14
0
        public async Task <BuildResult> Export(GameProject gameProject)
        {
            BuildResult result = await Build(gameProject, releaseMode : true);

            if (result.Ok)
            {
                // Copy Game Script DLL
                _scriptsBuilder.SaveScriptsDataFile(gameProject, result.ScriptData);

                // Copy Game Executable

                var srcExePath    = Path.Combine(Directory.GetCurrentDirectory(), "PicoSystem.Player.exe");
                var targetExePath = Path.Combine(gameProject.DistDirectory, $"{gameProject.Name}.exe");

                File.Copy(srcExePath, targetExePath);

                // Copy dependencies DLL's

                foreach (var exportDllName in exportDLLNames)
                {
                    string dllPath    = Path.Combine(Directory.GetCurrentDirectory(), exportDllName);
                    string targetPath = Path.Combine(gameProject.DistDirectory, exportDllName);

                    File.Copy(dllPath, targetPath);
                }

#if DEBUG
                foreach (var exportDllName in exportDebugDLLNames)
                {
                    string dllPath    = Path.Combine(Directory.GetCurrentDirectory(), exportDllName);
                    string targetPath = Path.Combine(gameProject.DistDirectory, exportDllName);

                    File.Copy(dllPath, targetPath);
                }
#endif
            }

            return(result);
        }
        public void GameInit()
        {
            //if (Configer.Instance.Debug)
            //{
            //    Application.Current.Host.Settings.EnableFrameRateCounter = true;
            //}

            //this.TouchHostPage();

            if (!GameProject.IsLoaded)
            {
                GameProject.LoadGameProject();
            }

            GameServerManager.Instance.Init();
            BattleNetManager.Instance.SetConnectArgs("www.jy-x.com", 4502, this.Dispatcher);
            //BattleNetManager.Instance.SetConnectArgs("211.100.49.136", 4502, this.Dispatcher);
            //BattleNetManager.Instance.SetConnectArgs("127.0.0.1", 4502, this.Dispatcher);
            if (!Configer.Instance.Debug)
            {
                uiHost.battleFieldContainer.debugPanel.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                uiHost.battleFieldContainer.debugPanel.Visibility = System.Windows.Visibility.Visible;
            }

            string rAssembly = Assembly.GetExecutingAssembly().FullName.Split(',')[1].Split('=')[1];

            uiHost.mainMenu.versionText.Text = rAssembly;
            uiHost.VersionInfoText.Text      = "金X " + rAssembly;

            height = this.LayoutRoot.Height;
            width  = this.LayoutRoot.Width;
            //Application.Current.Host.Content.Resized += new EventHandler(Content_Resized);
            Application.Current.Host.Content.FullScreenChanged += new EventHandler(Content_Resized);
        }
示例#16
0
 public ProjectNode(NodeView nodeView, GameProject gameProject)
     : base(nodeView, gameProject.RootDirectory)
 {
     this.GameProject = gameProject;
     this.Text        = gameProject.RootDirectory;
 }
示例#17
0
文件: Audio.cs 项目: DatZach/Swift
 public Audio(GameProject project)
 {
     this.project = project;
 }
示例#18
0
        public static List <IFunction> DefaultFunctions()
        {
            List <IFunction> functions = new List <IFunction>();

            // Conversion
            functions.Add(new Function <int>("float.ToInt", SymbolType.Integer,
                                             new[] { SymbolType.Float },
                                             (c, p) => new IntegerSymbol((int)((FloatSymbol)p[0]).Value)));
            functions.Add(new Function <int>("string.ToInt", SymbolType.Integer,
                                             new[] { SymbolType.String }, (c, p) => {
                int result;
                if (!int.TryParse(((StringSymbol)p[0]).Value, Parser.NumberStyleInteger,
                                  Symbol <int> .CultureInfo, out result))
                {
                    Debug.LogError($"Function ToInt({p[0].ValueString()}) : cannot parse as Integer.");
                    return(null);
                }
                return(new IntegerSymbol(result));
            }));
            functions.Add(new Function <float>("int.ToFloat", SymbolType.Float,
                                               new[] { SymbolType.Integer },
                                               (c, p) => new FloatSymbol(((IntegerSymbol)p[0]).Value)));
            functions.Add(new Function <float>("string.ToFloat", SymbolType.Float,
                                               new[] { SymbolType.String }, (c, p) => {
                float result;
                if (!float.TryParse(((StringSymbol)p[0]).Value, Parser.NumberStyleFloat,
                                    Symbol <float> .CultureInfo, out result))
                {
                    Debug.LogError($"Function ToFloat({p[0].ValueString()}) : cannot parse as Float.");
                    return(null);
                }
                return(new FloatSymbol(result));
            }));
            // Generic
            functions.Add(new Function <string>("ToString", SymbolType.String,
                                                new [] { SymbolType.Void }, (c, p) => new StringSymbol(p[0].ValueString())));
            // Math
            functions.Add(new Function <float>("Math.Cos", SymbolType.Float,
                                               new [] { SymbolType.Float },
                                               (c, p) => new FloatSymbol(Mathf.Cos(((FloatSymbol)p[0]).Value))));
            functions.Add(new Function <float>("Math.Sin", SymbolType.Float,
                                               new [] { SymbolType.Float },
                                               (c, p) => new FloatSymbol(Mathf.Sin(((FloatSymbol)p[0]).Value))));
            functions.Add(new Function <float>("Math.Tan", SymbolType.Float,
                                               new [] { SymbolType.Float },
                                               (c, p) => new FloatSymbol(Mathf.Tan(((FloatSymbol)p[0]).Value))));
            functions.Add(new Function <float>("Math.Abs", SymbolType.Float,
                                               new [] { SymbolType.Float },
                                               (c, p) => new FloatSymbol(Mathf.Abs(((FloatSymbol)p[0]).Value))));
            // Random
            functions.Add(new Function <float>("Random.Next", SymbolType.Float,
                                               new SymbolType[0], (c, p) => new FloatSymbol(Random.value)));
            functions.Add(new Function <float>("Random.Range", SymbolType.Float,
                                               new [] { SymbolType.Float, SymbolType.Float },
                                               (c, p) => new FloatSymbol(Random.Range(((FloatSymbol)p[0]).Value,
                                                                                      ((FloatSymbol)p[1]).Value))));
            // Arrays
            functions.Add(new Function <int>("array.Count", SymbolType.Integer,
                                             new [] { SymbolType.Array }, (c, p) => {
                int count;
                switch (p[0].ArrayType())
                {
                case SymbolType.Void: count = ((ArraySymbol <Void>)p[0]).Value.Elements.Count; break;

                case SymbolType.Boolean: count = ((ArraySymbol <bool>)p[0]).Value.Elements.Count; break;

                case SymbolType.Integer: count = ((ArraySymbol <int>)p[0]).Value.Elements.Count; break;

                case SymbolType.Float: count = ((ArraySymbol <float>)p[0]).Value.Elements.Count; break;

                case SymbolType.Id: count = ((ArraySymbol <Id>)p[0]).Value.Elements.Count; break;

                case SymbolType.String: count = ((ArraySymbol <string>)p[0]).Value.Elements.Count; break;

                case SymbolType.Date: count = ((ArraySymbol <DateTime>)p[0]).Value.Elements.Count; break;

                default:
                    Debug.LogError("Function array.Count : unsupported Array " +
                                   $"type \"{p[0].ArrayType()}\".");
                    return(null);
                }
                return(new IntegerSymbol(count));
            }));
            // Company
            functions.Add(new Function <bool>("Company.SetFeature",
                                              SymbolType.Boolean, new [] { SymbolType.Id, SymbolType.Boolean },
                                              (c, p) => {
                string featureId = ((IdSymbol)p[0]).Value.Identifier;
                bool enabled     = ((BooleanSymbol)p[1]).Value;
                bool result      = c.C().SetFeature(featureId, enabled);
                if (!result)
                {
                    Debug.LogError($"Function Company.SetFeature({featureId}, {enabled}) : " +
                                   $"invalid Feature ID \"{featureId}\".");
                }
                return(new BooleanSymbol(result));
            }));
            // Projects Statistics
            functions.Add(new Function <int>("Company.Projects.CompletedGamesCount",
                                             SymbolType.Integer, new SymbolType[0],
                                             (c, p) => new IntegerSymbol(c.C().CompletedProjects.Games.Count)));
            functions.Add(new Function <int>("Company.Projects.CompletedGames.WithEngineFeatureCount",
                                             SymbolType.Integer, new [] { SymbolType.Id },
                                             (c, p) => new IntegerSymbol(c.C().CompletedProjects.GamesWithEngineFeature(
                                                                             ((IdSymbol)p[0]).Value.Identifier).Count)));
            // Games
            functions.Add(new Function <float>("CurrentGame.Score",
                                               SymbolType.Float, new [] { SymbolType.Id },
                                               (c, p) => {
                GameProject game = c.C().CurrentGame();
                string scoreId   = ((IdSymbol)p[0]).Value.Identifier;
                if (game == null)
                {
                    Debug.LogError($"Function Company.CurrentGame.Score({scoreId}) : no current Game Project.");
                    return(null);
                }
                Project.ProjectScore score = game.Scores.Find(s => s.Id == scoreId);
                if (score != null)
                {
                    return(new FloatSymbol(score.score));
                }
                Debug.LogError($"Function Company.CurrentGame.Score({scoreId}) : no such Score ID.");
                return(null);
            }));
            functions.Add(new Function <float>("CurrentGame.ModifyScore",
                                               SymbolType.Float, new [] { SymbolType.Id, SymbolType.Float },
                                               (c, p) => {
                GameProject game = c.C().CurrentGame();
                string scoreId   = ((IdSymbol)p[0]).Value.Identifier;
                if (game == null)
                {
                    Debug.LogError($"Function Company.CurrentGame.Score({scoreId}) : no current Game Project.");
                    return(null);
                }
                Project.ProjectScore score = game.Scores.Find(s => s.Id == scoreId);
                if (score == null)
                {
                    Debug.LogError($"Function Company.CurrentGame.Score({scoreId}) : no such Score ID.");
                    return(null);
                }
                score.score += ((FloatSymbol)p[1]).Value;
                return(new FloatSymbol(score.score));
            }));
            // Employee Skills Proficiency
            functions.Add(new Function <float>("CurrentEmployee.Skill",
                                               SymbolType.Float, new [] { SymbolType.Id },
                                               (c, p) => {
                string skillId    = ((IdSymbol)p[0]).Value.Identifier;
                Employee employee = c.CurrentEmployee();
                if (employee == null)
                {
                    Debug.LogError($"Function CurrentEmployee.Skill({skillId}) : no current Employee set.");
                    return(null);
                }
                EmployeeSkill employeeSkill = Array.Find(employee.EmployeeSkills,
                                                         ec => ec.Id == skillId);
                if (employeeSkill == null)
                {
                    Debug.LogError($"Function CurrentEmployee.Skill({skillId}) : no such Skill for Employee \"{employee.Name}\".");
                    return(null);
                }
                return(new FloatSymbol(employeeSkill.Proficiency));
            }));

            return(functions);
        }
示例#19
0
        public async Task <BuildResult> Build(GameProject gameProject, bool releaseMode = false)
        {
            BuildResult result = new BuildResult();

            string targetDirectory = releaseMode ? gameProject.DistDirectory : gameProject.BuildDirectory;

            StringBuilder messageBuilder = new StringBuilder();

            FileInfo mainScriptFile = new FileInfo(Path.Combine(gameProject.ScriptsDirectory, gameProject.MainScript));

            if (mainScriptFile.Exists)
            {
                ScriptsCompileResult scriptsCompileResult = await _scriptsBuilder.Build(gameProject, mainScriptFile, releaseMode);

                bool scriptsOk = scriptsCompileResult.Errors == null;

                if (scriptsOk)
                {
                    if (!Directory.Exists(targetDirectory))
                    {
                        Directory.CreateDirectory(targetDirectory);
                    }

                    result.ScriptData = scriptsCompileResult.ScriptData;

                    bool assetsOk = true;

                    result.AssetsInvalidated = false;

                    // Build Resource Pack
                    List <AssetCompileResult> assetCompileResults = await _assetsBuilder.Build(gameProject);

                    if (assetCompileResults != null && assetCompileResults.Count > 0)
                    {
                        result.AssetsInvalidated = true;

                        foreach (var assetCompileResult in assetCompileResults)
                        {
                            if (!string.IsNullOrEmpty(assetCompileResult.Error))
                            {
                                if (assetsOk)
                                {
                                    messageBuilder.AppendLine("Error building assets:");
                                }

                                assetsOk = false;

                                messageBuilder.AppendLine($"In Resource: {assetCompileResult.AssetData.Name} : {assetCompileResult.Error}");
                            }
                        }

                        AssetsPack assetPack = new AssetsPack();

                        foreach (var assetCompileResult in assetCompileResults)
                        {
                            assetPack.AddAssetData(assetCompileResult.AssetData.Name, assetCompileResult.AssetData);
                        }

                        _assetsBuilder.SaveAssetsDataFile(targetDirectory, assetPack);
                    }

                    if (assetsOk)
                    {
                        result.Ok = true;
                    }
                    else
                    {
                        result.ResultMessage = messageBuilder.ToString();
                    }

                    return(result);
                }

                // Build Error:

                messageBuilder.AppendLine("Error compiling scripts:");

                foreach (var error in scriptsCompileResult.Errors)
                {
                    messageBuilder.AppendLine(error);
                }

                result.ResultMessage = messageBuilder.ToString();
                result.Ok            = false;
                return(result);
            }
            else
            {
                result.ResultMessage = "Missing Main Script!";
                result.Ok            = false;
                return(result);
            }
        }
示例#20
0
 public EcsInstance(GameProject project) : base(project)
 {
     _gameSystemManager = new GameSystemManager(this);
 }
示例#21
0
 public Sounds(GameProject project)
 {
     this.project = project;
 }
示例#22
0
        public override void Execute(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("swift run <project-name> [args]");
                return;
            }

            if (!Swift.License.IsRegistered())
            {
                Console.WriteLine("This copy of Swift is unlicensed. Please contact Zach Reedy for your Alpha license key.");
                return;
            }

            if (string.IsNullOrEmpty(Program.EnginePath))
            {
                Console.WriteLine("Error: Cannot locate suitable engine to launch with.");
                return;
            }

            string target = args.First();

            if (!Directory.Exists(target))
            {
                Console.WriteLine("Project directory does not exist.");
                return;
            }

            GameProject project = new GameProject();

            project.Load(target);

            string arguments = "--game \"" + project.TargetGameDataPath + "\" --debug";

            for (int i = 1; i < args.Length; ++i)
            {
                arguments += " " + args[i];
            }

            try
            {
                Console.WriteLine("Running game from \"{0}\"", project.TargetPath);
                Console.WriteLine("{0} {1}", Program.EnginePath, arguments);

                ProcessStartInfo startInfo = new ProcessStartInfo(Program.EnginePath, arguments)
                {
                    WorkingDirectory       = project.TargetPath,
                    RedirectStandardOutput = false,
                    RedirectStandardError  = false,
                    UseShellExecute        = false,
                    CreateNoWindow         = false
                };

                Process engine = Process.Start(startInfo);
                if (engine != null)
                {
                    engine.WaitForExit();

                    Console.WriteLine();

                    if (engine.ExitCode != 0)
                    {
                        Console.WriteLine("Engine returned with exit code {0}", engine.ExitCode);
                    }
                }
                else
                {
                    Console.WriteLine("Cannot start engine, but it was found.");
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Cannot start engine because it wasn't found.");
                Console.WriteLine("Tried to start it from \"{0}\".", Program.EnginePath);
            }
        }
示例#23
0
 private void tsmiStart_Click(object sender, EventArgs e)
 {
     GameProject.StartGame();
 }
示例#24
0
        public void SaveScriptsDataFile(GameProject project, byte[] scriptData)
        {
            var codeDataPath = Path.Combine(project.DistDirectory, "Game.dll");

            File.WriteAllBytes(codeDataPath, scriptData);
        }
示例#25
0
        public static void RandomAddProjectToClient(GameProject project, List <Client> clients)
        {
            int ranIndexClient = rand.Next(0, clients.Count);

            clients[ranIndexClient].AddProject(project);
        }
示例#26
0
 private void tsmiStop_Click(object sender, EventArgs e)
 {
     GameProject.KillGame();
 }
示例#27
0
        public override void Execute(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("swift compile <project-name> [platform]");
                return;
            }

            if (!Swift.License.IsRegistered())
            {
                Console.WriteLine("This copy of Swift is unlicensed. Please contact Zach Reedy for your Alpha license key.");
                return;
            }

            string projectName = args[0];

            if (!Directory.Exists(projectName))
            {
                Console.WriteLine("Project directory does not exist.");
                return;
            }

            GameData.PlatformFlags platform;

            if (args.Length > 1 && !args[1].StartsWith("--"))
            {
                if (!Enum.TryParse(args[1], true, out platform))
                {
                    Console.WriteLine("Warning: Unknown target platform \"{0}\", targeting default platform instead.", args[1]);
                    platform = DetectPlatform();
                }
            }
            else
            {
                platform = DetectPlatform();
            }

            if (platform == GameData.PlatformFlags.Unknown)
            {
                Console.WriteLine("Warning: Could not resolve current target platform, games may not compile or run.");
            }

            Stopwatch compileTimer = new Stopwatch();

            compileTimer.Start();

#if !DEBUG
            try
            {
#endif
            GameProject gameProject = new GameProject();
            gameProject.Load(projectName);

            if (File.Exists(gameProject.TargetGameDataPath))
            {
                File.Delete(gameProject.TargetGameDataPath);
            }

            GameData gameData = new GameData(gameProject, platform)
            {
                ExportSheets    = args.Any(arg => arg == "--export-sheets"),
                ShowDisassembly = args.Any(arg => arg == "--disassemble")
            };

            if (gameData.SerializeFromProject())
            {
                if (!gameData.Save(gameProject.TargetGameDataPath))
                {
                    throw new CompilerException("Cannot save game data.");
                }

                compileTimer.Stop();
                Console.WriteLine("Compiled in {0}ms.", compileTimer.ElapsedMilliseconds);
            }
#if !DEBUG
        }

        catch (CompilerException e)
        {
            Console.WriteLine(e.Message);
        }
        catch (IOException e)
        {
            Console.WriteLine(e.Message);
        }
        catch (Exception e)
        {
            Console.WriteLine("UNHANDLED EXCEPTION: {0}", e.Message);
            Console.WriteLine("--- Stack Trace ---");
            Console.WriteLine(e.StackTrace);
        }
#endif
        }