Esempio n. 1
0
 /// <summary>
 /// 按照数目随机取,若项目可以重叠,则重叠,否则添加
 /// </summary>
 /// <param name="item"></param>
 /// <param name="ls"></param>
 /// <returns></returns>
 public static List <PoolContent> FoldItem(PoolContent item, List <PoolContent> ls)
 {
     if (!item.CanBeFolded)
     {
         item.Count = new Random(GetRandomSeed()).Next(item.MinNumber, item.MaxNumber + 1);
         ls.Add(item);
         return(ls);
     }
     else
     {
         item.Count = new Random(GetRandomSeed()).Next(item.MinNumber, item.MaxNumber + 1);
         if (ls.Where(x => x.Name == item.Name).Count() == 0)
         {
             ls.Add(item);
         }
         else
         {
             ls.Where(x => x.Name == item.Name).FirstOrDefault().Count += item.Count;
         }
         return(ls);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 合成装备卡图片
        /// </summary>
        public Image GenerateCard(PoolContent pc)
        {
            Image background = Image.FromFile(pc.BoardPath);
            Image main;

            try
            {
                //为了美观,需要先生成卡内容,再生成框
                //读取卡主要内容
                main = Image.FromFile(pc.PicPath);
                //备份框内容,准备覆盖
                Image background_backup = (Image)background.Clone();
                background = CombinImage(background, main, 4, 10, 198, 198);
                background = CombinImage(background, background_backup, 0, 0);
            }
            catch (FileNotFoundException)
            {
                //未找到图片
                main = Image.FromFile($@"{dir}装备卡\框\ItemEmpty #1004496.png");
                //读取后台群
                ini = new IniConfig(dir + "Config.ini"); ini.Load();
                long groupid = ini.Object["后台群"]["Id"].GetValueOrDefault((long)0);
                //发送错误信息
                if (groupid != 0)
                {
                    CQSave.cq_group.CQApi.SendGroupMessage(groupid, $"发现图片缺失,请排查是否为命名错误 输入的图片路径={pc.PicPath} 名称={pc.Name}");
                }
                background = CombinImage(background, main, 48, 13, 119, 172);
            }
            //显示评级,不显示个数和星级
            if (pc.Displaymode1 == "显示评级")
            {
                Image img = Image.FromFile(pc.BigIcon);
                background = CombinImage(background, img, 53, 160, 106, 91);
                return(background);
            }
            else//显示个数及星级
            {
                Point  p     = new Point(103, 225);
                Font   font  = new Font("Impact", 25F);
                Color  color = Color.FromArgb(67, 67, 67);
                string text  = (pc.Displaymode2 == "显示个数") ? $"×{pc.Count}" : $"Lv.{pc.Level}";
                background = AddText2Image(background, text, p, font, color);
            }
            //绘制星星
            string str = "";

            for (int i = 0; i < pc.StarCount; i++)
            {
                str += "1";
            }
            for (int i = 0; i < pc.EmptyStarCount; i++)
            {
                str += "0";
            }
            char[] ch   = str.ToCharArray();
            int    trap = 26;

            //奇数与偶数的位置不同
            if (str.Length % 2 == 0)
            {
                int x = 103 - (str.Length / 2) * trap; int y = 171;
                for (int i = 0; i < str.Length; i++)
                {
                    Image img;
                    if (ch[i] == '1')
                    {
                        img = Image.FromFile($@"{dir}装备卡\框\StarBig #1916506.png");
                    }
                    else
                    {
                        img = Image.FromFile($@"{dir}装备卡\框\StarBigGray.png");
                    }
                    background = CombinImage(background, img, x, y, 33, 33);
                    x         += trap;
                }
            }
            else
            {
                int x = 90 - (str.Length / 2) * trap; int y = 171;
                for (int i = 0; i < str.Length; i++)
                {
                    Image img;
                    if (ch[i] == '1')
                    {
                        img = Image.FromFile($@"{dir}装备卡\框\StarBig #1916506.png");
                    }
                    else
                    {
                        img = Image.FromFile($@"{dir}装备卡\框\StarBigGray.png");
                    }
                    background = CombinImage(background, img, x, y, 33, 33);
                    x         += trap;
                }
            }
            return(background);
        }