Exemplo n.º 1
0
            protected override void OnUpdate()
            {
                if (Position.X < 0)
                {
                    velocity = new Vector2DF(4, 0);
                }
                else if (Position.X > 600)
                {
                    velocity = new Vector2DF(-4, 0);
                }
                Angle += 1;

                var collisionsInfo = Collisions2DInfo;

                foreach (var collisionInfo in collisionsInfo)
                {
                    switch (collisionInfo.CollisionType)
                    {
                    case CollisionType.Enter:
                        Console.WriteLine("Enter: " + collisionInfo.SelfCollider.Tag);
                        break;

                    case CollisionType.Stay:
                        break;

                    case CollisionType.Exit:
                        Console.WriteLine("Exit: " + collisionInfo.SelfCollider.Tag);
                        break;
                    }
                }
            }
Exemplo n.º 2
0
            public LaneEffect(Controller controller, int lane_number)
            {
                Controller = controller;
                LaneNumber = lane_number;

                switch (lane_number)
                {
                case 1: Texture = Engine.Graphics.CreateTexture2D("Graphics/LaneEffect_R.png"); break;

                case 2: Texture = Engine.Graphics.CreateTexture2D("Graphics/LaneEffect_Y.png"); break;

                case 3: Texture = Engine.Graphics.CreateTexture2D("Graphics/LaneEffect_G.png"); break;

                case 4: Texture = Engine.Graphics.CreateTexture2D("Graphics/LaneEffect_B.png"); break;

                case 5: Texture = Engine.Graphics.CreateTexture2D("Graphics/LaneEffect_O.png"); break;
                }

                CenterPosition = new Vector2DF(0, Texture.Size.Y);

                switch (lane_number)
                {
                case 1: Position = new Vector2DF(259, 519); break;

                case 2: Position = new Vector2DF(208, 519); break;

                case 3: Position = new Vector2DF(157, 519); break;

                case 4: Position = new Vector2DF(106, 519); break;

                case 5: Position = new Vector2DF(42, 519); break;
                }
            }
Exemplo n.º 3
0
            protected override void OnStart()
            {
                var g = Engine.Graphics.CreateTexture2D(CloudTexturePath);

                Texture        = g;
                CenterPosition = new Vector2DF(Texture.Size.X / 2, Texture.Size.Y / 2);
            }
Exemplo n.º 4
0
        private void PlaceVectors(NumberVector start)
        {
            //float angleSpan = 137.507f;
            float angleSpan = 360 / 72.0f;

            for (int i = 2; i <= 72; i++)
            {
                var vector   = NumberVector.CreateForNumber(i);
                var distance = (vector - start).GetLength();

                var position = new Vector2DF(1, 1);
                position.Degree = angleSpan * i;
                position.Length = distance * DistanceUnit;
                position       += new Vector2DF(320, 320);

                var obj = new TextObject2D()
                {
                    Text            = i.ToString(),
                    Font            = font,
                    Position        = position,
                    Color           = vector.IsPrime() ? Helper.AccentColor1 : Helper.PlaneColor,
                    DrawingPriority = 2,
                };
                var size = font.CalcTextureSize(i.ToString(), WritingDirection.Horizontal);
                obj.CenterPosition = size.To2DF() / 2;

                layer.AddObject(obj);
            }
        }
Exemplo n.º 5
0
            public SkillGauge(Skill skill)
            {
                // スキルを紐付け
                Skill = skill;

                string path = "";

                switch (skill.SkillType)
                {
                case SkillType.Attack: path = "Graphics/Gauge_Attack.png"; break;

                case SkillType.Heal: path = "Graphics/Gauge_Heal.png"; break;

                case SkillType.Boost: path = "Graphics/Gauge_Boost.png"; break;

                case SkillType.Guard: path = "Graphics/Gauge_Guard.png"; break;

                case SkillType.Support: path = "Graphics/Gauge_Support.png"; break;

                case SkillType.Edge: path = "Graphics/Gauge_Edge.png"; break;

                case SkillType.Damage: path = "Graphics/Gauge_Danger.png"; break;
                }

                Initialize(path);

                UR = new Vector2DF(150, 0);
                UL = new Vector2DF(0, 0);
                DR = new Vector2DF(150, 40);
                DL = new Vector2DF(0, 40);

                Skill.GaugeMethodSetter   =
                    (value) => GaugeValue = value;
            }
Exemplo n.º 6
0
 public Player()
 {
     Texture        = Engine.Graphics.CreateTexture2D("Resource/icon_business_man01.png");
     CenterPosition = new Vector2DF(Texture.Size.X / 2.0f, Texture.Size.Y / 2.0f);
     Position       = new Vector2DF(240, 500);
     Scale          = new Vector2DF(0.2f, 0.2f);
 }
Exemplo n.º 7
0
        protected override void OnRegistered()
        {
            Layer2D back = new Layer2D();
            Layer2D text = new Layer2D();

            // 背景を設定する
            back.AddPostEffect(
                new Background(
                    new Vector3DF(0.0f, 0.4f, 1.0f),
                    new Vector3DF(0.4f, 0.7f, 1.0f)
                    )
                );

            // テキストの中心座標をオブジェクトの中心にする
            Vector2DF center = new Vector2DF(0.5f, 0.5f);

            // 「Aero Groovers」
            AGText title = new AGText(120, 4, center);

            title.SetText("Aero Groovers");
            title.Position = new Vector2DF(640, 150);
            text.AddObject(title);

            // 「Press Any Button.」
            AGText announce = new AGText(72, 4, center);

            announce.SetText("Press Any Button.");
            announce.Position = new Vector2DF(640, 600);
            text.AddObject(announce);

            // レイヤーを追加する
            AddLayer(back);
            AddLayer(text);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 中心座標を設定する
        /// </summary>
        private void SetCenterPosition()
        {
            WritingDirection direction = WritingDirection.Horizontal;
            Vector2DF        size      = Font.CalcTextureSize(Text, direction).To2DF();

            CenterPosition = size * CenteringPosition;
        }
Exemplo n.º 9
0
            /// <summary>
            /// ウィンドウを開く指示を受けた時の処理
            /// </summary>
            private void OnOpened()
            {
                // ウィンドウの高さを変更する
                float v = FrameCounter;
                float h = (float)(470 - 370 * Pow(v / 10.0, 2));

                WindowSize = new Vector2DF(270, h);

                if (FrameCounter == 0)
                {
                    // 状態を変更し,メソッド内の処理を終える
                    NoisyValue = 0.025f;

                    playr_l.IsDrawn                 =
                        style_l.IsDrawn             =
                            style_v.IsDrawn         =
                                check_l.IsDrawn     =
                                    press_b.IsDrawn = true;

                    foreach (var pair in check)
                    {
                        pair.Value.IsDrawn = true;
                    }

                    Gauge.IsDrawn = true;

                    Player player = Game.Player[PlayerNumber - 1];
                    style_v.SetText(((Controller)player.Controller).ControllerType.ToString());

                    CurrentState = WindowState.Opening;
                    return;
                }

                --FrameCounter;
            }
Exemplo n.º 10
0
        protected override void OnUpdate()
        {
            // ウィンドウの大きさを設定
            float size_x = WindowSize.X;
            float size_y = WindowSize.Y;

            if (size_x < MinimumSize.X)
            {
                size_x = MinimumSize.X;
            }
            if (size_y < MinimumSize.Y)
            {
                size_y = MinimumSize.Y;
            }
            WindowSize = new Vector2DF(size_x, size_y);

            // 拡大率の設定
            Scale = WindowSize * 0.02f;
            SetScale();

            // 座標の設定
            SetPosition();

            // 色を設定する
            SetColor();
        }
Exemplo n.º 11
0
        public static void ShotTypeA(int count, Vector2DF pos, Layer2D gameLayer)
        {
            if (count % 7 == 0)
            {
                for (int i = 0; i < 12; i++)
                {
                    var angle     = 2 * Math.PI * (i / 12.0f);
                    var bulletPos = pos + 36.0f * new asd.Vector2DF((float)Math.Cos(angle), (float)Math.Sin(angle));

                    angle *= 360.0f / (2 * Math.PI); // rad to degree

                    if ((count / 30) % 3 == 0)
                    {
                        angle       += 90;
                        bulletPos.X += 0.0f;
                    }
                    else if ((count / 30) % 3 == 1)
                    {
                        angle       -= 90;
                        bulletPos.X -= 0.0f;
                    }
                    else
                    {
                    }
                    gameLayer.AddObject(new Bullet(bulletPos, (float)angle));
                }
            }
        }
Exemplo n.º 12
0
        public void SetPosition(Vector2DF pos)
        {
            _x = _col * width + (int)pos.X;
            _y = _row * height + (int)pos.Y;

            _backTexture.Position = new asd.Vector2DF(_x, _y);
        }
Exemplo n.º 13
0
            protected override void OnAdded()
            {
                var rectCollider = new RectangleCollider();

                rectCollider.Area      = new RectF(0, 0, 100, 100);
                rectCollider.IsVisible = true;
                rectCollider.Tag       = "A";
                AddCollider(rectCollider);

                var lineCollider = new LineCollider();

                lineCollider.StartingPosition = new Vector2DF(110, 110);
                lineCollider.EndingPosition   = new Vector2DF(200, 200);
                lineCollider.Thickness        = 10;
                lineCollider.Tag       = "B";
                lineCollider.IsVisible = true;
                AddCollider(lineCollider);

                var circleCollider = new CircleCollider();

                circleCollider.Center    = new Vector2DF(300, 300);
                circleCollider.Radius    = 90;
                circleCollider.Tag       = "C";
                circleCollider.IsVisible = true;
                AddCollider(circleCollider);

                Scale    = new Vector2DF(0.5f, 0.5f);
                velocity = new Vector2DF(4, 0);
            }
Exemplo n.º 14
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="cellPos">セルの座標</param>
 public Character(Vector2DI cellPos)
 {
     CellPosition = cellPos;
     Position     = CellPosition.To2DF() * CellSize;
     //微調整
     Position += new Vector2DF(0.3f, -0.7f) * CellSize / 2;
 }
Exemplo n.º 15
0
        public PauseLayer()
        {
            IsDrawn   = false;
            IsUpdated = false;

            var center = new Vector2DF(0.5f, 0.5f);

            Pause = new ScanLine(120, 4, center)
            {
                Text     = "PAUSE",
                Position = new Vector2DF(480, 150)
            };
            Items = new Dictionary <Item, ScanLine>
            {
                { Item.Resume, new ScanLine(60, 4, center)
                  {
                      Text = "RESUME", Position = new Vector2DF(480, 300)
                  } },
                { Item.Retry, new ScanLine(60, 4, center)
                  {
                      Text = "RETRY", Position = new Vector2DF(480, 400)
                  } },
                { Item.Return, new ScanLine(60, 4, center)
                  {
                      Text = "QUIT PLAY", Position = new Vector2DF(480, 500)
                  } },
            };
            Mask = new GeometryObject2D
            {
                Shape = new RectangleShape {
                    DrawingArea = new RectF(0, 0, 960, 720)
                },
                Color = new Color(0, 0, 0, 127)
            };
        }
Exemplo n.º 16
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="position">座標</param>
 /// <param name="text">表示文字列</param>
 /// <param name="difficulty">難易度</param>
 public Difficulties(Vector2DF position, string text, Dif difficulty)
 {
     ReturnDif = difficulty;
     Font      = BigFont;
     Position  = position;
     Text      = text;
 }
Exemplo n.º 17
0
        public Player(GameScene gameScene)
        {
            //ゲームシーン保持用(追加)
            this.gameScene = gameScene;

            //画像設定
            Texture        = Engine.Graphics.CreateTexture2D("Resource/icon_business_man01.png");
            CenterPosition = new Vector2DF(Texture.Size.X / 2.0f, Texture.Size.Y / 2.0f);
            Position       = new Vector2DF(240, 500);
            Scale          = new Vector2DF(0.2f, 0.2f);

            //HP設定(追加)
            hp = 5;

            //HP表示(追加)
            hpText = new HpText("自分のHP", new Vector2DF(0, Engine.WindowSize.Y - 30), this, gameScene);
            gameScene.UILayer.AddObject(hpText);

            //当たり判定の半径(追加)
            radius = Texture.Size.X * Scale.X / 32f;

            //初期化(追加)
            hitted   = false;
            hitcount = 0;
        }
Exemplo n.º 18
0
        public Enemy(Player player, GameScene gameScene)
        {
            //それぞれ初期化(追加)
            this.gameScene = gameScene;
            this.player    = player;

            //画像設定
            Texture        = Engine.Graphics.CreateTexture2D("Resource/leader_ibaru.png");
            CenterPosition = new Vector2DF(Texture.Size.X / 2.0f, Texture.Size.Y / 2.0f);
            Position       = new Vector2DF(240, 100);
            Scale          = new Vector2DF(0.2f, 0.2f);

            //初期化
            moveRight = true;
            hitted    = false;

            //初期化(追加)
            hitcount = 0;
            count    = 0;

            hp = 100;

            //当たり判定の半径(追加)
            radius = Texture.Size.X * Scale.X / 2f;

            //HP表示(追加)
            hpText = new HpText("敵のHP", new Vector2DF(0, 0), this, gameScene);
            gameScene.UILayer.AddObject(hpText);
        }
Exemplo n.º 19
0
 internal bool IsHit( Vector2DF mouse )
 {
     var size = new Vector2DF( Texture.Size.X, Texture.Size.Y ) * Scale;
     return mouse.X >= Position.X
         && mouse.X <= Position.X + size.X
         && mouse.Y >= Position.Y
         && mouse.Y <= Position.Y + size.Y;
 }
Exemplo n.º 20
0
        protected GeneralText(string path, int size, int o_size, Vector2DF center = new Vector2DF())
        {
            FontPath = path;
            Color white = new Color(255, 255, 255);
            Color black = new Color(0, 0, 0);

            Font           = Graphics.CreateDFont(path, size, white, o_size, black);
            CenterPosition = center;
        }
Exemplo n.º 21
0
            public ReleaseGauge()
            {
                Initialize("Graphics/ReleaseGauge.png");

                UR = new Vector2DF(240, 0);
                UL = new Vector2DF(0, 0);
                DR = new Vector2DF(240, 40);
                DL = new Vector2DF(0, 40);
            }
Exemplo n.º 22
0
 protected HitEffect(string path, float scale)
 {
     // 諸々の初期化
     Texture        = Graphics.CreateTexture(path);
     CenterPosition = new Vector2DF(128, 128);
     Scale          = new Vector2DF(scale / 200, scale / 200);
     AlphaBlend     = AlphaBlendMode.Add;
     Src            = new RectF(0, 0, 256, 256);
 }
Exemplo n.º 23
0
 public static void ShotTypeB(int count, Vector2DF pos, Layer2D gameLayer)
 {
     if (count % 10 == 0)
     {
         var bulletPos = new asd.Vector2DF(pos.X, pos.Y + 30);
         gameLayer.AddObject(new Bullet(bulletPos, +90));
         gameLayer.AddObject(new Bullet(bulletPos, +110));
         gameLayer.AddObject(new Bullet(bulletPos, +70));
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// フォームへのサイズ変更を通知
        /// </summary>
        private void ReSize()
        {
            var s     = info.TextureInfo.Texture.Texture.Size;
            var scale = info.UIObject.Scale;
            var size  = new Vector2DF(s.X * scale.X, s.Y * scale.Y);

            NumericUpDown_Size_X.Value = float.IsNaN(size.X) ? 0 : (decimal)size.X;
            NumericUpDown_Size_Y.Value = float.IsNaN(size.Y) ? 0 : (decimal)size.Y;
            info.UIObject.Scale        = scale;
        }
Exemplo n.º 25
0
        /// <summary>
        /// フォームへのサイズ変更を通知
        /// </summary>
        private void ReSize()
        {
            var s     = info.FontInfo.Font.Font.CalcTextureSize(RichTextBox_Text.Text, info.WritingDirection);
            var scale = info.UIObject.Scale;
            var size  = new Vector2DF(s.X * scale.X, s.Y * scale.Y);

            NumericUpDown_Size_X.Value = float.IsNaN(size.X) ? 0 : (decimal)size.X;
            NumericUpDown_Size_Y.Value = float.IsNaN(size.Y) ? 0 : (decimal)size.Y;
            info.UIObject.Scale        = scale;
        }
Exemplo n.º 26
0
            protected override void OnAdded()
            {
                var rectCollider = new RectangleCollider();

                rectCollider.Area      = new RectF(0, 0, 100, 100);
                rectCollider.Tag       = "D";
                rectCollider.IsVisible = true;
                AddCollider(rectCollider);
                Scale = new Vector2DF(0.5f, 0.5f);
            }
Exemplo n.º 27
0
 public EnemyShot(Type type, int count, Vector2DF pos, Layer2D gameLayer)
 {
     if (type == Type.t1)
     {
         ShotTypeA(count, pos, gameLayer);
     }
     else
     {
         ShotTypeB(count, pos, gameLayer);
     }
 }
Exemplo n.º 28
0
 public PressEffect(Keys Key)
 {
     // 諸々の初期化
     Texture        = Graphics.CreateTexture("Effect/Press.png");
     CenterPosition = new Vector2DF(128, 128);
     Scale          = new Vector2DF(0.375f, 0.375f);
     AlphaBlend     = AlphaBlendMode.Add;
     Src            = new RectF(0, 768, 256, 256);
     Count          = 12;
     this.Key       = Key;
 }
Exemplo n.º 29
0
        public Enemy(Vector2DF pos, Player player)
        {
            Position    = pos;
            this.player = player;

            Texture = asd.Engine.Graphics.CreateTexture2D("Resources/Enemy.png");

            Radius = Texture.Size.X / 2.0f;

            //破壊時の効果音を読み込む
            deathSound = asd.Engine.Sound.CreateSoundSource("Resources/Explode.wav", true);
        }
Exemplo n.º 30
0
 protected override void OnUpdate()
 {
     if (Position.X < 0)
     {
         velocity = new Vector2DF(4, 0);
     }
     else if (Position.X > 600)
     {
         velocity = new Vector2DF(-4, 0);
     }
     Angle += 1;
 }
Exemplo n.º 31
0
 public void UpdateTexture(Vector2DF pos)
 {
     if (pos.X > _x && pos.X < _x + width &&
         pos.Y > _y && pos.Y < _y + height)
     {
         _backTexture.Texture = Resource.getPaletteEnterSquareTexture();
     }
     else
     {
         _backTexture.Texture = null;
     }
 }
Exemplo n.º 32
0
 // *** Misc utils ***
 public static bool TestLineHit(Vector2DF testPt, Vector2DF lineTail, Vector2DF lineHead, float maxDist, ref float dist)
 {
     dist = float.MaxValue;
     if (lineTail != lineHead)
     {
         Vector2DF edge = lineHead - lineTail;
         Vector2DF edgeNormal = edge.Normal();
         float intrsctX = 0, intrsctY = 0;
         float posA = 0, posB = 0;
         Vector2DF.Intersect(testPt, edgeNormal, lineTail, edge, ref intrsctX, ref intrsctY, ref posA, ref posB);
         if (posB >= 0f && posB <= 1f)
         {
             Vector2DF distVec = new Vector2DF(intrsctX, intrsctY) - testPt;
             dist = distVec.GetLength();
         }
         dist = Math.Min((lineTail - testPt).GetLength(), dist);
     }
     dist = Math.Min((lineHead - testPt).GetLength(), dist);
     return dist <= maxDist;
 }
Exemplo n.º 33
0
 public static bool IsObjectAt(float ptX, float ptY, TransformParams t, float cX, float cY, float rX, float rY)
 {
     Utils.ThrowException(t == null ? new ArgumentNullException("t") : null);
     Vector2DF center = t.Transform(new Vector2DF(cX, cY));
     Vector2DF pt = new Vector2DF(ptX, ptY);
     if (pt == center) { return true; }
     float angle = (pt - center).GetAngle();
     float x = (float)Math.Cos(angle) * t.Transform(rX);
     float y = (float)Math.Sin(angle) * t.Transform(rY);
     float r = new Vector2DF(x, y).GetLength();
     return (center - pt).GetLength() <= r;
 }
Exemplo n.º 34
0
 public static void Draw(float x1, float y1, float x2, float y2, Graphics g, Pen pen, TransformParams t, BoundingArea.ReadOnly boundingArea)
 {
     #if !NO_PARTIAL_RENDERING
     Utils.ThrowException(g == null ? new ArgumentNullException("g") : null);
     Utils.ThrowException(pen == null ? new ArgumentNullException("pen") : null);
     Utils.ThrowException(t == null ? new ArgumentNullException("t") : null);
     Utils.ThrowException(boundingArea == null ? new ArgumentNullException("boundingArea") : null);
     Vector2DF pt1 = t.Transform(new Vector2DF(x1, y1));
     Vector2DF pt2 = t.Transform(new Vector2DF(x2, y2));
     Vector2DF isectPt1 = new Vector2DF();
     Vector2DF isectPt2 = new Vector2DF();
     BoundingArea inflatedArea = boundingArea.GetWritableCopy();
     inflatedArea.Inflate(pen.Width / 2f + 5f, pen.Width / 2f + 5f);
     ArrayList<KeyDat<float, PointInfo>> points = new ArrayList<KeyDat<float, PointInfo>>();
     foreach (RectangleF rect in inflatedArea.Rectangles)
     {
         if (LineIntersectRectangle(pt1, pt2, rect, ref isectPt1, ref isectPt2))
         {
             float distPt1 = (pt1 - isectPt1).GetLength();
             float distPt2 = (pt1 - isectPt2).GetLength();
             bool startPt1 = distPt1 < distPt2;
             points.Add(new KeyDat<float, PointInfo>(distPt1, new PointInfo(isectPt1, startPt1)));
             points.Add(new KeyDat<float, PointInfo>(distPt2, new PointInfo(isectPt2, !startPt1)));
         }
     }
     points.Sort();
     int refCount = 0;
     int startIdx = 0;
     for (int i = 0; i < points.Count; i++)
     {
         PointInfo pointInfo = points[i].Dat;
         if (pointInfo.IsStartPoint)
         {
             refCount++;
         }
         else
         {
             refCount--;
             if (refCount == 0)
             {
                 g.DrawLine(pen, points[startIdx].Dat.Point, pointInfo.Point);
                 startIdx = i + 1;
             }
         }
     }
     #else
     Draw(x1, y1, x2, y2, g, pen, t);
     #endif
 }
Exemplo n.º 35
0
 public static BoundingArea GetBoundingArea(float x1, float y1, float x2, float y2)
 {
     #if !SIMPLE_BOUNDING_AREA
     if (x1 == x2 || y1 == y2) { return new BoundingArea(VisualizationUtils.CreateRectangle(x1, y1, x2, y2)); }
     float delta = Math.Abs((x2 - x1) / (y2 - y1));
     float stepMax = (float)Math.Sqrt(mMaxBoxArea / delta + delta * mMaxBoxArea);
     Vector2DF line = new Vector2DF(x1, y1, x2, y2);
     float lineLen = line.GetLength();
     if (stepMax >= lineLen) { return new BoundingArea(VisualizationUtils.CreateRectangle(x1, y1, x2, y2)); }
     BoundingArea boundingArea = new BoundingArea();
     int steps = (int)Math.Ceiling(lineLen / stepMax);
     Vector2DF stepVec = line;
     stepVec.SetLength(lineLen / (float)steps);
     Vector2DF pt1 = new Vector2DF(x1, y1);
     Vector2DF pt2;
     for (int i = 0; i < steps - 1; i++)
     {
         pt2 = pt1 + stepVec;
         boundingArea.AddRectangles(VisualizationUtils.CreateRectangle(pt1.X, pt1.Y, pt2.X, pt2.Y));
         pt1 = pt2;
     }
     pt2 = new Vector2DF(x2, y2);
     boundingArea.AddRectangles(VisualizationUtils.CreateRectangle(pt1.X, pt1.Y, pt2.X, pt2.Y));
     return boundingArea;
     #else
     BoundingArea boundingArea = new BoundingArea();
     boundingArea.AddRectangles(VisualizationUtils.CreateRectangle(x1, y1, x2, y2));
     return boundingArea;
     #endif
 }
Exemplo n.º 36
0
 private static bool LineIntersectHorizontal(Vector2DF pt1, Vector2DF pt2, float y, ref float x)
 {
     return LineIntersectVertical(new Vector2DF(pt1.Y, pt1.X), new Vector2DF(pt2.Y, pt2.X), y, ref x);
 }
Exemplo n.º 37
0
 private static bool LineIntersectRectangle(Vector2DF pt1, Vector2DF pt2, RectangleF rect, ref Vector2DF isectPt1, ref Vector2DF isectPt2)
 {
     // note that this does not work properly in the case when the line lies on one of the rectangle's vertical edges
     // this is not a problem for the partial rendering of lines since the rectangles are inflated prior to determining
     // intersections
     float y = 0, x = 0;
     ArrayList<Vector2DF> points = new ArrayList<Vector2DF>(2);
     if (LineIntersectVertical(pt1, pt2, rect.X, ref y))
     {
         if (y > rect.Y && y < rect.Y + rect.Height) { points.Add(new Vector2DF(rect.X, y)); }
     }
     if (LineIntersectVertical(pt1, pt2, rect.X + rect.Width, ref y))
     {
         if (y > rect.Y && y < rect.Y + rect.Height) { points.Add(new Vector2DF(rect.X + rect.Width, y)); }
     }
     if (LineIntersectHorizontal(pt1, pt2, rect.Y, ref x))
     {
         if (x > rect.X && x < rect.X + rect.Width) { points.Add(new Vector2DF(x, rect.Y)); }
     }
     if (LineIntersectHorizontal(pt1, pt2, rect.Y + rect.Height, ref x))
     {
         if (x > rect.X && x < rect.X + rect.Width) { points.Add(new Vector2DF(x, rect.Y + rect.Height)); }
     }
     if (points.Count == 2)
     {
         isectPt1 = points[0];
         isectPt2 = points[1];
         return true;
     }
     else if (points.Count == 1)
     {
         isectPt1 = points[0];
         isectPt2 = VisualizationUtils.PointInsideRect(pt1.X, pt1.Y, rect) ? pt1 : pt2;
         return true;
     }
     else if (VisualizationUtils.PointInsideRect(pt1.X, pt1.Y, rect) && VisualizationUtils.PointInsideRect(pt2.X, pt2.Y, rect))
     {
         isectPt1 = pt1;
         isectPt2 = pt2;
         return true;
     }
     return false;
 }
Exemplo n.º 38
0
 private static bool LineIntersectVertical(Vector2DF pt1, Vector2DF pt2, float x, ref float y)
 {
     if (pt1.X > pt2.X) { Vector2DF tmp = pt1; pt1 = pt2; pt2 = tmp; } // swap points
     if (pt1.X < x && pt2.X > x)
     {
         float dY = pt2.Y - pt1.Y;
         if (dY == 0)
         {
             y = pt1.Y;
             return true;
         }
         float dX = pt2.X - pt1.X;
         float dx = x - pt1.X;
         float dy = dx * dY / dX;
         y = pt1.Y + dy;
         return true;
     }
     return false;
 }
Exemplo n.º 39
0
 public PointInfo(Vector2DF pt, bool isStartPt)
 {
     Point = pt;
     IsStartPoint = isStartPt;
 }