//331 288
        public void LoadHero(int heroIndex, Heroes3Master master)
        {
            HeroIndex = heroIndex;
            Hero      = null;
            if (heroIndex > -1 && heroIndex < HeroesManager.HeroesOrder.Length && master != null)
            {
                var hs = HeroesManager.AllHeroes[heroIndex];

                var bckgImage = HeroesManager.GetBackground(master);

                var canvas = new Bitmap(bckgImage);

                var g = Graphics.FromImage(canvas);

                /*    g.InterpolationMode = InterpolationMode.High;
                 *  g.SmoothingMode = SmoothingMode.HighQuality;
                 *  g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                 *  g.CompositingQuality = CompositingQuality.HighQuality;*/

                g.DrawImage(bckgImage, Point.Empty);

                var portrait = master.ResolveWith(HeroesManager.HeroesOrder[hs.ImageIndex]).GetBitmap();
                g.DrawImage(portrait, new Point(4, 3));

                var heroData = HeroExeData.Data[heroIndex];

                var z = Speciality.GetImage(master, heroData.Index);
                g.DrawImage(z, new Point(4, 166));

                Hero = heroData;
                if (heroData.Skill1 != null)
                {
                    g.DrawImage(heroData.Skill1.GetImage(master, heroData.FirstSkillLevel), new Point(5, 213));
                }

                if (heroData.Skill2 != null)
                {
                    g.DrawImage(heroData.Skill2.GetImage(master, heroData.SecondSkillLevel), new Point(148, 213));
                }

                var img1 = CreatureManager.GetImage(master, heroData.Unit1Index);
                g.DrawImage(img1, new Point(5, 262));
                var img2 = CreatureManager.GetImage(master, heroData.Unit2Index);
                g.DrawImage(img2, new Point(68, 262));
                var img3 = CreatureManager.GetImage(master, heroData.Unit3Index);
                g.DrawImage(img3, new Point(129, 262));

                if (heroData.Spell != null)
                {
                    g.DrawImage(heroData.Spell.GetImage(master), 192, 262);
                }

                DrawData(g, heroData);


                //heroData.Class.Stats

                /*
                 *  g.DrawImage(ps.GetSprite(0), new Point(18, 97));
                 *  g.DrawImage(ps.GetSprite(1), new Point(88, 97));
                 *  g.DrawImage(ps.GetSprite(2), new Point(158, 97));
                 *  g.DrawImage(ps.GetSprite(5), new Point(228, 97));
                 */
                g.Dispose();
                PictureBox.Image = canvas;
                CalculateRatio();
            }
        }
 private static void LoadOriginalSpecs(byte[] raw, int offset)
 {
     OriginalSpecs = Speciality.LoadInfo(raw, offset);
 }
        private void PictureBox_MouseClick(object sender, MouseEventArgs e)
        {
            if (Hero != null && HeroIndex >= 0 && lastRectIndex >= 0 && PropertyClicked != null)
            {
                if (e.Button == MouseButtons.Left)
                {
                    ProfilePropertyType type = ProfilePropertyType.Other;
                    int index        = 0;
                    int currentValue = 0;

                    if (lastRectIndex == 0)
                    {
                        //type = "Portrait";
                        return;
                    }
                    else if (lastRectIndex == 1)
                    {
                        //type = "Name";
                        return;
                    }
                    else if (lastRectIndex == 2)
                    {
                        type         = Speciality.ToProfilePropertyType(Hero.Spec.Type);
                        currentValue = Hero.Spec.ObjectId;
                    }
                    else if (lastRectIndex <= 4)
                    {
                        type         = ProfilePropertyType.SecondarySkill;
                        index        = lastRectIndex - 3;
                        currentValue = (index == 0 ? (3 * Hero.FirstSkillIndex + Hero.FirstSkillLevel) : (3 * Hero.SecondSkillIndex + Hero.SecondSkillLevel)) - 1;
                    }
                    else if (lastRectIndex <= 7)
                    {
                        type         = ProfilePropertyType.Creature;
                        index        = lastRectIndex - 5;
                        currentValue = index == 0 ? Hero.Unit1Index : (index == 1 ? Hero.Unit2Index : Hero.Unit3Index);
                    }
                    else if (lastRectIndex == 8)
                    {
                        type         = ProfilePropertyType.Spell;
                        currentValue = Hero.SpellIndex;
                    }
                    else if (lastRectIndex == 9)
                    {
                        type = ProfilePropertyType.HeroClass;
                    }

                    PropertyClicked(Hero.Index, type, index, currentValue);
                }
                else if (e.Button == MouseButtons.Right)
                {
                    if (lastRectIndex == 0)
                    {
                    }
                    else if (lastRectIndex == 1)
                    {
                    }
                    else if (lastRectIndex == 2)
                    {
                    }
                    else if (lastRectIndex <= 4)
                    {
                        if (lastRectIndex == 3)
                        {
                            if (Hero.SecondSkillIndex != -1)
                            {
                                Hero.FirstSkillIndex  = Hero.SecondSkillIndex;
                                Hero.FirstSkillLevel  = Hero.SecondSkillLevel;
                                Hero.SecondSkillIndex = -1;
                            }
                            else
                            {
                                Hero.FirstSkillIndex = -1;
                            }
                        }
                        else
                        {
                            Hero.SecondSkillIndex = -1;
                        }
                        LoadHero(Hero.Index, Heroes3Master.Master);
                    }
                    else if (lastRectIndex <= 7)
                    {
                        /*  type = "Creature";
                         * index = lastRectIndex - 5;
                         * currentValue = index == 0 ? Hero.Unit1Index : (index == 1 ? Hero.Unit2Index : Hero.Unit3Index);*/
                    }
                    else if (lastRectIndex == 8)
                    {
                        Hero.SpellBook  = 0;
                        Hero.SpellIndex = -1;
                        LoadHero(Hero.Index, Heroes3Master.Master);
                    }
                }
            }
        }
Пример #4
0
        private void HeroPropertyForm_ItemSelected(int selIndex, int arg1, int arg2, int arg3)
        {
            ProfilePropertyType type = heroPropertyForm.PropertyType;
            var hpcHeroProfile       = heroMainDataControl.HeroProfileControl;
            var hero = hpcHeroProfile.Hero;

            if (type == ProfilePropertyType.Creature)
            {
                int realIndex = CreatureManager.OnlyActiveCreatures[selIndex].CreatureIndex;
                hero.HasChanged = true;
                switch (heroPropertyForm.CurrentIndex)
                {
                case 0: hero.Unit1Index = realIndex; break;

                case 1: hero.Unit2Index = realIndex; break;

                case 2: hero.Unit3Index = realIndex; break;
                }
                hpcHeroProfile.LoadHero(hpcHeroProfile.HeroIndex, Heroes3Master.Master);
            }
            else if (type == ProfilePropertyType.SecondarySkill)
            {
                int skill = selIndex / 3;
                int level = 1 + selIndex % 3;

                hero.HasChanged = true;
                if (heroPropertyForm.CurrentIndex == 0)
                {
                    hero.FirstSkillIndex = skill;
                    hero.FirstSkillLevel = level;
                }
                else
                {
                    hero.SecondSkillIndex = skill;
                    hero.SecondSkillLevel = level;
                }
                hpcHeroProfile.LoadHero(hpcHeroProfile.HeroIndex, Heroes3Master.Master);
            }
            else if (type == ProfilePropertyType.Spell)
            {
                hero.HasChanged = true;
                hero.SpellBook  = 1;
                hero.SpellIndex = selIndex;
                hpcHeroProfile.LoadHero(hpcHeroProfile.HeroIndex, Heroes3Master.Master);
            }
            else
            {
                var specType = Speciality.FromProfileProperty(type);
                if (specType != SpecialityType.Invalid)
                {
                    Speciality.UpdateSpecialityData(specType, hero.Index, selIndex, arg1, arg2, arg3);
                    hero.HasChanged = true;

                    var hs = HeroesManager.AllHeroes[hero.Index];
                    SpecialityBuilder.TryUpdateSpecialityImageAndText(Heroes3Master.Master, hero);
                    heroMainDataControl.Speciality = hs.Speciality;

                    HeroesManager.AnyChanges = true;
                    hpcHeroProfile.LoadHero(hpcHeroProfile.HeroIndex, Heroes3Master.Master);
                }
                //hpcHeroProfile
            }
        }