Пример #1
0
        public override void Update()
        {
            if (body == null || !world.BodyList.Contains(body))
            {
                IsOperational = false;
            }

            if (isPendingAttach)
            {
                body.BodyType     = BodyType.Static;
                body.CollidesWith = Category.All;
                body.Rotation     = pendingRotation;
                isPendingAttach   = false;
            }
            if (body.BodyType == BodyType.Static)
            {
                // we're theoretically clinging to a wall.
                Vector2 aimVector = new Vector2((float)Math.Cos(body.Rotation), (float)Math.Sin(body.Rotation));

                if (FarseerHelper.hasLineOfSight(body.Position, body.Position + aimVector * 100, f => target.OwnsFixture(f), world))
                {
                    JumpOff();
                }
            }
        }
Пример #2
0
        private bool hasLineOfSight()
        {
            Vector2 p1 = pivot.Body.Position + AimVector * barrelLength;
            Vector2 p2 = pivot.Body.Position + AimVector * fireRange;

            return(FarseerHelper.hasLineOfSight(p1, p2, f => target.OwnsFixture(f), world));

            //bool hasLOS = false;

            //world.RayCast((f, p, n, fr) =>
            //{
            //    if (target.OwnsFixture(f))
            //        hasLOS = true;

            //    return 0; // terminate the ray cast

            //}, p1, p2);

            //return hasLOS;
        }