Exemplo n.º 1
0
        private void OnCollisionStart(NodeCollisionStartEventArgs e)
        {
            //validate
            if (IsGripping)
            {
                return;
            }
            if (e.OtherNode == Node.Parent)
            {
                return;
            }
            if (OtherGripper != null && (e.OtherNode == OtherGripper.Node || e.OtherNode == OtherGripper.Node.Parent))
            {
                return;
            }

            //register the node as touching
            if (!_touchingNodes.ContainsKey(e.OtherNode))
            {
                _touchingNodes.Add(e.OtherNode, e);
            }

            //determine if other gripper is touching the item too
            if (OtherGripper != null)
            {
                if (e.OtherBody.Mass != 0) // don't grip immovable objects
                {
                    if (OtherGripper.IsTouchingNode(e.OtherNode))
                    {
                        Grip(e);
                        OtherGripper.Grip(e);
                    }
                }
            }
        }
Exemplo n.º 2
0
        void OnCollided(NodeCollisionStartEventArgs args)
        {
            //Nog in te vullen
            var bulletNode = args.OtherNode;

            System.Diagnostics.Debug.WriteLine("collision " + bulletNode.Name);
            if (bulletNode.Name.StartsWith("basketball"))
            {
                //Todo

                if (bulletNode.Position.Y < collissionNode.Position.Y)
                {
                    //misses++;
                }
                else
                {
                    if (ballsThrown <= durationGame)
                    {
                        total = hits + misses;
                        if (total < ballsThrown)
                        {
                            hits++;
                            hitsText.Text = "Hits " + hits;
                        }
                    }
                }
                //thrownballs.Remove(bulletNode);
                System.Diagnostics.Debug.WriteLine("hits " + ballsThrown + " in collide " + hits + " misses " + misses);
            }
        }
Exemplo n.º 3
0
        void Camera_NodeCollisionStart(NodeCollisionStartEventArgs e)
        {
            if (!AutoDistance)
            {
                return;
            }

            //moveable object - increase the distance
            if (e.OtherBody.Mass > 0)
            {
                Distance            = MathHelper.Clamp(Distance + 2, _distanceMin, _distanceMax);
                _transitionDistance = Distance;
            }
        }
Exemplo n.º 4
0
		void OnCollided(NodeCollisionStartEventArgs args)
		{
			var bulletNode = args.OtherNode;
			if (IsAlive && bulletNode.Name != null && bulletNode.Name.StartsWith(nameof(Weapon)) && args.Body.Node == Node)
			{
				var weapon = bulletNode.GetComponent<WeaponReferenceComponent>().Weapon;
				Health -= weapon.Damage;
				var killed = Health <= 0;
				if (killed)
				{
					Explode();
				}
				else if (weapon.Damage > 0)
				{
					Hit();
				}
				weapon.OnHit(target: this, killed: killed, bulletNode: bulletNode);
			}
		}
Exemplo n.º 5
0
        void OnCollided(NodeCollisionStartEventArgs args)
        {
            var bulletNode = args.OtherNode;

            if (IsAlive && bulletNode.Name != null && bulletNode.Name.StartsWith(nameof(Weapon)) && args.Body.Node == Node)
            {
                var weapon = bulletNode.GetComponent <WeaponReferenceComponent>().Weapon;
                Health -= weapon.Damage;
                var killed = Health <= 0;
                if (killed)
                {
                    Explode();
                }
                else if (weapon.Damage > 0)
                {
                    Hit();
                }
                weapon.OnHit(target: this, killed: killed, bulletNode: bulletNode);
            }
        }
Exemplo n.º 6
0
        private void Grip(NodeCollisionStartEventArgs e)
        {
            if (!IsGripping)
            {
                _gripping = e.OtherNode;

                //create constraint
                if (ProducesConstraint)
                {
                    //store gripped objects values
                    _grippingBody      = e.OtherBody;
                    _grippingKinematic = e.OtherBody.Kinematic;
                    _grippingParent    = e.OtherNode.Parent;

                    //connect to the gripper
                    e.OtherNode.Parent    = Node;
                    e.OtherBody.Kinematic = true;

                    //call event
                    Gripping?.Invoke(_gripping);
                }
            }
        }
Exemplo n.º 7
0
 void onCollided(NodeCollisionStartEventArgs e)
 {
     Crashed?.Invoke();
 }