Exemplo n.º 1
0
        public void SavePlayerSkillsActive(Bitmap bitmap)
        {
            Directory.CreateDirectory($"{OutputDirectoryDated}/Skill");

            for (int i = 0; i < 6; i++)
            {
                var skill = cropWindowService.CropSkillActive(bitmap, i);

                skill.Save($"{OutputDirectoryDated}/Skill{i}_Active.png");
            }
        }
        private Skill ExtractSkill(Bitmap picturePart, int index, Bitmap fullBitmap)
        {
            foreach (var skillName in modelService.PossibleSkills())
            {
                var template            = resourceService.LoadSkillBitmap(skillName, index >= 4);
                var similiaryPercentage = ImageHelper.Compare(picturePart, template);

                // If similarityPercentage is > some value but not 1, then it must either be on not
                // castable (due to resources / cooldown) or it is active
                if (similiaryPercentage > 0.95f)
                {
                    var skill = new Skill {
                        Name = skillName, Index = index
                    };

                    if (similiaryPercentage >= 0.999f)
                    {
                        skill.CanBeCasted = true;

                        skill.IsActive = IsActive(imageService.CropSkillActive(fullBitmap, index), index);

                        if (skill.IsActive)
                        {
                            Trace.WriteLine($"{skillName} is active!");
                        }
                        // logService.AddEntry(this, $"Skill{index} is {skillName}.", LogLevel.Debug);
                    }

                    return(skill);
                }
            }

            // logService.AddEntry(this, $"Couldn't identify Skill{index}.", LogLevel.Debug);

            return(null);
        }