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

            base.Init();
        }
Exemplo n.º 2
0
        public override bool Intersects(Collider other)
        {
            if ((other is AxisAlignedBoxCollider))
                return Intersects((AxisAlignedBoxCollider)other);

            throw new NotImplementedException();
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 7
0
 public override void Init()
 {
     _scene = Object.GetAncestor<Scene>();
     Collider = Collider ?? Object.SearchComponent<Collider>();
     base.Init();
 }
Exemplo n.º 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;
        }
Exemplo n.º 9
0
 public void OnStomp(Collider collider)
 {
     if (Tags == null || (collider.Object != null && Tags.Contains(collider.Object.Tag)))
         _dying = true;
 }
Exemplo n.º 10
0
 public abstract bool Intersects(Collider other);
Exemplo n.º 11
0
 public void OnTrigger(Collider collider)
 {
     if (Tags == null || (collider.Object != null && Tags.Contains(collider.Object.Tag)))
         collider.Object.SendMessage("OnHit", false);
 }
Exemplo n.º 12
0
 public void OnTrigger(Collider collider)
 {
     if (_onTrigger != null)
         _onTrigger(collider);
 }
Exemplo n.º 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;
        }