Example #1
0
        private static BaseObject[] _objs; //все объекты на экране
        public static void Load()
        {
            Random r = new Random();
            int    radius; //радиус больших планет

            _objs = new BaseObject[84];
            for (int i = 0; i < 10; i++) //мигающие звезды
            {
                _objs[i] = new BlinkStar(new Point(r.Next(0, Game.Width), r.Next(0, Game.Height)), new Point(r.Next(4), 0), new Size(7, 7));
            }

            for (int i = 10; i < 20; i++)  //маленькие звезды
            {
                _objs[i] = new Star(new Point(r.Next(Game.Width), r.Next(Game.Height)), new Point(r.Next(5), r.Next(-1, 1)), new Size(5, 5));
            }

            for (int i = 20; i < _objs.Length - 4; i++) //точки
            {
                _objs[i] = new SmallPoint(new Point(r.Next(Game.Width), r.Next(Game.Height)), new Point(r.Next(3), 0), new Size(2, 2));
            }

            radius    = r.Next(20, 100); //Средняя планета
            _objs[80] = new BigPoint(new Point(r.Next(20, Game.Width - 20), r.Next(20, Game.Height - 20)), new Point(r.Next(3), 0), new Size(radius, radius), r.Next(5));

            //Корабль
            _objs[81] = new SpaceShip(new Point(50, Game.Height / 2), new Point(0, 2), new Size(30, 30));

            //Пуля
            _objs[82] = new Bullet(new Point(75, Game.Height / 2), new Point(-4, 0), new Size(5, 3));

            //Астероид
            _objs[83] = new Asteroid(new Point(650, Game.Height / 2 - 25), new Point(3, 0), new Size(50, 50), 20);
            //Астероид для проверки собственного Exception - слишком большой размер обьекта
            //_objs[83] = new Asteroid(new Point(650, Game.Height / 2 - 25), new Point(3, 0), new Size(171, 171), 20);
        }
        public JsonResult AddSmallPoint(string Name, string PointID, string Score, string Status, string KeyValue, int isdefault)
        {
            SmallPoint p = new SmallPoint();
            p.Name = Name;
            p.PointID = Int32.Parse(PointID);
            p.Score = double.Parse(Score);
            p.Status = Int32.Parse(Status);
            p.KeyValue = KeyValue;
            p.IsDefault = isdefault;

            try
            {
                new SmallPointDao().Insert(p);
            }
            catch (Exception e)
            {
                return Json(e.Message);
            }
            return Json("插入成功");
        }