Exemplo n.º 1
0
 public AProjectile(Projectile proj)
 {
     Type = proj.Type;
     X = proj.X;
     Y = proj.Y;
     Speed = new Point(proj.SpeedX, proj.SpeedY);
     Radius = proj.Radius;
 }
Exemplo n.º 2
0
        public ATile(int i, int j, TileType type)
            : base(i, j)
        {
            Type = type;

            IsFreeLeft = _tileFreeLeft(type);
            IsFreeRight = _tileFreeRight(type);
            IsFreeTop = _tileFreeTop(type);
            IsFreeBottom = _tileFreeBottom(type);

            var margin = Const.TileMargin;

            var sy = new Point(0, margin);
            var sx = new Point(margin, 0);
            var ly = new Point(0, Const.TileSize);
            var lx = new Point(Const.TileSize, 0);

            var res = new List<TilePart>();

            switch (type)
            {
                    // Левый верхний угол
                case TileType.LeftHeadedT:
                case TileType.TopHeadedT:
                case TileType.RightBottomCorner:
                case TileType.Crossroads:
                case TileType.Unknown:
                    res.Add(TilePart.GetCircle(Point.Zero, margin));
                    break;
            }

            switch (type)
            {
                    // Правый верхний угол
                case TileType.RightHeadedT:
                case TileType.TopHeadedT:
                case TileType.LeftBottomCorner:
                case TileType.Crossroads:
                case TileType.Unknown:
                    res.Add(TilePart.GetCircle(lx, margin));
                    break;
            }

            switch (type)
            {
                    // Правый нижний угол
                case TileType.BottomHeadedT:
                case TileType.RightHeadedT:
                case TileType.LeftTopCorner:
                case TileType.Crossroads:
                case TileType.Unknown:
                    res.Add(TilePart.GetCircle(lx + ly, margin));
                    break;
            }

            switch (type)
            {
                    // Левый нижний угол
                case TileType.BottomHeadedT:
                case TileType.LeftHeadedT:
                case TileType.RightTopCorner:
                case TileType.Crossroads:
                case TileType.Unknown:
                    res.Add(TilePart.GetCircle(ly, margin));
                    break;
            }

            switch (type)
            {
                    // Верхняя полоса
                case TileType.BottomHeadedT:
                case TileType.Horizontal:
                case TileType.LeftTopCorner:
                case TileType.RightTopCorner:
                    res.Add(TilePart.GetSegment(sy, lx + sy));
                    break;
            }
            switch (type)
            {
                    // Нижняя полоса
                case TileType.TopHeadedT:
                case TileType.Horizontal:
                case TileType.LeftBottomCorner:
                case TileType.RightBottomCorner:
                    res.Add(TilePart.GetSegment(ly - sy, lx + ly - sy));
                    break;
            }
            switch (type)
            {
                    // Левая полоса
                case TileType.RightHeadedT:
                case TileType.Vertical:
                case TileType.LeftBottomCorner:
                case TileType.LeftTopCorner:
                    res.Add(TilePart.GetSegment(sx, ly + sx));
                    break;
            }
            switch (type)
            {
                    // Правая полоса
                case TileType.LeftHeadedT:
                case TileType.Vertical:
                case TileType.RightBottomCorner:
                case TileType.RightTopCorner:
                    res.Add(TilePart.GetSegment(lx - sx, lx + ly - sx));
                    break;
            }

            var dx = Const.TileSize*j;
            var dy = Const.TileSize*i;
            foreach (var part in res)
            {
                if (part.Type == TilePartType.Circle)
                {
                    part.Circle.X += dx;
                    part.Circle.Y += dy;
                }
                else
                {
                    part.Start.X += dx;
                    part.Start.Y += dy;
                    part.End.X += dx;
                    part.End.Y += dy;

                    if (Geom.VectorProduct(part.Start, part.End, MyStrategy.GetCenter(i, j)) > 0)
                    {
                        var tmp = part.Start;
                        part.Start = part.End;
                        part.End = tmp;
                    }
                }
            }
            Parts = res.ToArray();
        }
Exemplo n.º 3
0
 public static TilePart GetSegment(Point s, Point t)
 {
     return new TilePart
     {
         Type = TilePartType.Segment,
         Start = s,
         End = t
     };
 }
Exemplo n.º 4
0
 public static TilePart GetCircle(Point cen, double r)
 {
     return new TilePart
     {
         Type = TilePartType.Circle,
         Circle = new ACircularUnit
         {
             Radius = r,
             X = cen.X,
             Y = cen.Y
         }
     };
 }