Exemplo n.º 1
0
        public void GenerateScript(string directory, string layerName)
        {
            LayerName  = layerName;
            ModuleName = directory.Substring(directory.LastIndexOf(Path.DirectorySeparatorChar) + 1);
            var builder = new StringBuilder();

            AddHeader(builder);

            AddFooter(builder);

            var directoryPath = "";

            switch (GetKindName())
            {
            case "{0}Locator":
            case "I{0}Manager":
            case "{0}ManagerMock":
                directoryPath = Path.Combine(directory, "Interface");
                break;

            case "{0}Manager":
            case "{0}ManagerTest":
                directoryPath = Path.Combine(directory, "Impl");
                break;
            }

            var fileName = string.Format(GetKindName(), ModuleName) + ".cs";
            var filePath = Path.Combine(directoryPath, fileName);

            FileIoLocater.Write(filePath, builder.ToString());
        }
Exemplo n.º 2
0
        public void GenerateScript(IGameObjectFieldInfo gameObjectFieldInfo)
        {
            ModuleName = gameObjectFieldInfo.GetModuleName();
            var builder = new StringBuilder();

            AddHeader(builder);

            // add fields
            foreach (var gameObjectName in gameObjectFieldInfo.GetTextGameObjects())
            {
                AddField(builder, gameObjectName, "Text");
            }

            if (gameObjectFieldInfo.GetTextGameObjects().Count > 0)
            {
                builder.AppendLine();
            }

            foreach (var gameObjectName in gameObjectFieldInfo.GetImageGameObjects())
            {
                AddField(builder, gameObjectName, "Image");
            }

            if (gameObjectFieldInfo.GetImageGameObjects().Count > 0)
            {
                builder.AppendLine();
            }
            foreach (var gameObjectName in gameObjectFieldInfo.GetButtonGameObjects())
            {
                AddField(builder, gameObjectName, "Button");
            }

            if (gameObjectFieldInfo.GetToggleGameObjects().Count > 0)
            {
                builder.AppendLine();
            }
            foreach (var gameObjectName in gameObjectFieldInfo.GetToggleGameObjects())
            {
                AddField(builder, gameObjectName, "Toggle[]");
            }

            if (gameObjectFieldInfo.GetButtonGameObjects().Count > 0)
            {
                builder.AppendLine();
            }

            AddAwake(builder, gameObjectFieldInfo.GetButtonGameObjects(), gameObjectFieldInfo.GetToggleGameObjects());

            // add methods
            foreach (var gameObjectName in gameObjectFieldInfo.GetButtonGameObjects())
            {
                AddOnButtonClickMethod(builder, gameObjectName);
                builder.AppendLine();
            }

            foreach (var gameObjectName in gameObjectFieldInfo.GetToggleGameObjects())
            {
                AddOnToggleChangeMethod(builder, gameObjectName);
                builder.AppendLine();
            }


            AddFotter(builder);

            var filePath = gameObjectFieldInfo.GetFilePath(GetKindName());

            FileIoLocater.Write(filePath, builder.ToString());
        }