public override void Init()
        {
            _body = Object.SearchComponent<RigidBody>();
            _collider = Object.SearchComponent<Collider>();

            base.Init();
        }
Пример #2
0
        public override bool Intersects(Collider other)
        {
            if ((other is AxisAlignedBoxCollider))
                return Intersects((AxisAlignedBoxCollider)other);

            throw new NotImplementedException();
        }
Пример #3
0
        public void OnCollide(Collider collider)
        {
            if (Tags != null && !Tags.Contains(collider.Object.Tag))
                return;

            var other = collider.Object.GlobalTransform.TranslationVector;

            var box = collider as AxisAlignedBoxCollider;
            if (box == null)
                throw new NotImplementedException();

            var pos = Object.GlobalTransform.TranslationVector;
            var col = Object.SearchComponent<AxisAlignedBoxCollider>();

            if (other.Y - box.RadiusHeight > pos.Y)
            {
                var body = collider.Object.SearchComponent<RigidBody>();
                if (body != null)
                {
                    body.Acceleration.Y = 0;
                    body.InstantAcceleration.Y = 0;
                    body.Momentum.Y = 0;
                    body.Push(new SharpDX.Vector3(0, 2.5f, 0), true);
                }
                Object.SendMessage("OnStomp", true, collider);
            }
            else
            {
                collider.Object.SendMessage("OnHit", true);
            }
        }
Пример #4
0
        public void OnHeadStomp(Collider collider)
        {
            _material.Texture = EmptyTexture;

            if(Item != null && _toMove != null)
            {
                Item.Visible = true;
                _toMove = 1;
                Item.Transform = Transform;
                Parent.Add(Item);
                Item.Init();
            }
        }
Пример #5
0
        public void OnCollide(Collider collider)
        {
            if (_moving)
                return;

            _lastCollider = collider;

            var body = collider.Object.SearchComponent<RigidBody>();
            if (body == null || body.Momentum.Y < 0)
                return;

            if (!ValidCollision(collider))
                return;

            Object.SendMessage("OnHeadStomp", true, collider);
            _moving = true;
            _originalPosition = Object.Transform;
        }
Пример #6
0
        public void OnTrigger(Collider collider)
        {
            if (Tags == null || (collider.Object != null && Tags.Contains(collider.Object.Tag)))
            {
                var rigidBody = collider.Object.SearchComponent<RigidBody>();
                if (rigidBody != null)
                {
                    Vector3 mask = Vector3.Zero;
                    if ((rigidBody.Momentum.X < 0) != (Force.X < 0))
                    {
                        rigidBody.Acceleration.X = 0;
                        rigidBody.InstantAcceleration.X = 0;
                        rigidBody.Momentum.X = 0;
                        mask.X = 1;
                    }

                    if ((rigidBody.Momentum.Y < 0) != (Force.Y < 0))
                    {
                        rigidBody.Acceleration.Y = 0;
                        rigidBody.InstantAcceleration.Y = 0;
                        rigidBody.Momentum.Y = 0;
                        mask.Y = 1;
                    }

                    if ((rigidBody.Momentum.Z < 0) != (Force.Z < 0))
                    {
                        rigidBody.Acceleration.Z = 0;
                        rigidBody.InstantAcceleration.Z = 0;
                        rigidBody.Momentum.Z = 0;
                        mask.Z = 1;
                    }

                    rigidBody.Push(Force * mask, true);
                }
            }
        }
Пример #7
0
 public override void Init()
 {
     _scene = Object.GetAncestor<Scene>();
     Collider = Collider ?? Object.SearchComponent<Collider>();
     base.Init();
 }
Пример #8
0
        bool ValidCollision(Collider collider)
        {
            var other = collider.Object.GlobalTransform.TranslationVector;
            var pos = Object.GlobalTransform.TranslationVector;
            var col = Object.SearchComponent<AxisAlignedBoxCollider>();

            var box = collider as AxisAlignedBoxCollider;
            if (box == null)
                return false;

            if (other.Y + box.RadiusHeight < pos.Y)
                return true;

            var dist = box.Object.Transform.TranslationVector - Object.Transform.TranslationVector;
            var distL = new Vector2(dist.X, dist.Z).Length();

            if (distL >= 0.5f)
                return false;

            return false;
        }
Пример #9
0
 public void OnStomp(Collider collider)
 {
     if (Tags == null || (collider.Object != null && Tags.Contains(collider.Object.Tag)))
         _dying = true;
 }
Пример #10
0
 public abstract bool Intersects(Collider other);
Пример #11
0
 public void OnTrigger(Collider collider)
 {
     if (Tags == null || (collider.Object != null && Tags.Contains(collider.Object.Tag)))
         collider.Object.SendMessage("OnHit", false);
 }
Пример #12
0
 public void OnTrigger(Collider collider)
 {
     if (_onTrigger != null)
         _onTrigger(collider);
 }
Пример #13
0
        void SlideDown(Collider collider)
        {
            if (_state != State.Unused)
                return;

            collider.Object.Translate(new Vector3(GlobalTransform.TranslationVector.X - collider.Object.GlobalTransform.TranslationVector.X - 0.4f, 0, 0));

            _sliding = collider.Object;
            _slidingBody = collider.Object.SearchComponent<RigidBody>();
            TrackFlag();
            _sliding.Enabled = false;
            _flag.Transform = _flag.Transform * Matrix.RotationY((float)Math.PI);

            _delayCount = TimeSpan.Zero;
            _state = State.InitialDelay;
        }