public GameObject(World world, String name, String textureName, Vector2 position, Vector2 position2, float width, float height, BodyType type, bool drawable, BodyShape shape) { this.Name = name; if (textureName != null) { this.texture = EngineContentManager.GetTexture(textureName); } this.textureName = textureName; this.position = position; this.position2 = position2; this.width = width; this.height = height; this.type = type; this.drawable = drawable; this.shape = shape; if (world != null) { CreateBody(world); this.body.BodyType = type; body.CollisionCategories = Category.All; } else { body = null; } }
public string register(string userName, string password, string firstName, string lastName, string phoneNumber, string city, string street, string postcode, string shoulders, string bust, string waist, string hips) { User user = new User(); BodyShape bs = new BodyShape(); int affected; JavaScriptSerializer serializer = new JavaScriptSerializer(); string rows; string userBodyShape = ""; if (shoulders != "" && bust != "" && waist != "" && hips != "") { userBodyShape = bs.calcBodyShapeAlgorithem(Convert.ToDouble(shoulders), Convert.ToDouble(bust), Convert.ToDouble(waist), Convert.ToDouble(hips)); } affected = user.register(userName, password, firstName, lastName, phoneNumber, city, street, postcode, userBodyShape); if (affected == 1) { rows = userBodyShape; } else { rows = "Unexpected Error"; } //Context.Response.Clear(); //Context.Response.ContentType = "application/json"; //Context.Response.Write(rows); //Context.Response.Flush(); //Context.Response.End(); return(rows); }
/// <summary> /// Creates a collidable edge with no texture /// </summary> /// <param name="world">World the object belongs to</param> /// <param name="name">Name of the object</param> /// <param name="start">Start point of the edge</param> /// <param name="end">End point of the edge</param> public GameObject(World world, String name, Vector2 start, Vector2 end) { this.Name = name; this.position = start; this.position2 = end; this.shape = BodyShape.Edge; body = BodyFactory.CreateEdge(world, start, end, name); }
public string getBodyShape(BodyShape bShape) { string bodyShape = ""; bodyShape = calcBodyShapeAlgorithem(bShape.shoulders, bShape.bust, bShape.waist, bShape.hip); return(bodyShape); }
public void getFits(string bShape) { BodyShape bshape = new BodyShape(); JavaScriptSerializer serializer = new JavaScriptSerializer(); List <Dictionary <string, object> > rows = new List <Dictionary <string, object> >(); rows = bshape.getFits(bShape); Context.Response.Clear(); Context.Response.ContentType = "application/json"; Context.Response.Write(serializer.Serialize(rows)); Context.Response.Flush(); Context.Response.End(); }
public BodyShapeController( ILogger <BodyShapeController> logger, IHttpContextAccessor httpContextAccessor, BodyShape MyBodyShape ) { _logger = logger; _questions = MyBodyShape; _httpContextAccessor = httpContextAccessor; ClaimsPrincipal currentUser = this.User; _user = (from c in _httpContextAccessor.HttpContext.User.Claims where c.Type == "UserID" select c.Value).FirstOrDefault() ; }
private GameObject RenderBody(BodyShape bodyShape) { switch (bodyShape) { case BodyShape.Capsule: return(GameObject.CreatePrimitive(PrimitiveType.Capsule)); case BodyShape.Cylinder: return(GameObject.CreatePrimitive(PrimitiveType.Cylinder)); case BodyShape.Cube: return(GameObject.CreatePrimitive(PrimitiveType.Cube)); case BodyShape.Sphere: default: return(GameObject.CreatePrimitive(PrimitiveType.Sphere)); } }
/// <summary> /// Renders the currently selected step /// </summary> /// <param name="rStep"></param> private bool DrawDetailItem(BodyShape rShape) { if (rShape == null) { return(false); } bool lIsDirty = false; bool lIsShapeDirty = rShape.OnInspectorGUI(); if (lIsShapeDirty) { lIsDirty = true; mTarget.SerializeBodyShapes(); } return(lIsDirty); }
/// <summary> /// Allows us to stop before removing the item /// </summary> /// <param name="rList"></param> private void OnListItemRemove(ReorderableList rList) { if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete the item?", "Yes", "No")) { int lIndex = rList.index; BodyShape lShape = mTarget.BodyShapes[lIndex]; lShape.DestroyUnityColliders(); mTarget.BodyShapes.RemoveAt(lIndex); rList.index--; if (mTarget.EditorBodyShapeIndex >= rList.count) { mTarget.EditorBodyShapeIndex = rList.count - 1; } mIsDirty = true; mTarget.SerializeBodyShapes(); } }
/// <summary> /// Called to stop the motion. If the motion is stopable. Some motions /// like jump cannot be stopped early /// </summary> public override void Deactivate() { mClimbable = null; // Re-enable actor controller processing mActorController.IsGravityEnabled = true; mActorController.IsCollsionEnabled = true; mActorController.FixGroundPenetration = true; mActorController.SetGround(null); BodyShape lBodyShape = mActorController.GetBodyShape("Combatant Shape"); if (lBodyShape != null) { lBodyShape.IsEnabledOnGround = true; lBodyShape.IsEnabledOnSlope = true; lBodyShape.IsEnabledAboveGround = true; } // Finish the deactivation process base.Deactivate(); }
public Creature(GameObject parent = null) { _seed = (uint)Mathf.Floor(Random.value * uint.MaxValue); _sequence = Convert.ToString(_seed, 2); _scale = Mathf.Clamp(ReadAsNormalizedFloat(13), 0.1f, 1.0f); _bodyShape = ReadAsEnum <BodyShape>(22); _isFlying = ReadAsBool(30); _mass = Mathf.Clamp(ReadAsNormalizedFloat(5) * 2.0f * _scale, MinimumMass, 10.0f); if (_isFlying) { _mass /= 3.0f; } _speed = ReadAsNormalizedFloat(16) / (_scale * _mass); _root = new GameObject(); if (parent != null) { _root.transform.parent = parent.transform; } var body = RenderBody(_bodyShape); body.transform.parent = _root.transform; _root.transform.localScale = Vector3.one * _scale; var position = Random.insideUnitSphere * 50.0f; position.y = Mathf.Clamp(position.y, 2.0f, 50.0f); _root.transform.position = position; _rigidBody = body.AddComponent <Rigidbody>(); _rigidBody.mass = _mass; //_rigidBody.drag = ReadAsNormalizedFloat(6) * 1.5f + 1.5f; Renderer bodyRenderer = body.GetComponent <Renderer>(); var material = new Material(Shader.Find("Standard")); material.color = ReadAsRgbColor(5); material.SetFloat("_Metallic", ReadAsNormalizedFloat(7)); material.SetFloat("_Glossiness", ReadAsNormalizedFloat(19)); bodyRenderer.material = material; }
/// <summary> /// Allows us to add to a list /// </summary> /// <param name="rList"></param> private void OnListItemAdd(ReorderableList rList) { if (mBodyShapeIndex >= mBodyShapeTypes.Count) { return; } BodyShape lShape = Activator.CreateInstance(mBodyShapeTypes[mBodyShapeIndex]) as BodyShape; lShape.Name = mBodyShapeNames[mBodyShapeIndex]; lShape._Parent = mTarget.transform; if (lShape._UseUnityColliders) { lShape.CreateUnityColliders(); } mTarget.BodyShapes.Add(lShape); mList.index = mTarget.BodyShapes.Count - 1; mTarget.EditorBodyShapeIndex = rList.index; mIsDirty = true; mTarget.SerializeBodyShapes(); }
public string calcBodyShapeAlgorithem(double shoulders, double bust, double waist, double hips) { BodyShape bShape = new BodyShape(); return(bShape.calcBodyShapeAlgorithem(shoulders, bust, waist, hips)); }
/// <summary> /// Init the specified body and sprite. /// </summary> /// <param name='body'> /// Body. /// </param> /// <param name='sprite'> /// Sprite. /// </param> public void InitNode(FSprite sprite, BodyShape shape) { _sprite = sprite; CreateBody(shape); }
public FPStaticBody(FSprite sprite, BodyShape shape = BodyShape.SQUARE) { _sprite = sprite; InitNode(_sprite, shape); }
public override void AddComponent(Component component, float x, float y, BodyShape shape, BodyType bodyType, Category category) { base.AddComponent(component, x + this.adjust.X, y + this.adjust.Y, shape, bodyType, category); }
/// <summary> /// Called to start the specific motion. If the motion /// were something like 'jump', this would start the jumping process /// </summary> /// <param name="rPrevMotion">Motion that this motion is taking over from</param> public override bool Activate(MotionControllerMotion rPrevMotion) { // Ensure we have good collision info if (mRaycastHitInfo.collider == null) { return(false); } //_IsGravityEnabled = false; //mIsGroundedExpected = false; mStartPosition = mActorController._Transform.position; // Track the object we're trying to climb and store it mClimbable = mRaycastHitInfo.collider.gameObject; // Disable actor controller processing for a short time mActorController.IsGravityEnabled = false; mActorController.FixGroundPenetration = false; mActorController.SetGround(mClimbable.transform); BodyShape lBodyShape = mActorController.GetBodyShape("Combatant Shape"); if (lBodyShape != null) { lBodyShape.IsEnabledOnGround = false; lBodyShape.IsEnabledOnSlope = false; lBodyShape.IsEnabledAboveGround = false; } Vector3 lClimbForward = Quaternion.AngleAxis(180, mActorController._Transform.up) * mRaycastHitInfo.normal; mFaceClimbableNormalAngle = mActorController._Transform.forward.HorizontalAngleTo(lClimbForward, mActorController._Transform.up); mFaceClimbableNormalAngleUsed = 0f; // Setup the reach data and clear any current values ClearReachData(); // Set the animator in motion if (mRaycastHitInfo.distance < 1f) { //Quaternion lWallHitRotation = Quaternion.LookRotation(-mRaycastHitInfo.normal, mActorController._Transform.up); Quaternion lWallHitRotation = mActorController._Transform.rotation; MotionReachData lReachData = MotionReachData.Allocate(); lReachData.StateID = STATE_StandClimb_2_5m; lReachData.StartTime = 0.445f; lReachData.EndTime = 0.524f; lReachData.Power = 4; lReachData.ReachTarget = mRaycastHitInfo.point + (mActorController._Transform.rotation * _ReachOffset1) + (lWallHitRotation * _ReachOffset2); lReachData.ReachTargetGround = mActorController.State.Ground; mReachData.Add(lReachData); lReachData = MotionReachData.Allocate(); lReachData.StateID = STATE_StandClimb_2_5m; lReachData.StartTime = 0.6f; lReachData.EndTime = 0.8f; lReachData.Power = 4; lReachData.ReachTarget = mRaycastHitInfo.point + (lWallHitRotation * _ReachOffset3); lReachData.ReachTargetGround = mActorController.State.Ground; mReachData.Add(lReachData); lReachData = MotionReachData.Allocate(); lReachData.StateID = STATE_ClimbToIdle; lReachData.StartTime = 0.0f; lReachData.EndTime = 0.5f; lReachData.Power = 4; lReachData.ReachTarget = mRaycastHitInfo.point + (lWallHitRotation * _ReachOffset4); lReachData.ReachTargetGround = mActorController.State.Ground; mReachData.Add(lReachData); mMotionController.SetAnimatorMotionPhase(mMotionLayer._AnimatorLayerIndex, PHASE_START_CLOSE, true); } else { //Quaternion lWallHitRotation = Quaternion.LookRotation(-mRaycastHitInfo.normal, mActorController._Transform.up); Quaternion lWallHitRotation = mActorController._Transform.rotation; MotionReachData lReachData = MotionReachData.Allocate(); lReachData.StateID = STATE_Climb_2_5m; lReachData.StartTime = 0.0f; lReachData.EndTime = 0.1f; lReachData.Power = 3; lReachData.ReachTarget = mRaycastHitInfo.point + (mActorController._Transform.rotation * _ReachOffset5) + (lWallHitRotation * new Vector3(0.0f, 0f, 0f)); lReachData.ReachTargetGround = mActorController.State.Ground; mReachData.Add(lReachData); lReachData = MotionReachData.Allocate(); lReachData.StateID = STATE_Climb_2_5m; lReachData.StartTime = 0.1f; lReachData.EndTime = 0.216f; lReachData.Power = 3; lReachData.ReachTarget = mRaycastHitInfo.point + (mActorController._Transform.rotation * _ReachOffset6) + (lWallHitRotation * new Vector3(0.0f, 0f, 0f)); lReachData.ReachTargetGround = mActorController.State.Ground; mReachData.Add(lReachData); lReachData = MotionReachData.Allocate(); lReachData.StateID = STATE_Climb_2_5m; lReachData.StartTime = 0.240f; lReachData.EndTime = 0.420f; lReachData.Power = 4; lReachData.ReachTarget = mRaycastHitInfo.point + (mActorController._Transform.rotation * _ReachOffset7); lReachData.ReachTargetGround = mActorController.State.Ground; mReachData.Add(lReachData); lReachData = MotionReachData.Allocate(); lReachData.StateID = STATE_ClimbToIdle; lReachData.StartTime = 0.0f; lReachData.EndTime = 0.5f; lReachData.Power = 4; lReachData.ReachTarget = mRaycastHitInfo.point + (lWallHitRotation * _ReachOffset8); lReachData.ReachTargetGround = mActorController.State.Ground; mReachData.Add(lReachData); mMotionController.SetAnimatorMotionPhase(mMotionLayer._AnimatorLayerIndex, PHASE_START, true); } // Return return(base.Activate(rPrevMotion)); }
private void CreateBody(BodyShape shape) { if (shape == BodyShape.CIRCLE) { _body = GameObject.CreatePrimitive(PrimitiveType.Sphere); } else { _body = GameObject.CreatePrimitive(PrimitiveType.Cube); } _body.AddComponent<FPFixture>(); _fixture = _body.GetComponent("FPFixture") as FPFixture; _fixture.sprite = _sprite; _fixture.body = _body; _body.transform.position = new Vector3(_sprite.x, _sprite.y, FPhysics.physicsDepth); _body.transform.localScale = new Vector3(_sprite.localRect.width * _sprite.scaleX,_sprite.localRect.height*_sprite.scaleY,FPhysics.defaultObjectThickness); }
public FPRigidBody(FSprite sprite, BodyShape shape = BodyShape.SQUARE) { _sprite = sprite; InitNode(_sprite, shape); CreateRigidBody(); }
void Start() { shape = new BodyShape(this.gameObject); }