Пример #1
0
        public static string Bulid(HttpContext context)
        {
            bool value = false;
            string message = "Fail!";
            XElement result = new XElement("Result");

            try
            {

                using (ProduceBussiness db = new ProduceBussiness())
                {
                    BallInfo[] infos = db.GetAllBall();
                    foreach (BallInfo info in infos )
                    {
                        result.Add(Road.Flash.FlashUtils.CreateBallInfo(info));
                    }
                }

                value = true;
                message = "Success!";
            }
            catch (Exception ex)
            {
                log.Error("BallList", ex);
            }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));

            //return result.ToString(false);
            return csFunction.CreateCompressXml(context, result, "BallList", true);
        }
Пример #2
0
 private static Dictionary<int, BallInfo> LoadFromDatabase()
 {
     Dictionary<int, BallInfo> list = new Dictionary<int, BallInfo>();
     using (ProduceBussiness db = new ProduceBussiness())
     {
         BallInfo[] ballInfos = db.GetAllBall();
         foreach (BallInfo b in ballInfos)
         {
             if (!list.ContainsKey(b.ID))
             {
                 list.Add(b.ID, b);
             }
         }
     }
     return list;
 }
Пример #3
0
        private static bool LoadBall(Dictionary<int, BallInfo> balls,Dictionary<int, Tile> ballTile)
        {
            using (ProduceBussiness db = new ProduceBussiness())
            {
                BallInfo[] ballInfos = db.GetAllBall();
                foreach (BallInfo b in ballInfos)
                {
                    if (!balls.ContainsKey(b.ID))
                    {
                        balls.Add(b.ID, b);

                        Tile shape = null;
                        string file = string.Format("bomb\\{0}.bomb", b.ID);
                        if (File.Exists(file))
                        {
                            shape = new Tile(file,false);
                        }

                        if (shape != null)
                        {
                            ballTile.Add(b.ID, shape);
                        }
                        else
                        {
                            if (b.ID != 1 && b.ID != 2 && b.ID != 3)
                            {
                                if (log.IsErrorEnabled)
                                    log.Error("Ball's file is not exist!");
                                return false;
                            }
                        }
                    }
                }
            }

            if (!balls.ContainsKey(0))
            {
                BallInfo temp = new BallInfo();
                temp.ID = 0;
                temp.Power = 1;
                temp.Radii = 60;
                temp.Amount = 1;
                balls.Add(0, temp);
            }

            return true;
        }