Beispiel #1
0
    private void MoveShot()
    {
        QRegion region = new QRegion(ShotRect());

        timerCount++;

        QRect shotR = ShotRect();

        if (shotR.Intersects(TargetRect()))
        {
            autoShootTimer.Stop();
            Emit.Hit();
            Emit.CanShoot(true);
        }
        else if (shotR.X() > Width() || shotR.Y() > Height() ||
                 shotR.Intersects(BarrierRect()))
        {
            autoShootTimer.Stop();
            Emit.Missed();
            Emit.CanShoot(true);
        }
        else
        {
            region = region.Unite(shotR);
        }

        Update(region);
    }
Beispiel #2
0
    private void moveShot()
    {
        QRegion region = new QRegion(shotRect());

        timerCount++;

        QRect shotR = shotRect();

        if (shotR.Intersects(targetRect()))
        {
            autoShootTimer.Stop();
            Emit.hit();
            Emit.canShoot(true);
        }
        else if (shotR.X() > Width() || shotR.Y() > Height())
        {
            autoShootTimer.Stop();
            Emit.missed();
            Emit.canShoot(true);
        }
        else
        {
            region = region.Unite(new QRegion(shotR));
        }

        Update(region);
    }
Beispiel #3
0
        public override void OnFixedUpdate(float time)
        {
            Collision = new QRect(Transform.Position - new QVec(sprite.Width / 2f - 5), new QVec(Movement - 5));
            if (Collision.Intersects(fruit.Collision))
            {
                var body = new SnakeBody();
                Bodies.Insert(0, body);
                Instantiate(body, LastPosition);
                fruit.NewLocation();
                //snakeMoveSpeed -= snakeMoveSpeed * 0.05f;
                Points++;
            }
            if (Bodies.Count > 0)
            {
                Bodies[0].Transform.Position = LastPosition;
            }
            for (int i = 0; i < Bodies.Count; i++)
            {
                if (Collision.Intersects(Bodies[i].Collision))
                {
                    Scene.Destroy(this);
                }
                //Bodies[i + 1].PreviousPosition = Bodies[i].PreviousPosition;
            }
            if (QInput.Held(QKeyStates.W))
            {
                CurrentDir = SnakeDirection.Up;
            }
            if (QInput.Held(QKeyStates.S))
            {
                CurrentDir = SnakeDirection.Down;
            }
            if (QInput.Held(QKeyStates.A))
            {
                CurrentDir = SnakeDirection.Left;
            }
            if (QInput.Pressed(QKeyStates.D))
            {
                CurrentDir = SnakeDirection.Right;
            }

            if (!Camera.IsInCameraView(Transform.Position))
            {
                Scene.Destroy(this);
            }
        }
Beispiel #4
0
        public void TestIntersects()
        {
            var s1 = new QRect();

            s1.X      = 0;
            s1.Y      = 0;
            s1.Width  = 500;
            s1.Height = 600;

            var s2 = new QRect();

            s2.X      = 400;
            s2.Y      = 500;
            s2.Width  = 500;
            s2.Height = 600;

            var inter = s1.Intersects(s2);

            Assert.IsTrue(inter);
        }
Beispiel #5
0
        public void TestIntersects()
        {
            var s1 = new QRect();
            s1.X = 0;
            s1.Y = 0;
            s1.Width = 500;
            s1.Height = 600;

            var s2 = new QRect();
            s2.X = 400;
            s2.Y = 500;
            s2.Width = 500;
            s2.Height = 600;

            var inter = s1.Intersects(s2);

            Assert.IsTrue(inter);
        }