public static void ChainUp(List <Pax4ObjectPhysicsPart> p_physicsPartList, bool p_endPositionFixed = false) { if (p_physicsPartList == null || p_physicsPartList.Count <= 0) { return; } Pax4ObjectPhysicsPart chainLink0 = null; Pax4ObjectPhysicsPart chainLink1 = null; chainLink0 = p_physicsPartList[0]; for (int i = 1; i < p_physicsPartList.Count; i++) { chainLink1 = p_physicsPartList[i]; Vector3 hingePositionParent = (chainLink1.GetPosition() - chainLink0.GetPosition()) / 2.0f;; chainLink0.CreateHingeJoint(chainLink1, true, hingePositionParent, Pax4ObjectPhysicsPart._defaultHingeAxis); chainLink0 = chainLink1; } if (p_endPositionFixed) { p_physicsPartList[p_physicsPartList.Count - 1].EnableConstraint(); } }
public void CreateHingeJoint(Pax4ObjectPhysicsPart p_child, bool p_disableChildController, JVector p_hingePositionParent, JVector p_hingeAxis) { if (_body == null || p_child == null) { return; } if (_hingeJoint == null) { _hingeJoint = new Dictionary <Pax4ObjectPhysicsPart, HingeJoint>(); } if (p_disableChildController) { p_child.DisableConstraint(); } HingeJoint hingeJoint = new HingeJoint(Pax4World._current._physicsSystem, this._body, p_child._body, p_hingePositionParent, p_hingeAxis); p_child._hingeJointParent = this; _hingeJoint.Add(p_child, hingeJoint); }
public Pax4ConstraintCameraChase(Pax4ObjectPhysicsPart p_physicsPart, Vector3 p_cameraPosition) : base(p_physicsPart._body, null) { _cameraPosition = p_cameraPosition; SetPhysicsPart(p_physicsPart); }
public Pax4ConstraintWayPoint(Pax4ObjectPhysicsPart p_physicsPart, float p_velocityFactor, Pax4WayPointPath p_wayPointPath = null, int p_wayPointIndex = 0) : base() { _velocityFactor = p_velocityFactor; _wayPointPath = p_wayPointPath; _wayPointIndex = p_wayPointIndex; SetPhysicsPart(p_physicsPart, p_wayPointIndex); }
public Pax4ConstraintBodyVector(Pax4ObjectPhysicsPart p_physicsPart, float p_velocityFactor, Vector3 p_bodyVector) : base(p_physicsPart._body, null) { _velocityFactor = p_velocityFactor; _bodyVector = Pax4Tools.ToJVector(p_bodyVector); _bodyVector.Normalize(); SetPhysicsPart(p_physicsPart); }
public void SetPhysicsPart(Pax4ObjectPhysicsPart p_physicsPart) { if (p_physicsPart == null) { return; } _physicsPart = p_physicsPart; _physicsPart.AddConstraint(this); }
public virtual bool HandleCollisionDetection(CollisionSkin p_this, CollisionSkin p_other) { if (_dxRequested) { return(false); } Pax4ObjectPhysicsPart other = (Pax4ObjectPhysicsPart)p_other._pax4Object; if (((Pax4Actor)other)._actorType == EActorType._ENEMY || ((Pax4Actor)other)._actorType == EActorType._WORLD) { return(false); } return(true); }
public void SetPhysicsPart(Pax4ObjectPhysicsPart p_physicsPart, int p_wayPointIndex = 0) { if (p_physicsPart == null) { return; } p_physicsPart.DisableConstraint(); _physicsPart = p_physicsPart; _physicsPart.AddConstraint(this); if (_wayPointPath == null) { return; } _wayPointIndex = p_wayPointIndex; _worldHeading = _wayPointPath._wayPoint[_wayPointIndex] - _physicsPart._body.Position; _currentDistance = _worldHeading.Length(); }
public void UpdateSelectedObject() { //if (Pax4Touch._current._currentTouchState._oneTap) if (Pax4Touch._current._currentTouchState._clean && Pax4Touch._current._currentTouchState._oneTap) { JVector rayOrigin; JVector rayDirection; Pax4Tools.RayTo(Pax4Touch._current._currentTouchState._xy.X, Pax4Touch._current._currentTouchState._xy.Y, out rayOrigin, out rayDirection); RigidBody body; JVector hitNormal; JVector hitPoint; float hitDistance = 0.0f; float fraction; rayDirection *= Pax4Camera._current._farPlane; bool result = _physicsSystem.CollisionSystem.Raycast(rayOrigin, rayDirection, //at this point it's a full length ray ;) RaycastCallback, out body, out hitNormal, out fraction); _selectedPhysicsPart = null; if (result) { hitPoint = rayOrigin + fraction * rayDirection; hitDistance = (hitPoint - rayOrigin).Length(); _selectedPhysicsPart = (Pax4ObjectPhysicsPart)body._paxState; } } }
public void DisableHingeJoint(Pax4ObjectPhysicsPart p_child = null) { if (_hingeJoint == null) { return; } if (p_child != null) { if (_hingeJoint.ContainsKey(p_child)) { _hingeJoint[p_child].Deactivate(); _hingeJoint.Remove(p_child); } } else { foreach (KeyValuePair <Pax4ObjectPhysicsPart, HingeJoint> kvp in _hingeJoint) { kvp.Value.Deactivate(); } } }
public Pax4ConstraintWayPointAirplane(Pax4ObjectPhysicsPart p_physicsPart, float p_velocityFactor, Vector3 p_angularVelocityFactor, Pax4WayPointPath p_wayPointPath = null, int p_wayPointIndex = 0) : base(p_physicsPart, p_velocityFactor, p_wayPointPath, p_wayPointIndex) { _worldAngularVelocityFactor = p_angularVelocityFactor; }
public Pax4WayPointControllerActor(Pax4ObjectPhysicsPart p_physicsPart, float p_velocityFactor, Pax4WayPointPath p_wayPointPath = null, int p_wayPointIndex = 0) : base(p_physicsPart, p_velocityFactor, p_wayPointPath, p_wayPointIndex) { }
public virtual bool HandleCollisionDetection(CollisionSkin p_this, CollisionSkin p_other) { if (_dxRequested) { return(false); } Pax4ObjectPhysicsPart other = (Pax4ObjectPhysicsPart)p_other._pax4Object; if (((Pax4Actor)other)._actorType == EActorType._WORLD) { return(true); } Vector3 effectPosition = Pax4Tools.WorldToScreen(other._body.Position); if (((Pax4Actor)other)._actorType != EActorType._PLAYER) { if (this._actorElementType != ((Pax4Actor)other)._actorElementType) { this._health -= _normalHealthStep; if (this._health <= 0.0f) { this.RequestDx(); } if (this._actorPowerUp == EActorPowerUp._DURABILITY) { if (this._actorElementType == EActorType._LAVA) { ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceBurning1.Play(); } else if (this._actorElementType == EActorType._ICE) { ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceFreezing1.Play(); } return(HandleCollisionDetectionOther(effectPosition, (Pax4Actor)other, _durabilityHealthStep)); } else if (this._actorPowerUp == EActorPowerUp._NORMAL) { if (((Pax4Actor)other)._actorPowerUp != EActorPowerUp._NULL && ((Pax4Actor)other)._actorClassType == EActorType._AMMO) { if (this == Pax4ActorPlayerAmmoLava._current) { Pax4ActorPlayerAmmoLava._powerUp = ((Pax4Actor)other)._actorPowerUp; } else if (this == Pax4ActorPlayerAmmoIce._current) { Pax4ActorPlayerAmmoIce._powerUp = ((Pax4Actor)other)._actorPowerUp; } } return(HandleCollisionDetectionOther(effectPosition, (Pax4Actor)other, _normalHealthStep)); } } else// (this._actorElementType == other._actorElementType) { if (this._actorElementType == EActorType._LAVA) { ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceBurning.Play(); } else if (this._actorElementType == EActorType._ICE) { ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceFreezing.Play(); } this._health -= _similarHealthStep; if (this._health <= 0.0f) { this.RequestDx(); } if (_similarHealthStep >= 1.0f) { return(HandleCollisionDetectionOther(effectPosition, (Pax4Actor)other, _durabilityHealthStep)); } else if (this._actorPowerUp == EActorPowerUp._DURABILITY) { return(false); } } } else if (((Pax4Actor)other)._actorType == EActorType._PLAYER && Pax4ActorPlayerAmmoLava._current._launched && Pax4ActorPlayerAmmoIce._current._launched) { ((Pax4ParticleEffectLavaAndIce)Pax4ParticleEffect._current)._particleEffectScore300.Trigger(ref effectPosition); ((Pax4ParticleEffectLavaAndIce)Pax4ParticleEffect._current)._particleEffectScoreHelpingHand.Trigger(ref effectPosition); Pax4UiStateLavaAndIceMission._currentMissionState._scoreSpriteModifier.Ini(((Pax4WorldLavaAndIce)Pax4World._current)._score, ((Pax4WorldLavaAndIce)Pax4World._current)._score + 300, true, 1.0f); Pax4UiStateLavaAndIceMission._currentMissionState._scoreSpriteModifier.Trigger(); ((Pax4WorldLavaAndIce)Pax4World._current)._score += 300; } return(true); }