Example #1
0
    public void DoBreakBoneAnimation(
        ref Character _CharacterRef,
        int _PartIndex = 0 /* <= 0, for random */)
    {
        if (_PartIndex <= 0)
        {
            _PartIndex = Random.Range(1, _CharacterRef.mesh.m_nPartCount);
        }

        GlobalSingleton.DEBUG("DoBreakBoneAnimation Obj = "
                              + _CharacterRef.ToString()
                              + ", nPartIndex = "
                              + _PartIndex);

        s_DummyIndex = (s_DummyIndex + 1) % m_DummyPoints.Count;
        GameObject obj = m_DummyPoints[s_DummyIndex];

        obj.transform.position = _CharacterRef.transform.position;
        _CharacterRef.mesh.BreakPart(_PartIndex, obj);

        BoneAnimation boneAnimation = obj.AddComponent <BoneAnimation>();

        boneAnimation.m_StartPoint = _CharacterRef.transform.position;
        boneAnimation.m_EndPoint   = new Vector3(
            Random.Range(-32.0f, 32.0f),
            Random.Range(-1.0f, 1.0f),
            Random.Range(-10.0f, 5.0f));

        Invoke("OnBoneAnimationFinish", 5.0f);
    }
Example #2
0
        public static void DeleteEntityWriteTests(string solutionDirectory, Entity entity, string solutionName, string dbContextName)
        {
            try
            {
                var classPath = ClassPathHelper.TestRepositoryClassPath(solutionDirectory, $"Delete{entity.Name}RepositoryTests.cs", entity.Name, solutionName);

                if (!Directory.Exists(classPath.ClassDirectory))
                {
                    Directory.CreateDirectory(classPath.ClassDirectory);
                }

                if (File.Exists(classPath.FullClassPath))
                {
                    throw new FileAlreadyExistsException(classPath.FullClassPath);
                }

                using (FileStream fs = File.Create(classPath.FullClassPath))
                {
                    var data = DeleteRepositoryTestFileText(classPath, entity, solutionName, dbContextName);
                    fs.Write(Encoding.UTF8.GetBytes(data));
                }

                GlobalSingleton.AddCreatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", ""));
            }
            catch (FileAlreadyExistsException e)
            {
                WriteError(e.Message);
                throw;
            }
            catch (Exception e)
            {
                WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                throw;
            }
        }
 void Start()
 {
     buttonColor   = GlobalSingleton.GetColor(id);
     buttonColor.a = offOpacity;
     image.color   = buttonColor;
     KeyRemap();
 }
Example #4
0
    public void SetOpponentTarget(int _ChunkIndex, string _ChunkString)
    {
        if (!m_OpponentTargetMap.ContainsKey(_ChunkIndex))
        {
            m_OpponentTargetMap.Add(_ChunkIndex, null);
        }
        if (!m_OpponentOriginalPosition.ContainsKey(_ChunkIndex))
        {
            m_OpponentOriginalPosition.Add(_ChunkIndex, Vector3.zero);
        }
        if (!m_SelfOriginalPosition.ContainsKey(_ChunkIndex))
        {
            m_SelfOriginalPosition.Add(_ChunkIndex, Vector3.zero);
        }

        m_OpponentTargetMap[_ChunkIndex]        = GlobalSingleton.Find(_ChunkString, true);
        m_OpponentOriginalPosition[_ChunkIndex] = m_OpponentTargetMap[_ChunkIndex].transform.position;
        m_SelfOriginalPosition[_ChunkIndex]     = ChunkRef[_ChunkIndex].transform.position;

        if (null == m_OpponentTargetMap[_ChunkIndex])
        {
            Debug.LogWarning("SetOpponentTarget null == null == m_OpponentTargetMap _ChunkString" + _ChunkString);
        }

        if (!m_ActuallyBeenHittedMap.ContainsKey(_ChunkIndex))
        {
            m_ActuallyBeenHittedMap.Add(_ChunkIndex, false);
        }
        m_ActuallyBeenHittedMap[_ChunkIndex] = false;
    }
Example #5
0
        public static void Create(string solutionDirectory, string solutionName)
        {
            try
            {
                var classPath = ClassPathHelper.HttpClientExtensionsClassPath(solutionDirectory, solutionName, $"HttpClientExtensions.cs");

                if (!Directory.Exists(classPath.ClassDirectory))
                {
                    Directory.CreateDirectory(classPath.ClassDirectory);
                }

                if (File.Exists(classPath.FullClassPath))
                {
                    File.Delete(classPath.FullClassPath); // saves me from having to make a remover!
                }
                using (FileStream fs = File.Create(classPath.FullClassPath))
                {
                    var data = CreateHttpClientExtensionsText(classPath);
                    fs.Write(Encoding.UTF8.GetBytes(data));
                }

                GlobalSingleton.AddCreatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", ""));
            }
            catch (FileAlreadyExistsException e)
            {
                WriteError(e.Message);
                throw;
            }
            catch (Exception e)
            {
                WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                throw;
            }
        }
    void Update()
    {
        if (GlobalSingleton.GetHealth() < 0)
        {
            if (pressed)
            {
                GlobalSingleton.GetSound().PlayerOff(id);
                pressed = false;
            }
            return;
        }

        if (Input.GetKeyDown(keyCode))
        {
            if (aniCor != null)
            {
                StopCoroutine(aniCor);
            }
            aniCor = StartCoroutine(HitchLib.Tweening.GenericTween(new Action <float>(AnimateAlpha), offOpacity, onOpacity, 0.05f, HitchLib.Easing.EASE_LINEAR));
            GlobalSingleton.GetSound().PlayerOn(id);
            pressed = true;
        }
        if (Input.GetKeyUp(keyCode))
        {
            if (aniCor != null)
            {
                StopCoroutine(aniCor);
            }
            aniCor = StartCoroutine(HitchLib.Tweening.GenericTween(new Action <float>(AnimateAlpha), onOpacity, offOpacity, 0.25f, HitchLib.Easing.EASE_LINEAR));
            GlobalSingleton.GetSound().PlayerOff(id);
            pressed = false;
        }
    }
Example #7
0
        public static void Run(string solutionDirectory, string entityName, EntityProperty prop)
        {
            try
            {
                GlobalSingleton instance = GlobalSingleton.GetInstance();

                var propList = new List <EntityProperty>()
                {
                    prop
                };

                EntityModifier.AddEntityProperties(solutionDirectory, entityName, propList);
                DtoModifier.AddPropertiesToDtos(solutionDirectory, entityName, propList);
                RepositoryModifier.AddInclude(solutionDirectory, entityName, propList);

                WriteHelpHeader($"{Environment.NewLine}The '{prop.Name}' property was successfully added to the '{entityName}' entity and it's associated DTOs. Keep up the good work!");
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException ||
                    e is SolutionNotFoundException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }
Example #8
0
        public void OneInstance()
        {
            var s1 = GlobalSingleton.Instance();
            var s2 = GlobalSingleton.Instance();

            Assert.That(s1, Is.EqualTo(s2));
        }
Example #9
0
 public static void IncreaseScore()
 {
     ++instance.score;
     if (instance.score > 5)
     {
         instance.bpm += 1;
     }
     if (instance.score > 10)
     {
         instance.bpm += 1;
     }
     if (instance.score > 20)
     {
         instance.bpm += 3;
     }
     if (instance.score > 30)
     {
         instance.bpm += 5;
     }
     if (instance.bpm > 160)
     {
         instance.bpm = 160;
     }
     instance.hideThreshold = (instance.score + 1) / 5;
     instance.ScoreUpdate();
     GlobalSingleton.Heal();
 }
Example #10
0
    void OnAction(Character _CharRef, Character _OtherRef, int _ChunkIndex, ActionKey _Action)
    {
        GlobalSingleton.DEBUG(_CharRef.name + "," + _ChunkIndex + "," + _Action);
        switch (_Action)
        {
        case ActionKey.Attack:
            _CharRef.DoChangeModel(_ChunkIndex, MODELTYPE.E_ATTACK);
            _CharRef.DoAction(_ChunkIndex, AnimationState.Attack, 1.2f);
            _CharRef.SetOpponentTarget(_ChunkIndex);

            _OtherRef.DoAction(_ChunkIndex, AnimationState.Hitted, 1.2f);
            _OtherRef.SetOpponentTarget(_ChunkIndex);
            break;

        case ActionKey.Defend:
            _CharRef.DoChangeModel(_ChunkIndex, MODELTYPE.E_DEFENSE);
            _OtherRef.ClearOpponentTarget(_ChunkIndex);
            // _CharRef.DoAction(_ChunkIndex, AnimationState.Defend, 2.0f);
            break;

        case ActionKey.Concentrate:
            _CharRef.DoChangeModel(_ChunkIndex, MODELTYPE.E_CONCENTRATE);
            _OtherRef.ClearOpponentTarget(_ChunkIndex);
            break;
        }
    }
Example #11
0
        public static void CreateWebAppFactory(string solutionDirectory, ApiTemplate template, Entity entity)
        {
            try
            {
                var classPath = ClassPathHelper.TestWebAppFactoryClassPath(solutionDirectory, $"CustomWebApplicationFactory.cs", template.SolutionName);

                if (!Directory.Exists(classPath.ClassDirectory))
                {
                    Directory.CreateDirectory(classPath.ClassDirectory);
                }

                if (File.Exists(classPath.FullClassPath))
                {
                    File.Delete(classPath.FullClassPath); // saves me from having to make a remover!
                }
                using (FileStream fs = File.Create(classPath.FullClassPath))
                {
                    var data = GetWebAppFactoryFileText(classPath, template, entity);
                    fs.Write(Encoding.UTF8.GetBytes(data));
                }

                GlobalSingleton.AddCreatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", ""));
            }
            catch (FileAlreadyExistsException e)
            {
                WriteError(e.Message);
                throw;
            }
            catch (Exception e)
            {
                WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                throw;
            }
        }
Example #12
0
        public static void CreateEntity(string solutionDirectory, Entity entity, IFileSystem fileSystem)
        {
            try
            {
                var classPath = ClassPathHelper.EntityClassPath(solutionDirectory, $"{entity.Name}.cs");

                if (!fileSystem.Directory.Exists(classPath.ClassDirectory))
                {
                    fileSystem.Directory.CreateDirectory(classPath.ClassDirectory);
                }

                if (fileSystem.File.Exists(classPath.FullClassPath))
                {
                    throw new FileAlreadyExistsException(classPath.FullClassPath);
                }

                using (var fs = fileSystem.File.Create(classPath.FullClassPath))
                {
                    var data = GetEntityFileText(classPath.ClassNamespace, entity);
                    fs.Write(Encoding.UTF8.GetBytes(data));
                }

                GlobalSingleton.AddCreatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{fileSystem.Path.DirectorySeparatorChar}", ""));
            }
            catch (FileAlreadyExistsException e)
            {
                WriteError(e.Message);
                throw;
            }
            catch (Exception e)
            {
                WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                throw;
            }
        }
        public static void SetIdentityOptions(string solutionDirectory, AuthSetup setup)
        {
            var classPath = ClassPathHelper.IdentityProjectPath(solutionDirectory, $"ServiceExtensions.cs");

            if (!Directory.Exists(classPath.ClassDirectory))
            {
                throw new DirectoryNotFoundException($"The `{classPath.ClassDirectory}` directory could not be found.");
            }

            if (!File.Exists(classPath.FullClassPath))
            {
                throw new FileNotFoundException($"The `{classPath.FullClassPath}` file could not be found.");
            }

            var tempPath = $"{classPath.FullClassPath}temp";

            using (var input = File.OpenText(classPath.FullClassPath))
            {
                using (var output = new StreamWriter(tempPath))
                {
                    string line;
                    while (null != (line = input.ReadLine()))
                    {
                        var newText = $"{line}";
                        if (line.Contains($"options.User.RequireUniqueEmail"))
                        {
                            newText = @$ "                options.User.RequireUniqueEmail = {setup.IdentityRequirements.RequireUniqueEmail.ToString().ToLower()};";
                        }
                        else if (line.Contains($"options.Password.RequiredLength"))
                        {
                            newText = @$ "                options.Password.RequiredLength = {setup.IdentityRequirements.RequiredLength};";
                        }
                        else if (line.Contains($"options.Password.RequireDigit"))
                        {
                            newText = @$ "                options.Password.RequireDigit = {setup.IdentityRequirements.RequireDigit.ToString().ToLower()};";
                        }
                        else if (line.Contains($"options.Password.RequireLowercase"))
                        {
                            newText = @$ "                options.Password.RequireLowercase = {setup.IdentityRequirements.RequireLowercase.ToString().ToLower()};";
                        }
                        else if (line.Contains($"options.Password.RequireUppercase"))
                        {
                            newText = @$ "                options.Password.RequireUppercase = {setup.IdentityRequirements.RequireUppercase.ToString().ToLower()};";
                        }
                        else if (line.Contains($"options.Password.RequireNonAlphanumeric"))
                        {
                            newText = @$ "                options.Password.RequireNonAlphanumeric = {setup.IdentityRequirements.RequireNonAlphanumeric.ToString().ToLower()};";
                        }

                        output.WriteLine(newText);
                    }
                }
            }

            // delete the old file and set the name of the new one to the original name
            File.Delete(classPath.FullClassPath);
            File.Move(tempPath, classPath.FullClassPath);

            GlobalSingleton.AddUpdatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", ""));
        }
Example #14
0
        public static void CreateController(string solutionDirectory, Entity entity, bool AddSwaggerComments)
        {
            try
            {
                var classPath = ClassPathHelper.ControllerClassPath(solutionDirectory, $"{Utilities.GetControllerName(entity.Plural)}.cs");

                if (!Directory.Exists(classPath.ClassDirectory))
                {
                    Directory.CreateDirectory(classPath.ClassDirectory);
                }

                if (File.Exists(classPath.FullClassPath))
                {
                    throw new FileAlreadyExistsException(classPath.FullClassPath);
                }

                using (FileStream fs = File.Create(classPath.FullClassPath))
                {
                    var data = GetControllerFileText(classPath.ClassNamespace, entity, AddSwaggerComments);
                    fs.Write(Encoding.UTF8.GetBytes(data));
                }

                GlobalSingleton.AddCreatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", ""));
            }
            catch (FileAlreadyExistsException e)
            {
                WriteError(e.Message);
                throw;
            }
            catch (Exception e)
            {
                WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                throw;
            }
        }
    void Update()
    {
        if (GlobalSingleton.GetHealth() < 0)
        {
            return;
        }

        if (hitCooldown > 0)
        {
            hitCooldown -= Time.deltaTime;
        }
        beat += GlobalSingleton.GetBPM() * 0.0166666666666f * Time.deltaTime;

        if (beat > DESTROY_BEAT + sustainLength)
        {
            NoteGenerator.RemoveNote(this);
            Destroy(gameObject);
            return;
        }

        if (beat > lateDistance && !playerMissed && !playerHit)
        {
            GlobalSingleton.GetShake().StartShake(0.5f, 0.1f);
            MissNote(0);
        }

        if (beat > lateDistance && lastNote)
        {
            lastNote = false;
            if (numMissed <= 0)
            {
                GlobalSingleton.IncreaseScore();
            }
            numMissed = 0;
        }

        if (beat >= COMPUTER_BEAT && !computerHit)
        {
            computerHit = true;
            StartCoroutine(PlayNote());
        }

        if (beat >= HIDDING_BEAT && !hideHit && hideNote)
        {
            hideHit = true;
            for (int i = 0; i < noteColors.Length; ++i)
            {
                StartCoroutine(HitchLib.Tweening.FadeTo(noteColors[i], 60f / GlobalSingleton.GetBPM(),
                                                        HitchLib.Easing.EASE_LINEAR, 0));
            }
            StartCoroutine(HitchLib.Tweening.FadeTo(keyText, 60f / GlobalSingleton.GetBPM(),
                                                    HitchLib.Easing.EASE_LINEAR, 0));
        }

        float   yPos = BEAT_PLAYER_Y - (beat * BEAT_SIZE);
        Vector3 pos  = rTrans.localPosition;

        pos.y = yPos * GlobalSingleton.GetTimelineScale();
        rTrans.localPosition = pos;
    }
Example #16
0
    public void DoAnimation(
        Character _CharRef,
        string _ChunkNode,
        int _ChunkIndex,
        AnimationState _NextState,
        float _DelayTime = 0.0f)
    {
        RootRef = _CharRef.gameObject;
        ChunkRef[_ChunkIndex] = GlobalSingleton.Find(_ChunkNode, true);
        Mesh_VoxelChunk Mesh      = _CharRef.mesh as Mesh_VoxelChunk;
        string          BoneIndex = "bone" + _ChunkIndex;

        // ChunkRef
        if (null != ChunkRef &&
            null != RootRef &&
            Mesh.Chunks.ContainsKey(BoneIndex))
        {
            ChunkMapRef[_ChunkIndex] = Mesh.Chunks[BoneIndex];
            // GlobalSingleton.DEBUG("Ready to change parent:"+ ChunkMapRef[_ChunkIndex].Count);

            foreach (GameObject go in ChunkMapRef[_ChunkIndex])
            {
                go.transform.SetParent(ChunkRef[_ChunkIndex].transform);
            }
        }

        ChangeAnimationState(_ChunkIndex, _NextState, _DelayTime, true);
    }
Example #17
0
        public static void CreateGitIgnore(string solutionDirectory)
        {
            try
            {
                var filePath = Path.Combine(solutionDirectory, ".gitignore");

                if (File.Exists(filePath))
                {
                    throw new FileAlreadyExistsException(filePath);
                }

                using (FileStream fs = File.Create(filePath))
                {
                    var data = "";
                    data = GetGitIgnoreFileText();
                    fs.Write(Encoding.UTF8.GetBytes(data));
                }

                GlobalSingleton.AddCreatedFile(filePath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", ""));
            }
            catch (FileAlreadyExistsException e)
            {
                WriteError(e.Message);
                throw;
            }
            catch (Exception e)
            {
                WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                throw;
            }
        }
Example #18
0
    void Update()
    {
        Vector3 scale = transform.localScale;

        scale.y = GlobalSingleton.GetTimelineScale();
        transform.localScale = scale;
    }
 public void ClickButton()
 {
     if (!hit)
     {
         hit = true;
         GlobalSingleton.GetFader().Fade(() => { SceneManager.LoadScene("Reload"); });
     }
 }
 public void ClickButton()
 {
     if (!hit)
     {
         hit = true;
         StartCoroutine(SubmitScore(username.SubmitName(), GlobalSingleton.GetScore()));
     }
 }
Example #21
0
 void Awake()
 {
     if (instance == null)
         instance = this;
     else
         Destroy(gameObject);
     Object.DontDestroyOnLoad(gameObject);
 }
Example #22
0
        private static void UpdateDtoFile(string solutionDirectory, string entityName, List <EntityProperty> props, Dto dto)
        {
            var dtoFileName = $"{Utilities.GetDtoName(entityName, dto)}.cs";
            var classPath   = ClassPathHelper.DtoClassPath(solutionDirectory, dtoFileName, entityName);

            if (!Directory.Exists(classPath.ClassDirectory))
            {
                throw new DirectoryNotFoundException($"The `{classPath.ClassDirectory}` directory could not be found.");
            }

            if (!File.Exists(classPath.FullClassPath))
            {
                throw new FileNotFoundException($"The `{classPath.FullClassPath}` file could not be found.");
            }

            var tempPath = $"{classPath.FullClassPath}temp";

            using (var input = File.OpenText(classPath.FullClassPath))
            {
                using (var output = new StreamWriter(tempPath))
                {
                    string line;
                    var    fkUsingStatements = "";

                    if (dto == Dto.Read)
                    {
                        foreach (var prop in props)
                        {
                            if (prop.IsForeignKey)
                            {
                                fkUsingStatements += DtoFileTextGenerator.GetForeignKeyUsingStatements(classPath, fkUsingStatements, prop, dto);
                            }
                        }
                    }

                    while (null != (line = input.ReadLine()))
                    {
                        var newText = $"{line}";
                        if (line.Contains($"add-on property marker"))
                        {
                            newText += @$ "{Environment.NewLine}{Environment.NewLine}{DtoFileTextGenerator.DtoPropBuilder(props, dto)}";
                        }
                        if (line.Contains("using System;"))
                        {
                            newText += fkUsingStatements;
                        }

                        output.WriteLine(newText);
                    }
                }
            }

            // delete the old file and set the name of the new one to the original name
            File.Delete(classPath.FullClassPath);
            File.Move(tempPath, classPath.FullClassPath);

            GlobalSingleton.AddUpdatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", ""));
        }
 public void ButtonUp()
 {
     if (aniCor != null)
     {
         StopCoroutine(aniCor);
     }
     aniCor = StartCoroutine(HitchLib.Tweening.GenericTween(new Action <float>(AnimateAlpha), onOpacity, offOpacity, 0.25f, HitchLib.Easing.EASE_LINEAR));
     GlobalSingleton.GetSound().NoteOff(id);
 }
    // Corutines:

    private IEnumerator PlayNote()
    {
        ComputerButton.GetButton(id).ButtonDown();
        GlobalSingleton.GetSound().NoteOn(id);
        yield return(new WaitForSeconds(((sustainLength + 0.25f) * 60f) / GlobalSingleton.GetBPM()));

        GlobalSingleton.GetSound().NoteOff(id);
        ComputerButton.GetButton(id).ButtonUp();
    }
    // Messages:

    void Start()
    {
        for (int i = 0; i <= GlobalSingleton.GetScore(); ++i)
        {
            notes.Add(GenerateNote(i));
        }
        liveNotes = new List <NoteController>();
        NoteController.numMissed = 0;
    }
Example #26
0
        public static void RegisterSwaggerInStartup(string solutionDirectory, ApiEnvironment env)
        {
            try
            {
                var classPath = ClassPathHelper.StartupClassPath(solutionDirectory, $"{Utilities.GetStartupName(env.EnvironmentName)}.cs");

                if (!Directory.Exists(classPath.ClassDirectory))
                {
                    throw new DirectoryNotFoundException($"The `{classPath.ClassDirectory}` directory could not be found.");
                }

                if (!File.Exists(classPath.FullClassPath))
                {
                    throw new FileNotFoundException($"The `{classPath.FullClassPath}` file could not be found.");
                }

                var tempPath = $"{classPath.FullClassPath}temp";
                using (var input = File.OpenText(classPath.FullClassPath))
                {
                    using (var output = new StreamWriter(tempPath))
                    {
                        string line;
                        while (null != (line = input.ReadLine()))
                        {
                            var newText = $"{line}";
                            if (line.Contains("#region Dynamic Services"))
                            {
                                newText += $"{Environment.NewLine}            services.AddSwaggerExtension();";
                            }
                            else if (line.Contains("#region Dynamic App"))
                            {
                                newText += $"{Environment.NewLine}            app.UseSwaggerExtension();";
                            }

                            output.WriteLine(newText);
                        }
                    }
                }

                // delete the old file and set the name of the new one to the original name
                File.Delete(classPath.FullClassPath);
                File.Move(tempPath, classPath.FullClassPath);

                GlobalSingleton.AddUpdatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", ""));
            }
            catch (FileAlreadyExistsException e)
            {
                WriteError(e.Message);
                throw;
            }
            catch (Exception e)
            {
                WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                throw;
            }
        }
        public static void AddPolicies(string solutionDirectory, List <Policy> policies)
        {
            var classPath = ClassPathHelper.InfrastructureIdentityProjectRootClassPath(solutionDirectory, $"ServiceRegistration.cs");

            if (!Directory.Exists(classPath.ClassDirectory))
            {
                Directory.CreateDirectory(classPath.ClassDirectory);
            }

            if (!File.Exists(classPath.FullClassPath))
            {
                throw new FileNotFoundException($"The `{classPath.FullClassPath}` file could not be found.");
            }

            var policiesString = "";

            foreach (var policy in policies)
            {
                policiesString += $@"{Environment.NewLine}{Utilities.PolicyStringBuilder(policy)}";
            }

            var tempPath = $"{classPath.FullClassPath}temp";

            using (var input = File.OpenText(classPath.FullClassPath))
            {
                using (var output = new StreamWriter(tempPath))
                {
                    string line;
                    bool   updateNextLine = false;
                    while (null != (line = input.ReadLine()))
                    {
                        var newText = $"{line}";
                        if (line.Contains($"AddAuthorization"))
                        {
                            updateNextLine = true;
                        }
                        else if (updateNextLine)
                        {
                            newText       += policiesString;
                            updateNextLine = false;
                        }

                        output.WriteLine(newText);
                    }
                }
            }

            // delete the old file and set the name of the new one to the original name
            File.Delete(classPath.FullClassPath);
            File.Move(tempPath, classPath.FullClassPath);

            GlobalSingleton.AddUpdatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", ""));
        }
Example #28
0
 void Awake()
 {
     if (_instance == null) {
         _instance = this;
         DontDestroyOnLoad( this);
     }
     else{
         if(this != _instance){
             Destroy(this.gameObject);
         }
     }
 }
Example #29
0
    // Messages:

    void Update()
    {
        cooldown -= Time.deltaTime * GlobalSingleton.GetBPM() * 0.0166666666f;
        if (cooldown < 0)
        {
            while (cooldown < 0)
            {
                cooldown += 1;
            }
            GlobalSingleton.GetSound().PlaySound(click);
        }
    }
Example #30
0
        public static void Run(string filePath, string buildSolutionDirectory, IFileSystem fileSystem)
        {
            try
            {
                GlobalSingleton instance = GlobalSingleton.GetInstance();

                FileParsingHelper.RunInitialTemplateParsingGuards(filePath);
                var template = FileParsingHelper.GetTemplateFromFile <MicroTemplate>(filePath);
                WriteHelpText($"Your template file was parsed successfully.");

                foreach (var micro in template.Microservices)
                {
                    FileParsingHelper.RunPrimaryKeyGuard(micro.Entities);
                }
                FileParsingHelper.RunSolutionNameAssignedGuard(template.SolutionName);

                // solution level stuff
                var solutionDirectory = $"{buildSolutionDirectory}{Path.DirectorySeparatorChar}{template.SolutionName}";
                var srcDirectory      = Path.Combine(solutionDirectory, "src");
                fileSystem.Directory.CreateDirectory(srcDirectory);
                SolutionBuilder.BuildSolution(srcDirectory, template.SolutionName, fileSystem);

                // add all files based on the given template config
                RunMicroTemplateBuilders(srcDirectory, template.Microservices, template.Gateways, fileSystem);

                ReadmeBuilder.CreateReadme(solutionDirectory, template.SolutionName, fileSystem);
                if (template.AddGit)
                {
                    GitSetup(solutionDirectory);
                }

                WriteFileCreatedUpdatedResponse();
                WriteHelpHeader($"{Environment.NewLine}Your API is ready! Build something amazing.");
                StarGithubRequest();
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException ||
                    e is EntityNotFoundException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                }
            }
        }
Example #31
0
    Mesh_VoxelChunk Load(string filename)
    {
        string    filepath  = s_Path + filename;
        TextAsset textAsset = Resources.Load(filepath) as TextAsset;

        if (!textAsset)
        {
            GlobalSingleton.ERROR("Load file failed : " + filepath);
            return(null);
        }
        return(new Mesh_VoxelChunk(textAsset.text));
    }
Example #32
0
        private static void AddSwaggerServiceExtension(string solutionDirectory, ApiTemplate template)
        {
            try
            {
                var classPath = ClassPathHelper.WebApiExtensionsClassPath(solutionDirectory, $"ServiceExtensions.cs");

                if (!Directory.Exists(classPath.ClassDirectory))
                {
                    throw new DirectoryNotFoundException($"The `{classPath.ClassDirectory}` directory could not be found.");
                }

                if (!File.Exists(classPath.FullClassPath))
                {
                    throw new FileNotFoundException($"The `{classPath.FullClassPath}` file could not be found.");
                }

                var tempPath = $"{classPath.FullClassPath}temp";
                using (var input = File.OpenText(classPath.FullClassPath))
                {
                    using (var output = new StreamWriter(tempPath))
                    {
                        string line;
                        while (null != (line = input.ReadLine()))
                        {
                            var newText = $"{line}";
                            if (line.Contains("#region Swagger Region"))
                            {
                                newText += GetSwaggerServiceExtensionText(template);
                            }

                            output.WriteLine(newText);
                        }
                    }
                }

                // delete the old file and set the name of the new one to the original name
                File.Delete(classPath.FullClassPath);
                File.Move(tempPath, classPath.FullClassPath);

                GlobalSingleton.AddUpdatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", ""));
            }
            catch (FileAlreadyExistsException e)
            {
                WriteError(e.Message);
                throw;
            }
            catch (Exception e)
            {
                WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                throw;
            }
        }
Example #33
0
 // Use this for initialization
 void Start()
 {
     singleton = GameObject.FindGameObjectWithTag ("DontDestroy");
     sS = singleton.GetComponent<GlobalSingleton> ();
     if(sS.inMenu){
         player.SetActive(true);
         managers.SetActive(true);
         return;
     }
     cam = Camera.main.GetComponent<camera>();
     StartCoroutine(WaitToBegin());
     //	Debug.Log("start");
 }
Example #34
0
    // Use this for initialization
    void Start()
    {
        singleton = GameObject.FindGameObjectWithTag ("DontDestroy");
        sS = singleton.GetComponent<GlobalSingleton> ();

        scoreText = GetComponentInChildren<TextMesh> ();
        redirectObj = GameObject.Find ("redirectParticles");

        rediChargeParticleObject = GameObject.FindGameObjectWithTag ("rediChargeParticles");
        rediChargeParticles = rediChargeParticleObject.GetComponent<ParticleSystem> ();

        if (!GlobalSingleton.instance.inMenu) {
            scoreParticles.loop = true;
            scoreParticles.Play();
        }
        else{
            scoreParticles.loop = false;
            scoreParticles.Play();
        }
    }
Example #35
0
    // Use this for initialization
    void Start()
    {
        singleton = GameObject.FindGameObjectWithTag ("DontDestroy");
        sS = singleton.GetComponent<GlobalSingleton> ();

        ownParticles = GetComponentInChildren<ParticleSystem> ();
        particleColor = ownParticles.startColor;
        ownParticles.Play ();

        player = GameObject.FindGameObjectWithTag ("Player");
        trail = GetComponent<TrailRenderer> ();
        playerS = player.GetComponent<playerMovement> ();
        if(!sS.inMenu){
            bulletManager = GameObject.FindGameObjectWithTag ("BulletManager");
            timerStart = bulletManager.GetComponent<BulletManager> ().bulletTimer;

        }
        timer = timerStart;
    }
Example #36
0
    // Use this for initialization
    void Start()
    {
        singleton = GameObject.FindGameObjectWithTag ("DontDestroy");
        sS = singleton.GetComponent<GlobalSingleton> ();

        lifeText = lifeTextObject.GetComponent<TextMesh> ();

        Reset ();

        foreach(ParticleSystem p in lifeParticles){
            p.gameObject.SetActive(true);
        }
        initLightColor = lifeParticles [0].startColor;

        if(!sS.inMenu){
            lifeText.text = "";
        }
    }