Beispiel #1
0
        private FunctionSyntax GetMainFunctionSyntax(float left, float right, float top, float bottom, Tileset tileset, SoundEnvironment sound, params string[] initFunctions)
        {
            var statements = new List <NewStatementSyntax>()
            {
                JassSyntaxFactory.CallStatement(
                    "SetCameraBounds",
                    JassSyntaxFactory.ArgumentList(
                        JassSyntaxFactory.VariableExpression("left"),
                        JassSyntaxFactory.VariableExpression("bottom"),
                        JassSyntaxFactory.VariableExpression("right"),
                        JassSyntaxFactory.VariableExpression("top"),
                        JassSyntaxFactory.VariableExpression("left"),
                        JassSyntaxFactory.VariableExpression("top"),
                        JassSyntaxFactory.VariableExpression("right"),
                        JassSyntaxFactory.VariableExpression("bottom"))),
                JassSyntaxFactory.CallStatement(
                    "SetDayNightModels",
                    JassSyntaxFactory.ArgumentList(
                        JassSyntaxFactory.ConstantExpression(LightEnvironmentProvider.GetTerrainLightEnvironmentModel(tileset)),
                        JassSyntaxFactory.ConstantExpression(LightEnvironmentProvider.GetUnitLightEnvironmentModel(tileset)))),
                JassSyntaxFactory.CallStatement(
                    "NewSoundEnvironment",
                    JassSyntaxFactory.ConstantExpression(SoundEnvironmentProvider.GetSoundEnvironment(sound))),
                JassSyntaxFactory.CallStatement(
                    "SetAmbientDaySound",
                    JassSyntaxFactory.ConstantExpression(SoundEnvironmentProvider.GetAmbientDaySound(tileset))),
                JassSyntaxFactory.CallStatement(
                    "SetAmbientNightSound",
                    JassSyntaxFactory.ConstantExpression(SoundEnvironmentProvider.GetAmbientNightSound(tileset))),
                JassSyntaxFactory.CallStatement(
                    "SetMapMusic",
                    JassSyntaxFactory.ArgumentList(
                        JassSyntaxFactory.ConstantExpression("Music"),
                        JassSyntaxFactory.ConstantExpression(true),
                        JassSyntaxFactory.ConstantExpression(0))),
            };

            foreach (var initFunction in initFunctions)
            {
                statements.Add(JassSyntaxFactory.CallStatement(initFunction));
            }

            return(JassSyntaxFactory.Function(
                       JassSyntaxFactory.FunctionDeclaration("main"),
                       JassSyntaxFactory.LocalVariableList(
                           JassSyntaxFactory.VariableDefinition(
                               JassSyntaxFactory.ParseTypeName("real"),
                               "left",
                               JassSyntaxFactory.BinaryAdditionExpression(
                                   JassSyntaxFactory.ConstantExpression(left),
                                   JassSyntaxFactory.InvocationExpression(
                                       "GetCameraMargin",
                                       JassSyntaxFactory.ArgumentList(JassSyntaxFactory.VariableExpression("CAMERA_MARGIN_LEFT"))))),
                           JassSyntaxFactory.VariableDefinition(
                               JassSyntaxFactory.ParseTypeName("real"),
                               "right",
                               JassSyntaxFactory.BinarySubtractionExpression(
                                   JassSyntaxFactory.ConstantExpression(right),
                                   JassSyntaxFactory.InvocationExpression(
                                       "GetCameraMargin",
                                       JassSyntaxFactory.ArgumentList(JassSyntaxFactory.VariableExpression("CAMERA_MARGIN_RIGHT"))))),
                           JassSyntaxFactory.VariableDefinition(
                               JassSyntaxFactory.ParseTypeName("real"),
                               "top",
                               JassSyntaxFactory.BinarySubtractionExpression(
                                   JassSyntaxFactory.ConstantExpression(top),
                                   JassSyntaxFactory.InvocationExpression(
                                       "GetCameraMargin",
                                       JassSyntaxFactory.ArgumentList(JassSyntaxFactory.VariableExpression("CAMERA_MARGIN_TOP"))))),
                           JassSyntaxFactory.VariableDefinition(
                               JassSyntaxFactory.ParseTypeName("real"),
                               "bottom",
                               JassSyntaxFactory.BinaryAdditionExpression(
                                   JassSyntaxFactory.ConstantExpression(bottom),
                                   JassSyntaxFactory.InvocationExpression(
                                       "GetCameraMargin",
                                       JassSyntaxFactory.ArgumentList(JassSyntaxFactory.VariableExpression("CAMERA_MARGIN_BOTTOM")))))),
                       statements.ToArray()));
        }