示例#1
0
            public void PossibleDirtyObjectContagion(object targetObject)
            {
                if (targetObject == null)
                {
                    return;
                }
                Sim sim = targetObject as Sim;

                if (sim != null)
                {
                    Posture posture = sim.Posture;
                    if (posture != null)
                    {
                        targetObject = posture.Container;
                    }
                }
                //foreach (Type sDirtyObjectType in sDirtyObjectTypes)
                //{
                //	if (sDirtyObjectType.IsAssignableFrom(targetObject.GetType()))
                //	{
                //		PossiblyGetSick(HealthManager.kInteractSicknessOdds);
                //		break;
                //	}
                //}
            }
    public void Reset()
    {
        UnlockAllAxes();
        enableAutomaticAxisLockingWhenIdle = true;

        groundChecker.Reset();
        netImpulseForce               = Vector2.zero;
        penguinRigidBody.velocity     = Vector2.zero;
        penguinRigidBody.position     = initialSpawnPosition;
        penguinRigidBody.isKinematic  = false;
        penguinRigidBody.useAutoMass  = false;
        penguinRigidBody.mass         = mass;
        penguinRigidBody.centerOfMass = new Vector2(centerOfMassX, centerOfMassY);

        xMotionIntensity = 0.00f;
        penguinAnimator.applyRootMotion = true;
        penguinAnimator.updateMode      = AnimatorUpdateMode.Normal;
        ClearVerticalMovementTriggers();

        TurnToFace(Facing.RIGHT);
        UpdateAnimatorParameters();

        // align penguin with surface normal in a single update
        posture = Posture.UPRIGHT;
        groundChecker.CheckForGround(fromPoint: ComputeReferencePoint(), extraLineHeight: torsoCollider.bounds.extents.y);
        Vector2 targetUpAxis = groundChecker.WasDetected ? groundChecker.SurfaceNormalOfLastContact : Vector2.up;

        AlignPenguinWithUpAxis(targetUpAxis, forceInstantUpdate: true);
        groundChecker.Reset();
    }
        public TrainingPage()
        {
            InitializeComponent();

            this.Loaded += (s, e) => {
                this.timer.Elapsed += new ElapsedEventHandler(TimerCountDown);
                this.timer.Interval = 1000;

                //DataMessageQueue messageQueue = new ServerChannelDataMessageQueue();
                DataMessageQueue messageQueue = CommonDataMessageQueue.getInstance();

                this.consumer = new SkeletonDataComsumer(messageQueue, (vectors) => {
                    Posture pos = new Posture(PostureType.Both, vectors);
                    Dispatcher.Invoke(() => PostureDataReady(pos));
                });

                String[] trainingNames = service.getTrainingNames(0);
                foreach (String trainingName in trainingNames)
                {
                    TrainingNameSelect.Items.Add(trainingName);
                }
            };

            this.Unloaded += (s, e) => {
                timer.Dispose();
            };
        }
示例#4
0
 protected override void onUpdate(GameTime gameTime)
 {
     this.skeleton = this.kinect.skeleton;
     if (this.skeleton != null)
     {
         if (this.posture != null)
         {
             this.posture.joints = Posture.castSkeletonToJoints(this.skeleton);
         }
         else
         {
             this.posture = new Posture(this.skeleton);
         }
     }
     // IMPORTANT:
     // FIX: ARREGLAR ESTO PARA QUE CALCULE LOS ERRORES Y LA DIFICULTAD LA DE DESDE UNA CAPA MAS ARRIBA...
     if (postureToCompare != null && this.posture != null)
     {
         this.posture.compareTo(this.postureToCompare, ref accuracy, 0.07f, 0.058f);
     }
     else
     if (this.kinect.skeleton != null)
     {
         accuracy = new double[20] {
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
         }
     }
     ;
 }
示例#5
0
 private void GoToIns()
 {
     Ins.SetActive(true);
     Posture.SetActive(false);
     TutorialCameraController.myCameraState = TutorialCameraController.CameraState.App;
     //HintPosInsBack 暂时不用
 }
 public ActionResult AddEdit(int?id, Posture model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             bool isNew = false;
             //FeedFooder feed = isNew ? new FeedFooder { } : _repo.GetById(id.Value);
             // feed = model;
             if (!id.HasValue)
             {
                 model.UpdatedBy = "admin";
                 isNew           = true;
             }
             if (isNew)
             {
                 model.Id        = 0;
                 model.UpdatedAt = DateTime.Now;
                 _repo.Postures.Insert(model);
                 _repo.Save();
             }
             else
             {
                 _repo.Postures.Update(model);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(RedirectToAction("Index"));
 }
示例#7
0
        /// <summary>
        /// Moves the camera based on player input.
        /// </summary>
        /// <param name="direction">Direction moved.</param>
        /// <param name="elapsedTimeSec">Elapsed game time.</param>
        public void UpdatePosition(ref Vector3 direction, float elapsedTimeSec)
        {
            if (currentVelocity.LengthSquared() != 0.0f)
            {
                // Only move the camera if the velocity vector is not of zero
                // length. Doing this guards against the camera slowly creeping
                // around due to floating point rounding errors.

                Vector3 displacement = (currentVelocity * elapsedTimeSec) +
                                       (0.5f * acceleration * elapsedTimeSec * elapsedTimeSec);

                // Floating point rounding errors will slowly accumulate and
                // cause the camera to move along each axis. To prevent any
                // unintended movement the displacement vector is clamped to
                // zero for each direction that the camera isn't moving in.
                // Note that the UpdateVelocity() method will slowly decelerate
                // the camera's velocity back to a stationary state when the
                // camera is no longer moving along that direction. To account
                // for this the camera's current velocity is also checked.

                if (direction.X == 0.0f && (float)Math.Abs(currentVelocity.X) < 1e-6f)
                {
                    displacement.X = 0.0f;
                }

                if (direction.Y == 0.0f && (float)Math.Abs(currentVelocity.Y) < 1e-6f)
                {
                    displacement.Y = 0.0f;
                }

                if (direction.Z == 0.0f && (float)Math.Abs(currentVelocity.Z) < 1e-6f)
                {
                    displacement.Z = 0.0f;
                }

                Move(displacement.X, displacement.Y, displacement.Z);

                switch (posture)
                {
                case Posture.Standing:
                    break;

                case Posture.Rising:
                    if (eye.Y > eyeHeightStanding)
                    {
                        eye.Y             = eyeHeightStanding;
                        posture           = Posture.Standing;
                        currentVelocity.Y = 0.0f;
                    }
                    break;
                }
            }

            // Continuously update the camera's velocity vector even if the
            // camera hasn't moved during this call. When the camera is no
            // longer being moved the camera is decelerating back to its
            // stationary state.

            UpdateVelocity(ref direction, elapsedTimeSec);
        }
示例#8
0
    bool StandUp()
    {
        // Check if standing up is possible
        bool canStandUp = true;

        if (currentPosture == Posture.crouching)
        {
            canStandUp = !CheckForCeiling(1.71f);
            Debug.Log("Can Stand up from crouch: " + canStandUp);
        }
        else if (currentPosture == Posture.proning)
        {
            canStandUp = !CheckForCeiling(1.71f);
        }

        // Perform standing up
        if (!canStandUp)
        {
            Debug.Log("Cannot stand up, ceiling too low! Du hasch koin blatz nedda, bisch zu fett");
            return(false);
        }

        // TODO: Switch Colliders, animate Character
        postureCollider[0].enabled = true;
        postureCollider[1].enabled = false;
        postureCollider[2].enabled = false;
        Debug.Log("Stood up");
        currentPosture = ChangePostureImg(Posture.standing);

        speedValue = moveSettings.walkVelocity;
        return(true);
    }
示例#9
0
    public void InitializeCharacter(CharacterIdentity ci)
    {
        characterIdentity = ci;
        trans             = model.GetComponent <Transform>();
        rigid             = GetComponent <Rigid>();

        mState      = new IdleState();
        mDelayState = new IdleDelayState();

        gameSystemState = SystemOrder.NOTHING;
        inputOrder      = InputOrder.stand;
        attackOrder     = -1;
        walkDirection   = new Vector3(0, 0, 0);
        sightRotation   = new Vector3(0, 0, 0);

        posture     = new Posture(this);
        walkPhase   = 0;
        attackPhase = 0;

        holdingItemIndex = -1;

        if (characterIdentity.isPlayer)
        {
            GetComponent <Basic>().mManager.allManager.SetCamera(gameObject);
            posture.BecomeInvisible();

            targetCharacter = null;
        }
        else
        {
            targetCharacter = GetComponent <Basic>().mManager.allManager.player;
        }
    }
示例#10
0
 public bool PostureDetector(Posture posture)
 {
     if (postureStart != posture)
     {
         accumulator  = 0;
         postureStart = posture;
         return(false);
     }
     if (accumulator < PostureDetectionNumber)
     {
         accumulator++;
         return(false);
     }
     if (posture != postureInitial)
     {
         accumulator    = 0;
         postureInitial = posture;
         return(true);
     }
     else
     {
         accumulator = 0;
     }
     return(false);
 }
示例#11
0
 //algoritmo que permite detectar postura
 bool PostureDetector(Posture posture)
 {
     if (postureInDetection != posture)
     {
         accumulator        = 0;
         postureInDetection = posture;
         return(false);
     }
     if (accumulator < PostureDetectionNumber)
     {
         accumulator++;
         return(false);
     }
     if (posture != previousPosture)
     {
         previousPosture = posture;
         accumulator     = 0;
         return(true);
     }
     else
     {
         accumulator = 0;
     }
     return(false);
 }
示例#12
0
        public void getHunch()
        {
            double x1 = body.Joints[JointType.Head].Position.X * Math.Sin(shouldersAngle);
            double z1 = body.Joints[JointType.Head].Position.Z * Math.Cos(shouldersAngle);

            double x2 = body.Joints[JointType.SpineShoulder].Position.X * Math.Sin(shouldersAngle);
            double z2 = body.Joints[JointType.SpineShoulder].Position.Z * Math.Cos(shouldersAngle);



            double distanceShoulders = Math.Sqrt((body.Joints[JointType.ShoulderRight].Position.X - body.Joints[JointType.ShoulderLeft].Position.X) *
                                                 (body.Joints[JointType.ShoulderRight].Position.X - body.Joints[JointType.ShoulderLeft].Position.X) +
                                                 (body.Joints[JointType.ShoulderRight].Position.Z - body.Joints[JointType.ShoulderLeft].Position.Z) *
                                                 (body.Joints[JointType.ShoulderRight].Position.Z - body.Joints[JointType.ShoulderLeft].Position.Z));



            if (-x1 + z1 < -x2 + z2 - distanceShoulders * 0.05)
            {
                hunch       = true;
                bodyPosture = Posture.bad;
                PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.HUNCHBACK);
                currentMistakes.Add(pa);
            }
            else
            {
                hunch = false;
            }
        }
示例#13
0
        public void getLeftHandUnderHip()
        {
            double x1 = body.Joints[JointType.HandLeft].Position.X * Math.Cos(shouldersAngle);
            double z1 = body.Joints[JointType.HandLeft].Position.Z * Math.Sin(shouldersAngle);

            double x2 = body.Joints[JointType.HipLeft].Position.X * Math.Cos(shouldersAngle);
            double z2 = body.Joints[JointType.HipLeft].Position.Z * Math.Sin(shouldersAngle);

            double x3 = (body.Joints[JointType.HipLeft].Position.X - body.Joints[JointType.HipRight].Position.X)
                        * (body.Joints[JointType.HipLeft].Position.X - body.Joints[JointType.HipRight].Position.X);
            double z3 = (body.Joints[JointType.HipLeft].Position.Z - body.Joints[JointType.HipRight].Position.Z)
                        * (body.Joints[JointType.HipLeft].Position.Z - body.Joints[JointType.HipRight].Position.Z);
            double length1 = Math.Sqrt(x3 + z3);

            if (body.Joints[JointType.HandTipLeft].Position.Y < body.Joints[JointType.HipLeft].Position.Y &&
                x2 - z2 < x1 - z1 + length1 * .01)
            {
                leftHandUnderHips = true;
                bodyPosture       = Posture.bad;
                PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LEFTHANDUNDERHIP);
                currentMistakes.Add(pa);
            }
            else
            {
                leftHandUnderHips = false;
            }
        }
示例#14
0
        public static Posture CalculatePosture(TransformMatrix ACS, TransformMatrix Inertia, TransformMatrix BoneRelMotion)
        {
            Posture post = new Posture();

            TransformMatrix AnatIner = ACS.Inverse() * BoneRelMotion * Inertia;

            double[] myInertia = { 0, 0, 0 };
            for (int i = 0; i < 3; i++)
            {
                myInertia[i] = AnatIner.Array[i][POS_AXIS]; //select which axis to use....
            }
            double x = PROJ_PLANES_SIGN[0] * myInertia[PROJ_PLANES[0]];
            double y = PROJ_PLANES_SIGN[1] * myInertia[PROJ_PLANES[1]];
            double z = PROJ_PLANES_SIGN[2] * myInertia[PROJ_PLANES[2]];
            CartesianCoordinate coord = cart2spherical(x, y, z);
            double theta = coord.az;
            double phi   = coord.elev;

            //if (PROJ_PLANES == {1, 3, -2}...
            theta = (theta / Math.Abs(theta)) * Math.PI - theta;
            //endif

            post.FE_Raw = theta * 180 / Math.PI;
            post.RU_Raw = phi * 180 / Math.PI;

            post.FE = post.FE_Raw - NEUTRAL_FE_POSITION;
            post.RU = post.RU_Raw - NEUTRAL_RU_POSITION;
            return(post);
        }
        public GameTrainingPage()
        {
            InitializeComponent();

            this.Loaded += (s, e) => {
                serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPAddress ip       = IPAddress.Parse("127.0.0.1");
                EndPoint  endPoint = new IPEndPoint(ip, 6000);
                serverSocket.Bind(endPoint);
                serverSocket.Listen(1);

                //DataMessageQueue messageQueue = new ServerChannelDataMessageQueue();
                DataMessageQueue messageQueue = CommonDataMessageQueue.getInstance();

                this.consumer = new SkeletonDataComsumer(messageQueue, (vectors) => {
                    Posture pos = new Posture(PostureType.Both, vectors);
                    Dispatcher.Invoke(() => PostureDataReady(pos));
                });
            };

            this.Unloaded += (s, e) => {
                if (socket != null)
                {
                    socket.Close();
                }
                if (serverSocket != null)
                {
                    serverSocket.Close();
                }
                if (consumer != null)
                {
                    consumer.stop();
                }
            };
        }
示例#16
0
        public static Posture[] CalculatePosturesFE(Bone CoordinateSystemBone, Bone PositionDefiningBone)
        {
            //First check if we have enough
            if (!CoordinateSystemBone.IsValidBone || !CoordinateSystemBone.HasInertia ||
                !PositionDefiningBone.IsValidBone || !PositionDefiningBone.HasInertia)
            {
                return(null);
            }

            //Lets create an array for the number of postures...
            int numPositions = CoordinateSystemBone.TransformMatrices.Length;

            Posture[] postures = new Posture[numPositions];
            for (int i = 0; i < numPositions; i++)
            {
                postures[i] = CalculatePosture(CoordinateSystemBone.InertiaMatrix, PositionDefiningBone.InertiaMatrix,
                                               CoordinateSystemBone.TransformMatrices[i], PositionDefiningBone.TransformMatrices[i]);

                //need to make certain that only the capitate is corrected
                if (PositionDefiningBone.BoneIndex != (int)WristFilesystem.BIndex.CAP)
                {
                    postures[i].FE = postures[i].FE_Raw;
                    postures[i].RU = postures[i].RU_Raw;
                }
            }
            return(postures);
        }
示例#17
0
        public void analyzePosture()
        {
            currentMistakes = new ArrayList();
            currentGoodies  = new ArrayList();

            bodyPosture = Posture.good;
            getShouldersAngle();
            getArmsCrossed();
            getHunch();
            getRightHandUnderHip();
            getLeftHandUnderHip();
            getRightHandBehindBack();
            getRightArmClosePosture();
            getLeftArmClosePosture();
            getRightLean();
            getLeftLean();
            getResetPosture();
            getLegsCrossed();

            calcMovingHands();
            getArmsAngles();
            searchPause();



            //    calcIsMovingArms();
        }
示例#18
0
    private void ShowCameraBG()
    {
        KararaA.SetActive(false);
        Debug.Log("ShowCameraBG");
        if (AdClick1stTime)
        {
            Posture.SetActive(true);
            Show(CameraBackground);
            ChangeHintPos(HintPosCamera, 3);
            body.sprite = initialBody;
        }
        else
        {
            // set all children
            Posture.SetActive(true);
            Show(CameraBackground);
            CameraBackground.GetComponent <Image>().sprite = cameraBGFull;

            StartCoroutine(ShowShutterHint());


            //身上穿的衣服
            // if(isAlter) {body.sprite = pos0WorkAlter;}
            // else {body.sprite = pos0Work;}

            everything.sprite = null;
            HintScreen.transform.localPosition = HintPosShutter;
        }
    }
示例#19
0
        public SavePostureConstraintResponse SavePostureConstraint(SavePostureConstraintRequest request)
        {
            try
            {
                var postureConstraint = request.MapTo <PostureConstraint>();

                if (request.Id == 0)
                {
                    var posture = new Posture {
                        Id = request.PostureId
                    };
                    DataContext.Postures.Attach(posture);
                    postureConstraint.Posture = posture;
                    foreach (var id in request.RelationIds)
                    {
                        var desiredState = new DesiredState {
                            Id = id
                        };
                        DataContext.DesiredStates.Attach(desiredState);
                        postureConstraint.DesiredStates.Add(desiredState);
                    }
                    DataContext.PostureConstraints.Add(postureConstraint);
                }
                else
                {
                    postureConstraint = DataContext.PostureConstraints.Include(x => x.DesiredStates).First(x => x.Id == request.Id);
                    request.MapPropertiesToInstance <PostureConstraint>(postureConstraint);
                    postureConstraint.DesiredStates = new List <DesiredState>();
                    foreach (var id in request.RelationIds)
                    {
                        var desiredState = DataContext.DesiredStates.Local.FirstOrDefault(x => x.Id == id);
                        if (desiredState == null)
                        {
                            desiredState = new DesiredState {
                                Id = id
                            };
                            DataContext.DesiredStates.Attach(desiredState);
                        }
                        postureConstraint.DesiredStates.Add(desiredState);
                    }
                }
                DataContext.SaveChanges();
                return(new SavePostureConstraintResponse
                {
                    IsSuccess = true,
                    Message = "The item has been saved successfully",
                    Id = postureConstraint.Id,
                    Definition = postureConstraint.Definition,
                    RelationIds = postureConstraint.DesiredStates.Select(x => x.Id).ToArray()
                });
            }
            catch
            {
                return(new SavePostureConstraintResponse
                {
                    IsSuccess = false,
                    Message = "An error occured, please contact the administrator for further information"
                });
            }
        }
示例#20
0
 public void             startInterpolate(Posture goal)
 {
     this.auto_pilot.is_active = true;
     this.auto_pilot.start     = this.getPosture();
     this.auto_pilot.goal      = goal;
     this.auto_pilot.timer     = 0.0f;
 }
示例#21
0
        private void SetPosture(Posture p)
        {
            switch (p)
            {
            case Posture.Run:
                Log.Normal(Entity.Get <Creature>().Posture == Posture.Stand
                                                                ? String.Format("{0} starts to run.", EntityName)
                                                                : String.Format("{0} starts running from a crouch.", EntityName));
                break;

            case Posture.Stand:
                Log.Normal(Entity.Get <Creature>().Posture == Posture.Run
                                                                        ? String.Format("{0} stops running.", EntityName)
                                                                        : String.Format("{0} stands up.", EntityName));
                break;

            case Posture.Crouch:
                Log.Normal(Entity.Get <Creature>().Posture == Posture.Prone
                                                ? String.Format("{0} pushes up into a crouch.", EntityName)
                                                : String.Format("{0} crouches down.", EntityName));
                break;

            case Posture.Prone:
                Log.NormalFormat("{0} goes prone.", EntityName);
                break;

            default:
                throw new ArgumentOutOfRangeException("p");
            }
            Entity.Get <Creature>().Posture = p;
        }
示例#22
0
 internal void ChangePosture(Posture newPosture)
 {
     if (newPosture != Framework.Posture.Unknown)
     {
         Posture = newPosture;
     }
 }
示例#23
0
    public bool ChangePos(Posture CPosture)
    {
        if (_Posture == CPosture || Now_Action_Point <= 0)
        {
            return(false);
        }

        switch (CPosture)
        {
        case Posture.Crouching:
            Now_Action_Point--;
            _Posture       = CPosture;
            Now_Move_Point = Move_Point;
            GetComponent <SpriteRenderer>().sprite = _Pos[1];
            PostureBonus = 5;
            break;

        case Posture.Prone:
            Now_Action_Point--;
            _Posture       = CPosture;
            Now_Move_Point = Move_Point;
            GetComponent <SpriteRenderer>().sprite = _Pos[2];
            PostureBonus = 10;
            break;

        case Posture.Standing:
            Now_Action_Point--;
            _Posture       = CPosture;
            Now_Move_Point = Move_Point;
            GetComponent <SpriteRenderer>().sprite = _Pos[0];
            PostureBonus = 0;
            break;
        }
        return(true);
    }
示例#24
0
        public override string ToString()
        {
            StringBuilder __sb = new StringBuilder("MSimulationResult(");

            __sb.Append(", Posture: ");
            __sb.Append(Posture == null ? "<null>" : Posture.ToString());
            if (Constraints != null && __isset.Constraints)
            {
                __sb.Append(", Constraints: ");
                __sb.Append(Constraints);
            }
            if (Events != null && __isset.Events)
            {
                __sb.Append(", Events: ");
                __sb.Append(Events);
            }
            if (SceneManipulations != null && __isset.SceneManipulations)
            {
                __sb.Append(", SceneManipulations: ");
                __sb.Append(SceneManipulations);
            }
            if (DrawingCalls != null && __isset.DrawingCalls)
            {
                __sb.Append(", DrawingCalls: ");
                __sb.Append(DrawingCalls);
            }
            if (LogData != null && __isset.LogData)
            {
                __sb.Append(", LogData: ");
                __sb.Append(LogData);
            }
            __sb.Append(")");
            return(__sb.ToString());
        }
示例#25
0
        public void getResetPosture()
        {
            bool useAngles = false;

            if (useAngles)
            {
            }
            else
            {
                float x = Math.Abs(body.Joints[JointType.HandTipRight].Position.X - body.Joints[JointType.HandTipLeft].Position.X);
                float y = Math.Abs(body.Joints[JointType.HandTipRight].Position.Y - body.Joints[JointType.HandTipLeft].Position.Y);
                float z = Math.Abs(body.Joints[JointType.HandTipRight].Position.Z - body.Joints[JointType.HandTipLeft].Position.Z);

                if (armsCrossed == false && legsCrossed == false &&
                    rightHandBehindBack == false && leftHandBehindBack == false &&
                    rightLean == false && leftLean == false && hunch == false &&
                    body.HandRightState != HandState.Closed && body.HandLeftState != HandState.Closed &&
                    leftArmClosePosture == false && rightArmClosePosture == false &&
                    x < 0.04 &&
                    y < 0.04 &&
                    z < 0.04)
                {
                    resetPosture = true;
                    bodyPosture  = Posture.good;
                    PresentationAction pa = new PresentationAction(PresentationAction.GoodType.RESETPOSTURE);
                    currentGoodies.Add(pa);
                }
                else
                {
                    resetPosture = false;
                }
            }
        }
示例#26
0
            public override bool Test(Sim a, EquestrianCenter target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (target.IsActorUsingMe(a))
                {
                    return(false);
                }

                Posture posture = a.Posture as RidingPosture;

                if (posture == null)
                {
                    posture = a.Posture as LeadingHorsePosture;
                    if (posture == null)
                    {
                        greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(a.IsFemale, "NeedHorse", new object[] { a }));
                        return(false);
                    }
                }

                Sim container = posture.Container as Sim;

                if (!container.IsSelectable)
                {
                    return(false);
                }

                if (container.SimDescription.IsFemale)
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(a.IsFemale, "NeedMaleHorse", new object[] { a }));
                    return(false);
                }
                else if (container.SimDescription.Child)
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(a.IsFemale, "NeedAdultHorse", new object[] { a }));
                    return(false);
                }
                else if (container.SimDescription.Elder)
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(container.IsFemale, "ElderPetsTooOldForBreed", new object[] { container }));
                    return(false);
                }

                /*
                 * if (container.SimDescription.IsUnicorn)
                 * {
                 *  greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(a.IsFemale, "UnicornCannotBeOffered", new object[] { a }));
                 *  return false;
                 * }
                 */

                Motives motives = container.Motives;

                if (motives.HasMotive(CommodityKind.StallionOffered) && (motives.GetValue(CommodityKind.StallionOffered) >= EquestrianCenter.kOfferStallionMotiveThreshold))
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(a.IsFemale, "Cooldown", new object[] { a, container }));
                    return(false);
                }
                return(true);
            }
示例#27
0
        public Camera(Game game) : base(game)
        {
            UpdateOrder = 1;

            // Initialize camera state.
            fovx  = DEFAULT_FOVX;
            znear = DEFAULT_ZNEAR;
            zfar  = DEFAULT_ZFAR;
            accumHeadingDegrees = 0.0f;
            accumPitchDegrees   = 0.0f;
            eyeHeightStanding   = 0.0f;
            eyeHeightCrouching  = 0.0f;
            eye             = Vector3.Zero;
            target          = Vector3.Zero;
            targetYAxis     = Vector3.UnitY;
            xAxis           = Vector3.UnitX;
            yAxis           = Vector3.UnitY;
            zAxis           = Vector3.UnitZ;
            viewDir         = Vector3.Forward;
            acceleration    = new Vector3(DEFAULT_ACCELERATION_X, DEFAULT_ACCELERATION_Y, DEFAULT_ACCELERATION_Z);
            velocityWalking = new Vector3(DEFAULT_VELOCITY_X, DEFAULT_VELOCITY_Y, DEFAULT_VELOCITY_Z);
            velocityRunning = velocityWalking * DEFAULT_RUNNING_MULTIPLIER;
            velocity        = velocityWalking;
            orientation     = Quaternion.Identity;
            viewMatrix      = Matrix.Identity;
            posture         = Posture.Standing;

            // Initialize mouse and keyboard input.
            enableMouseSmoothing      = true;
            rotationSpeed             = DEFAULT_SPEED_ROTATION;
            mouseSmoothingSensitivity = DEFAULT_MOUSE_SMOOTHING_SENSITIVITY;
            mouseSmoothingCache       = new Vector2[MOUSE_SMOOTHING_CACHE_SIZE];
            mouseIndex         = 0;
            mouseMovement      = new Vector2[2];
            mouseMovement[0].X = 0.0f;
            mouseMovement[0].Y = 0.0f;
            mouseMovement[1].X = 0.0f;
            mouseMovement[1].Y = 0.0f;

            // Setup default action key bindings.
            actionKeys = new Dictionary <Actions, Keys>();
            actionKeys.Add(Actions.Crouch, Keys.LeftControl);
            actionKeys.Add(Actions.Jump, Keys.Space);
            actionKeys.Add(Actions.MoveForwards, Keys.W);
            actionKeys.Add(Actions.MoveBackwards, Keys.S);
            actionKeys.Add(Actions.StrafeRight, Keys.D);
            actionKeys.Add(Actions.StrafeLeft, Keys.A);
            actionKeys.Add(Actions.Run, Keys.LeftShift);

            // Get initial keyboard and mouse states.
            currentKeyboardState = Keyboard.GetState();
            currentMouseState    = Mouse.GetState();

            // Setup perspective projection matrix.
            Rectangle clientBounds = game.Window.ClientBounds;
            float     aspect       = (float)clientBounds.Width / (float)clientBounds.Height;

            Perspective(fovx, aspect, znear, zfar);
        }
 void OnStandupAnimationEventStart()
 {
     posture = Posture.BENTOVER;
     frontFlipperUpperCollider.enabled = true;
     frontFlipperLowerCollider.enabled = true;
     frontFootCollider.enabled         = true;
     backFootCollider.enabled          = true;
 }
示例#29
0
        public ActionResult DeleteConfirmed(int id)
        {
            Posture posture = db.Postures.Find(id);

            db.Postures.Remove(posture);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Delete(int id)
        {
            Posture Posture = await _repo.Postures.GetById(id);

            _repo.Categories.Delete(id);

            return(RedirectToAction("Index"));
        }
示例#31
0
文件: Player.cs 项目: bsmr/openc1
        private void Jump(GameTime gameTime)
        {
            float elapsedTimeSec = Engine.Instance.ElapsedSeconds;

            // Transition between jumping states.
            switch (_posture)
            {
                case Posture.Standing:
                    if (_shouldJump)
                    {
                        _posture = Posture.Jumping;
                        _jumpingVelocity = 42.0f * elapsedTimeSec;
                    }

                    break;

                case Posture.Jumping:
                    _shouldJump = true;
                    _jumpingVelocity -= 0.2f * elapsedTimeSec;
                    _position += Vector3.Up * _jumpingVelocity;

                    if (_jumpingVelocity <= 0)
                    {
                        _posture = Posture.Falling;
                        _jumpingVelocity = 0.0f;
                    }

                    break;

                case Posture.Falling:
                    _shouldJump = true;
                    _jumpingVelocity -= 0.6f * elapsedTimeSec;
                    _position += Vector3.Up * _jumpingVelocity;

                    if (_position.Y < _worldHeight)
                    {
                        _position.Y = _worldHeight;
                        _posture = Posture.Standing;
                        _jumpingVelocity = 0.0f;
                        _shouldJump = false;
                    }

                    break;

                default:
                    _shouldJump = false;
                    break;
            }
        }
        public void getArmsCrossed()
        {
            bool useAngles=false;

            if(useAngles)
            {
                double x1 = body.Joints[JointType.HandRight].Position.X * Math.Cos(shouldersAngle);
                double z1 = body.Joints[JointType.HandRight].Position.Z * Math.Sin(shouldersAngle);

                double x2 = body.Joints[JointType.HandLeft].Position.X * Math.Cos(shouldersAngle);
                double z2 = body.Joints[JointType.HandLeft].Position.Z * Math.Sin(shouldersAngle);


                if (x1 - z1 < x2 - z2)
                {
                    armsCrossed = true;
                    bodyPosture = Posture.bad;

                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.ARMSCROSSED);
                    currentMistakes.Add(pa);
                }
                else
                {
                    armsCrossed = false;
                }
            }
            else
            {
                if(body.Joints[JointType.HandRight].Position.X+0.1< body.Joints[JointType.HandLeft].Position.X)
                {
                    armsCrossed = true;
                    bodyPosture = Posture.bad;
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.ARMSCROSSED);
                    currentMistakes.Add(pa);
                }
                else
                {
                    armsCrossed = false;
                }
            }
            
        }
        void getLeftLean()
        {
            bool useAngles = false;

            if (useAngles)
            {
            }
            else
            {
                if (body.Joints[JointType.ShoulderLeft].Position.X > body.Joints[JointType.HipLeft].Position.X)
                {
                    leftLean = true;
                    bodyPosture = Posture.bad;
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LEFTLEAN);
                    currentMistakes.Add(pa);
                }
                else
                {
                    leftLean = false;
                }
            }
        }
示例#34
0
        /// <summary>
        /// Transforms FML into BML and executes
        /// </summary>
        /// <param name="body">the FML body containing the FML functions to be interpreted</param>
        private void interpret(FMLBody body)
        {
            foreach (var chunk in body.chunks) {
                BMLBody curr = new BMLBody();
                chunk.BMLRef = curr;
                foreach (var function in chunk.functions) {
                    Vocalisation voc = new Vocalisation("Vocal", chunk.owner, 1f, mood.GetArousal(), mood.GetValence());
                    switch (function.Function) {
                        case FMLFunction.FunctionType.BOARDGAME_REACT_MOVE:
                            ReactMoveFunction react = function as ReactMoveFunction;
                            this.react(react.MoveToReact[0], react.MyMove ? player : (player == Player.First ? Player.Second : Player.First));
                            FaceEmotion faceReact;
                            Posture poser = new Posture("postureReact", chunk.owner, Behaviour.Lexemes.Stance.SITTING, 0f, 8f);
                            if (surprised.Check()) {
                                int coin = UnityEngine.Random.Range(0, 3);
                                faceReact = new FaceEmotion("ConfusedFace", chunk.owner, 0f, 1.4f * expressionIntensity, 0.8f * expressionIntensity);
                                if (coin < 2) {
                                    poser.AddPose(Behaviour.Lexemes.BodyPart.RIGHT_ARM, Behaviour.Lexemes.BodyPose.FIST_COVER_MOUTH);
                                    curr.AddChunk(poser);
                                }
                                coin = UnityEngine.Random.Range(0, noiseChance);
                                curr.AddChunk(faceReact);
                                if (coin == 0) curr.AddChunk(voc);
                            }
                            break;
                        case FMLFunction.FunctionType.BOARDGAME_CONSIDER_MOVE:
                            //tbh this shouldn't be here
                            if (impatient.Check()) {
                                Debug.Log("IMPATIENT");
                                Gaze glanceAtPlayer = new Gaze("glanceAtPlayer", chunk.owner, motion.Player, Behaviour.Lexemes.Influence.HEAD, start: 0f, end: 0.25f, priority: 2);
                                curr.AddChunk(glanceAtPlayer);
                                curr.AddChunk(voc);
                            } else {
                                ConsiderMoveFunction func = function as ConsiderMoveFunction;
                                if (func.MoveToConsider.Type == MoveType.MOVE) {
                                    Gaze glanceFrom = new Gaze("glanceAtFrom", chunk.owner, BoardgameManager.Instance.GetCellObject(func.MoveToConsider.From),
                                        Behaviour.Lexemes.Influence.HEAD, start: 0f, end: 2f);
                                    curr.AddChunk(glanceFrom);
                                    Gaze glanceTo = new Gaze("glanceAtTo", chunk.owner, BoardgameManager.Instance.GetCellObject(func.MoveToConsider.To),
                                        Behaviour.Lexemes.Influence.HEAD, start: 2.1f, end: 2f, priority: 2);
                                    curr.AddChunk(glanceTo);
                                } else {
                                    Gaze glanceTo = new Gaze("glanceAtCell", chunk.owner, BoardgameManager.Instance.GetCellObject(func.MoveToConsider.To),
                                       Behaviour.Lexemes.Influence.HEAD, start: 0f, end: 2f);
                                    curr.AddChunk(glanceTo);
                                }
                            }

                            break;
                        case FMLFunction.FunctionType.BOARDGAME_MAKE_MOVE:
                            MakeMoveFunction move = function as MakeMoveFunction;
                            PhysicalCell from, to;
                            BoardgameManager.Instance.GetMoveFromTo(move.MoveToMake[0], player, out from, out to);
                            Grasp reach = new Grasp("reachTowardsPiece", chunk.owner, from.gameObject,
                                Behaviour.Lexemes.Mode.LEFT_HAND, (arm) => { graspPiece(from, arm); }, 0, end: 1.5f);
                            Posture leanReach = new Posture("leantowardsPiece", chunk.owner, Behaviour.Lexemes.Stance.SITTING, 0, end: 1.5f, priority: 2);
                            Gaze lookReach = new Gaze("glanceAtReach", chunk.owner, from.gameObject, Behaviour.Lexemes.Influence.HEAD, start: 0f, end: 1.25f);
                            Debug.Log((int)(Vector3.Distance(from.transform.position, transform.position) * 40));
                            leanReach.AddPose(Behaviour.Lexemes.BodyPart.WHOLEBODY, Behaviour.Lexemes.BodyPose.LEANING_FORWARD,
                                (int)(Vector3.Distance(from.transform.position, transform.position) * 40));
                            Place place = new Place("placePiece", chunk.owner, to.gameObject,
                                Behaviour.Lexemes.Mode.LEFT_HAND, (piece) => {
                                    placePiece(piece, to);
                                    BoardgameManager.Instance.MoveMade(move.MoveToMake, player); BoardgameManager.Instance.SyncState(); BoardgameManager.Instance.MakeNoise(to.id);
                                },
                                1.25f, end: 2f);
                            Posture leanPlace = new Posture("leantowardsCell", chunk.owner, Behaviour.Lexemes.Stance.SITTING, 1.25f, end: 1.5f, priority: 3);
                            leanPlace.AddPose(Behaviour.Lexemes.BodyPart.WHOLEBODY, Behaviour.Lexemes.BodyPose.LEANING_FORWARD,
                                (int)(Vector3.Distance(to.transform.position, transform.position) * 40));
                            Gaze lookPlace = new Gaze("glanceAtPlace", chunk.owner, to.gameObject, Behaviour.Lexemes.Influence.HEAD, start: 1.25f, end: 2f, priority: 2);
                            Gaze glance = new Gaze("glanceAtPlayer", chunk.owner, motion.Player, Behaviour.Lexemes.Influence.HEAD, start: 2f, end: 1.25f, priority: 3);
                            curr.AddChunk(glance);
                            curr.AddChunk(lookReach);
                            curr.AddChunk(lookPlace);
                            curr.AddChunk(leanReach);
                            curr.AddChunk(leanPlace);
                            curr.AddChunk(reach);
                            curr.AddChunk(place);
                            break;
                        case FMLFunction.FunctionType.EMOTION:
                            //transform expression
                            EmotionFunction f = function as EmotionFunction;
                            float v = Mathf.Clamp(f.Valence, 0, 2);

                            if (v < Config.Neutral) {
                                v = (v - Config.Neutral) * 0.8f + Config.Neutral;
                            }
                            float a = Mathf.Clamp(f.Arousal, 0, 2);
                            if (a > Config.Neutral) {
                                a = (a - Config.Neutral) * 0.6f + Config.Neutral;
                            }
                            FaceEmotion fe = new FaceEmotion("emote " + f.Arousal + " " + f.Valence, chunk.owner, 0f, a, v);
                            float lean = Mathf.Clamp((f.Arousal - Config.Neutral) * 30, -20, 30);
                            Posture emoLean = new Posture("emoteLean", chunk.owner, Behaviour.Lexemes.Stance.SITTING, 0, end: 3f);
                            emoLean.AddPose(Behaviour.Lexemes.BodyPart.WHOLEBODY, Behaviour.Lexemes.BodyPose.LEANING_FORWARD, (int)lean);
                            curr.AddChunk(emoLean);
                            curr.AddChunk(fe);
                            break;
                    }
                }
            }
            //sort out timing
            foreach (var chunk in body.chunks) {
                if (chunk.timing != null) {
                    switch (chunk.timing.Primitive) {
                        case Primitive.MustEndBefore:
                            chunk.timing.ChunkReference.BMLRef.ExecuteAfter(chunk.BMLRef);
                            break;
                        case Primitive.StartImmediatelyAfter:
                            chunk.BMLRef.ExecuteAfter(chunk.timing.ChunkReference.BMLRef);
                            break;
                    }
                }
            }

            //let's refactor this later so that we don't have to do 3N
            foreach (var chunk in body.chunks) {
                behave.ScheduleBehaviour(chunk.BMLRef);
            }
        }
        /// <summary>
        /// Moves the camera based on player input.
        /// </summary>
        /// <param name="direction">Direction moved.</param>
        /// <param name="elapsedTimeSec">Elapsed game time.</param>
        private void UpdatePosition(ref Vector3 direction, float elapsedTimeSec)
        {
            if (currentVelocity.LengthSquared() != 0.0f)
            {
                // Only move the camera if the velocity vector is not of zero
                // length. Doing this guards against the camera slowly creeping
                // around due to floating point rounding errors.

                Vector3 displacement = (currentVelocity * elapsedTimeSec) +
                    (0.5f * acceleration * elapsedTimeSec * elapsedTimeSec);

                // Floating point rounding errors will slowly accumulate and
                // cause the camera to move along each axis. To prevent any
                // unintended movement the displacement vector is clamped to
                // zero for each direction that the camera isn't moving in.
                // Note that the UpdateVelocity() method will slowly decelerate
                // the camera's velocity back to a stationary state when the
                // camera is no longer moving along that direction. To account
                // for this the camera's current velocity is also checked.

                if (direction.X == 0.0f && (float)Math.Abs(currentVelocity.X) < 1e-6f)
                    displacement.X = 0.0f;

                if (direction.Y == 0.0f && (float)Math.Abs(currentVelocity.Y) < 1e-6f)
                    displacement.Y = 0.0f;

                if (direction.Z == 0.0f && (float)Math.Abs(currentVelocity.Z) < 1e-6f)
                    displacement.Z = 0.0f;

                Move(displacement.X, displacement.Y, displacement.Z);

                switch (posture)
                {
                case Posture.Standing:
                    break;

                case Posture.Crouching:
                    if (eye.Y < eyeHeightCrouching)
                        eye.Y = eyeHeightCrouching;
                    break;

                case Posture.Rising:
                    if (eye.Y > eyeHeightStanding)
                    {
                        eye.Y = eyeHeightStanding;
                        posture = Posture.Standing;
                    }
                    break;

                case Posture.Jumping:
                    if (eye.Y < eyeHeightStanding)
                    {
                        eye.Y = eyeHeightStanding;
                        posture = Posture.Standing;
                        currentVelocity.Y = 0.0f;
                    }
                    break;
                }
            }

            // Continuously update the camera's velocity vector even if the
            // camera hasn't moved during this call. When the camera is no
            // longer being moved the camera is decelerating back to its
            // stationary state.

            UpdateVelocity(ref direction, elapsedTimeSec);
        }
        /// <summary>
        /// Metodo que detecta si se esta realizando una determinada postura.
        /// </summary>
        /// <param name="postura"></param> Postura del esqueleto.
        /// <returns>
        /// true: postura esperada.
        /// false: postura no esperada.
        /// </returns>
        private Boolean detectarPostura(Posture postura)
        {
            if (posturaEnDeteccion != postura)
            {
                acumulador = 0;
                posturaEnDeteccion = postura;
                return false;
            }

            if (acumulador < NumeroDeteccionPostura)
            {
                acumulador++;
                return false;
            }
            if (postura != posturaAnterior)
            {
                posturaAnterior = postura;
                acumulador = 0;
                return true;
            }
            else
                acumulador = 0;
            return false;
        }
	private List<AnimationClip> BuildTransition(Posture sourcePosture, Posture targetPosture)
	{
		return BuildTransition(sourcePosture, targetPosture, new List<Posture>());
	}
        /// <summary>
        /// Determines which way to move the camera based on player input.
        /// The returned values are in the range [-1,1].
        /// </summary>
        /// <param name="direction">The movement direction.</param>
        private void GetMovementDirection(out Vector3 direction)
        {
            direction = Vector3.Zero;
            direction.X = 0.0f;
            direction.Y = 0.0f;
            direction.Z = 0.0f;

            // keyboard W (move ahead)
            if (currentKeyboardState.IsKeyDown(actionKeys[Actions.MoveForwards]))
            {
                if (!forwardsPressed)
                {
                    forwardsPressed = true;
                    currentVelocity.Z = 0.0f;
                }
                if(GamePad.GetState(PlayerIndex.One).IsConnected) direction.Z += GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y;
                direction.Z += 1.0f;
            }
            else if(GamePad.GetState(PlayerIndex.One).IsConnected && GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y < 0.0f)
            {
                 if (!forwardsPressed)
                    {
                        forwardsPressed = true;
                        currentVelocity.Z = 0.0f;
                    }

                    direction.Z += GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y;
            }
            else
            {
                    forwardsPressed = false;
            }
            //////////////////////////////////////////////////////////////////////

            // keyboard S (move backwards)
            if (currentKeyboardState.IsKeyDown(actionKeys[Actions.MoveBackwards]))
            {
                if (!backwardsPressed)
                {
                    backwardsPressed = true;
                    currentVelocity.Z = 0.0f;
                }

                direction.Z -= 1.0f;
            }
            else if(GamePad.GetState(PlayerIndex.One).IsConnected && GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y > 0.0f)
            {
                if (!backwardsPressed)
                {
                    backwardsPressed = true;
                    currentVelocity.Z = 0.0f;
                }

                direction.Z += GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y;

            }
            else
            {
                backwardsPressed = false;
            }
            //////////////////////////////////////////////////////////////////////
            // keyboard S (strafe right)
            if (currentKeyboardState.IsKeyDown(actionKeys[Actions.StrafeRight]))
            {
                if (!strafeRightPressed)
                {
                    strafeRightPressed = true;
                    currentVelocity.X = 0.0f;
                }

                direction.X += 1.0f;
            }
            else if(GamePad.GetState(PlayerIndex.One).IsConnected && GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X > 0.0f)
            {
                if (!strafeRightPressed)
                {
                    strafeRightPressed = true;
                    currentVelocity.X = 0.0f;
                }

                direction.X += GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X;
            }
            else
            {
                strafeRightPressed = false;
            }
            //////////////////////////////////////////////////////////////////////
            if (currentKeyboardState.IsKeyDown(actionKeys[Actions.StrafeLeft]))
            {
                if (!strafeLeftPressed)
                {
                    strafeLeftPressed = true;
                    currentVelocity.X = 0.0f;
                }

                direction.X -= 1.0f;
            }
            else if(GamePad.GetState(PlayerIndex.One).IsConnected && GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X < 0.0f)
            {
                if (!strafeLeftPressed)
                {
                    strafeLeftPressed = true;
                    currentVelocity.X = 0.0f;
                }

                direction.X += GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X;
            }
            else
            {
                strafeLeftPressed = false;
            }

            if (currentKeyboardState.IsKeyDown(actionKeys[Actions.Crouch]) || GamePad.GetState(PlayerIndex.One).Buttons.LeftStick == ButtonState.Pressed)
            {
                switch (posture)
                {
                case Posture.Standing:
                    posture = Posture.Crouching;
                    direction.Y -= 1.0f;
                    currentVelocity.Y = 0.0f;
                    break;

                case Posture.Crouching:
                    direction.Y -= 1.0f;
                    break;

                case Posture.Rising:
                    // Finish rising before allowing another crouch.
                    direction.Y += 1.0f;
                    break;

                default:
                    break;
                }
            }
            else
            {
                switch (posture)
                {
                case Posture.Crouching:
                    posture = Posture.Rising;
                    direction.Y += 1.0f;
                    currentVelocity.Y = 0.0f;
                    break;

                case Posture.Rising:
                    direction.Y += 1.0f;
                    break;

                default:
                    break;
                }
            }

            if ((currentKeyboardState.IsKeyDown(actionKeys[Actions.Jump]) &&
                previousKeyboardState.IsKeyUp(actionKeys[Actions.Jump]))
                || GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)
            {
                switch (posture)
                {
                case Posture.Standing:
                    posture = Posture.Jumping;
                    currentVelocity.Y = velocity.Y;
                    direction.Y += 1.0f;
                    break;

                case Posture.Jumping:
                    direction.Y += 1.0f;
                    break;

                default:
                    break;
                }
            }
            else
            {
                if (posture == Posture.Jumping)
                    direction.Y += 1.0f;
            }
        }
示例#39
0
文件: Player.cs 项目: bsmr/openc1
 public void StandAt(Vector3 playerPos)
 {
     _posture = Posture.Standing;
     _position = playerPos;
     _velocity = 0.0f;
 }
        public void analyzePosture()
        {
            currentMistakes = new ArrayList();
            currentGoodies = new ArrayList();

            bodyPosture = Posture.good;
            getShouldersAngle();
            getArmsCrossed();
            getHunch();
            getRightHandUnderHip();
            getLeftHandUnderHip();
            getRightHandBehindBack();
            getRightArmClosePosture();
            getLeftArmClosePosture();
            getRightLean();
            getLeftLean();
            getResetPosture();

            calcMovingHands();
            getArmsAngles();
            searchPause();
        //    calcIsMovingArms();
           
        }
        public void getLeftHandBehindBack()
        {
            bool useAngles = false;

            if (useAngles)
            {
                double x1 = body.Joints[JointType.HandLeft].Position.X * Math.Sin(shouldersAngle);
                double z1 = body.Joints[JointType.HandLeft].Position.Z * Math.Cos(shouldersAngle);

                double x2 = body.Joints[JointType.SpineMid].Position.X * Math.Sin(shouldersAngle);
                double z2 = body.Joints[JointType.SpineMid].Position.Z * Math.Cos(shouldersAngle);

                if (-x1 + z1 < -x2 + z2)
                {

                    leftHandBehindBack = true;
                    bodyPosture = Posture.bad;
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LEFTHANDBEHINDBACK);
                    currentMistakes.Add(pa);
                }
                else
                {
                    leftHandBehindBack = false;
                }
            }
            else
            {
                if (body.Joints[JointType.HandLeft].Position.Z > body.Joints[JointType.SpineMid].Position.Z)
                {
                    leftHandBehindBack = true;
                    bodyPosture = Posture.bad;
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LEFTHANDBEHINDBACK);
                    currentMistakes.Add(pa);
                }
                else
                {
                    leftHandBehindBack = false;
                }
            }
        }
        /// <summary>
        /// Determines which way to move the camera based on player input.
        /// The returned values are in the range [-1,1].
        /// </summary>
        /// <param name="direction">The movement direction.</param>
        private void GetMovementDirection(out Vector3 direction)
        {
            direction.X = 0.0f;
            direction.Y = 0.0f;
            direction.Z = 0.0f;

            if (input.IsKeyDown(actionKeys[Actions.MoveForwards]))
            {
                if (!forwardsPressed)
                {
                    forwardsPressed = true;
                    currentVelocity.Z = 0.0f;
                }
                direction.Z += 1.0f;
            }
            else
            {
                forwardsPressed = false;
            }

            if (input.IsKeyDown(actionKeys[Actions.MoveBackwards]))
            {
                if (!backwardsPressed)
                {
                    backwardsPressed = true;
                    currentVelocity.Z = 0.0f;
                }
                direction.Z -= 1.0f;
            }
            else
            {
                backwardsPressed = false;
            }

            if (input.IsKeyDown(actionKeys[Actions.StrafeRight]))
            {
                if (!strafeRightPressed)
                {
                    strafeRightPressed = true;
                    currentVelocity.X = 0.0f;
                }
                direction.X += 1.0f;
            }
            else
            {
                strafeRightPressed = false;
            }

            if (input.IsKeyDown(actionKeys[Actions.StrafeLeft]))
            {
                if (!strafeLeftPressed)
                {
                    strafeLeftPressed = true;
                    currentVelocity.X = 0.0f;
                }
                direction.X -= 1.0f;
            }
            else
            {
                strafeLeftPressed = false;
            }

            if (input.IsKeyDown(actionKeys[Actions.Crouch]))
            {
                switch (posture)
                {
                case Posture.Standing:
                    posture = Posture.Crouching;
                    direction.Y -= 1.0f;
                    currentVelocity.Y = 0.0f;
                    break;

                case Posture.Crouching:
                    direction.Y -= 1.0f;
                    break;
                case Posture.Rising:
                    // Finish rising before allowing another crouch.
                    direction.Y += 1.0f;
                    break;
                default:
                    break;
                }
            }
            else
            {
                switch (posture)
                {
                case Posture.Crouching:
                    posture = Posture.Rising;
                    direction.Y += 1.0f;
                    currentVelocity.Y = 0.0f;
                    break;
                case Posture.Rising:
                    direction.Y += 1.0f;
                    break;
                default:
                    break;
                }
            }

            if (input.IsKeyDownOnce(actionKeys[Actions.Jump]))
            {
                switch (posture)
                {
                case Posture.Standing:
                    posture = Posture.Jumping;
                    currentVelocity.Y = velocity.Y;
                    direction.Y += 1.0f;
                    break;
                case Posture.Jumping:
                    direction.Y += 1.0f;
                    break;
                default:
                    break;
                }
            }
            else
            {
                if (posture == Posture.Jumping)
                    direction.Y += 1.0f;
            }
        }
示例#43
0
	// 자세를 스택에서 팝한다.
	public void		popPosture()
	{
		if(this.stack.Count > 0) {

			this.current = this.stack[this.stack.Count - 1];

			this.stack.RemoveRange(this.stack.Count - 1, 1);

			this.update();
		}
	}
示例#44
0
	// 자세를 설정한다.
	public void	setPosture(Posture posture)
	{
		this.current = posture;
		this.update();
	}
        void getRightLean()
        {
            bool useAngles = false;

            if (useAngles)
            {
            }
            else
            {
                if (body.Joints[JointType.ShoulderRight].Position.X < body.Joints[JointType.HipRight].Position.X)
                {
                    rightLean = true;
                    bodyPosture = Posture.bad;
                    PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.RIGHTLEAN);
                    currentMistakes.Add(pa);
                }
                else
                {
                    rightLean = false;
                }
            }
        }
示例#46
0
    public void TrackPostures(ReplaySkeletonData skeleton)
    {
        if (skeleton.TrackingState != SkeletonTrackingState.Tracked)
            return;

        Vector3? headPosition = null;
        Vector3? leftHandPosition = null;
        Vector3? rightHandPosition = null;

        foreach (Joint joint in skeleton.Joints)
        {
            if (joint.Position.W < 0.8f || joint.TrackingState != JointTrackingState.Tracked)
                continue;

            switch (joint.ID)
            {
                case JointID.Head:
                    headPosition = joint.Position.ToVector3();
                    break;
                case JointID.HandLeft:
                    leftHandPosition = joint.Position.ToVector3();
                    break;
                case JointID.HandRight:
                    rightHandPosition = joint.Position.ToVector3();
                    break;
            }
        }

        // HandsJoined
        if (CheckHandsJoined(rightHandPosition, leftHandPosition))
            return;

        // LeftHandOverHead
        if (CheckHandOverHead(headPosition, leftHandPosition))
        {
            RaisePostureDetected(Posture.LeftHandOverHead);
            return;
        }

        // RightHandOverHead
        if (CheckHandOverHead(headPosition, rightHandPosition))
        {
            RaisePostureDetected(Posture.RightHandOverHead);
            return;
        }

        // LeftHello
        if (CheckHello(headPosition, leftHandPosition))
        {
            RaisePostureDetected(Posture.LeftHello);
            return;
        }

        // RightHello
        if (CheckHello(headPosition, rightHandPosition))
        {
            RaisePostureDetected(Posture.RightHello);
            return;
        }

        previousPosture = Posture.None;
        accumulator = 0;
    }
示例#47
0
文件: Player.cs 项目: bsmr/openc1
 public Player()
 {
     _posture = Posture.Standing;
     _health = 1.0f;
 }
	private List<AnimationClip> BuildTransition(Posture sourcePosture, Posture targetPosture, List<Posture> skip)
	{
		AnimationClip foundClip;
		List<AnimationClip> clipList = new List<AnimationClip>();
		sourcePosture.Transitions.TryGetValue(targetPosture, out foundClip);
		if(foundClip)
			clipList.Add(foundClip);
		else
		{
			skip.Add(sourcePosture);
			List<List<AnimationClip>> options = new List<List<AnimationClip>>();
			foreach(KeyValuePair<Posture, AnimationClip> kvp in sourcePosture.Transitions)
			{
				if(!skip.Contains(kvp.Key))
				{
					List<AnimationClip> tempList = BuildTransition(kvp.Key, targetPosture, skip);
					if(tempList.Count > 0)
					{
						tempList.Insert(0, kvp.Value);
						options.Add(tempList);
					}
				}
			}
			int listSize = System.Int32.MaxValue;
			foreach(List<AnimationClip> l in options)
			{
				if(l.Count < listSize)
				{
					clipList = l;
					listSize = l.Count;
				}
			}
		}
		return clipList;
	}
示例#49
0
文件: Player.cs 项目: bsmr/openc1
 public bool Jump(float velocity)
 {
     if (_posture == Posture.Standing)
     {
         _posture = Posture.Jumping;
         _jumpingVelocity = velocity;
         return true;
     }
     else
     {
         return false;
     }
 }
        public FirstPersonCamera(Game game)
            : base(game)
        {
            UpdateOrder = 1;

            // Initialize camera state.
            fovx = DEFAULT_FOVX;
            znear = DEFAULT_ZNEAR;
            zfar = DEFAULT_ZFAR;
            accumHeadingDegrees = 0.0f;
            accumPitchDegrees = 0.0f;
            eyeHeightStanding = 0.0f;
            eyeHeightCrouching = 0.0f;
            eye = Vector3.Zero;
            target = Vector3.Zero;
            targetYAxis = Vector3.UnitY;
            xAxis = Vector3.UnitX;
            yAxis = Vector3.UnitY;
            zAxis = Vector3.UnitZ;
            viewDir = Vector3.Forward;
            acceleration = new Vector3(DEFAULT_ACCELERATION_X, DEFAULT_ACCELERATION_Y, DEFAULT_ACCELERATION_Z);
            velocityWalking = new Vector3(DEFAULT_VELOCITY_X, DEFAULT_VELOCITY_Y, DEFAULT_VELOCITY_Z);
            velocityRunning = velocityWalking * DEFAULT_RUNNING_MULTIPLIER;
            velocity = velocityWalking;
            orientation = Quaternion.Identity;
            viewMatrix = Matrix.Identity;
            posture = Posture.Standing;

            // Initialize mouse and keyboard input.
            rotationSpeed = DEFAULT_SPEED_ROTATION;
            #if(WINDOWS)
            enableMouseSmoothing = true;
            //rotationSpeed = DEFAULT_SPEED_ROTATION;
            mouseSmoothingSensitivity = DEFAULT_MOUSE_SMOOTHING_SENSITIVITY;
            mouseSmoothingCache = new Vector2[MOUSE_SMOOTHING_CACHE_SIZE];
            mouseIndex = 0;
            mouseMovement = new Vector2[2];
            mouseMovement[0].X = 0.0f;
            mouseMovement[0].Y = 0.0f;
            mouseMovement[1].X = 0.0f;
            mouseMovement[1].Y = 0.0f;
            #endif
            // Setup default action key bindings.
            actionKeys = new Dictionary<Actions, Keys>();

            actionKeys.Add(Actions.Crouch, Keys.LeftControl);
            actionKeys.Add(Actions.Jump, Keys.Space);
            actionKeys.Add(Actions.MoveForwards, Keys.W);
            actionKeys.Add(Actions.MoveBackwards, Keys.S);
            actionKeys.Add(Actions.StrafeRight, Keys.D);
            actionKeys.Add(Actions.StrafeLeft, Keys.A);
            actionKeys.Add(Actions.Run, Keys.LeftShift);
            //#if !WINDOWS
            //            actionKeys.Add(Actions.Crouch, Keys.LeftControl);
            //            actionKeys.Add(Actions.Jump, Keys.Space);
            //            actionKeys.Add(Actions.MoveForwards, Keys.W);
            //            actionKeys.Add(Actions.MoveBackwards, Keys.S);
            //            actionKeys.Add(Actions.StrafeRight, Keys.D);
            //            actionKeys.Add(Actions.StrafeLeft, Keys.A);
            //            actionKeys.Add(Actions.Run, Keys.LeftShift);
            //#endif

            // Get initial keyboard and mouse states.
            currentKeyboardState = Keyboard.GetState();

            #if (WINDOWS)

            currentMouseState = Mouse.GetState();
            #endif
            // Setup perspective projection matrix.
            Rectangle clientBounds = game.Window.ClientBounds;
            float aspect = (float)clientBounds.Width / (float)clientBounds.Height;
            Perspective(fovx, aspect, znear, zfar);
        }
        public void getResetPosture()
        {
            bool useAngles = false;
            if (useAngles)
            {
                
            }
            else
            {
                float x = Math.Abs(body.Joints[JointType.HandTipRight].Position.X - body.Joints[JointType.HandTipLeft].Position.X);
                float y = Math.Abs(body.Joints[JointType.HandTipRight].Position.Y - body.Joints[JointType.HandTipLeft].Position.Y);
                float z = Math.Abs(body.Joints[JointType.HandTipRight].Position.Z - body.Joints[JointType.HandTipLeft].Position.Z);

                if (armsCrossed==false&& legsCrossed==false && 
                    rightHandBehindBack==false && leftHandBehindBack == false
                    && rightLean==false && leftLean==false && hunch==false
                    && body.HandRightState != HandState.Closed && body.HandLeftState!= HandState.Closed
                    && leftArmClosePosture == false && rightArmClosePosture == false
                    && x<0.04
                    && y<0.04 
                    && z<0.04)
                {
                    resetPosture = true;
                    bodyPosture = Posture.good;
                    PresentationAction pa = new PresentationAction(PresentationAction.GoodType.RESETPOSTURE);
                    currentGoodies.Add(pa);
                }
                else
                {
                    resetPosture = false;                    
                }
            }
               
        }
示例#52
0
    void RaisePostureDetected(Posture posture)
    {
        if (accumulator < AccumulatorTarget)
        {
            if (accumulatedPosture != posture)
            {
                accumulator = 0;
                accumulatedPosture = posture;
            }
            accumulator++;
            return;
        }

        if (previousPosture == posture)
            return;

        previousPosture = posture;
        if (PostureDetected != null)
            PostureDetected(posture);

        accumulator = 0;
    }
        public void getLegsCrossed()
        {
             bool useAngles = false;
             if (useAngles)
             {

             }
             else
             {
                 if (body.Joints[JointType.FootRight].Position.X < body.Joints[JointType.FootLeft].Position.X)
                 {
                     legsCrossed = true;
                     bodyPosture = Posture.bad;
                     PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LEGSCROSSED);
                     currentMistakes.Add(pa);
                 }
                 else
                 {
                     legsCrossed = false;
                 }
             }
        }
 private void AssessAngerPacifist(KeyValuePair<Empire, Ship_Game.Gameplay.Relationship> Relationship, Posture posture, float usedTrust)
 {
     if (posture != Posture.Friendly)
     {
         this.AssessDiplomaticAnger(Relationship);
     }
     else if (!Relationship.Value.Treaty_OpenBorders && (Relationship.Value.Treaty_Trade || Relationship.Value.Treaty_NAPact) && !Relationship.Value.HaveRejected_OpenBorders)
     {
         if (Relationship.Value.Trust >= 50f)
         {
             if (Relationship.Value.Trust - usedTrust > (float)(this.empire.data.DiplomaticPersonality.Territorialism / 2))
             {
                 Offer NAPactOffer = new Offer()
                 {
                     OpenBorders = true,
                     AcceptDL = "Open Borders Accepted",
                     RejectDL = "Open Borders Friends Rejected"
                 };
                 Ship_Game.Gameplay.Relationship value = Relationship.Value;
                 NAPactOffer.ValueToModify = new Ref<bool>(() => value.HaveRejected_OpenBorders, (bool x) => value.HaveRejected_OpenBorders = x);
                 Offer OurOffer = new Offer()
                 {
                     OpenBorders = true
                 };
                 if (Relationship.Key != EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty))
                 {
                     Relationship.Key.GetGSAI().AnalyzeOffer(OurOffer, NAPactOffer, this.empire, Offer.Attitude.Pleading);
                     return;
                 }
                 this.empire.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(this.empire, EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty), "Offer Open Borders Friends", OurOffer, NAPactOffer));
                 return;
             }
         }
         else if (Relationship.Value.Trust >= 20f && Relationship.Value.Anger_TerritorialConflict + Relationship.Value.Anger_FromShipsInOurBorders >= 0.75f * (float)this.empire.data.DiplomaticPersonality.Territorialism && Relationship.Value.Trust - usedTrust > (float)(this.empire.data.DiplomaticPersonality.Territorialism / 2))
         {
             Offer NAPactOffer = new Offer()
             {
                 OpenBorders = true,
                 AcceptDL = "Open Borders Accepted",
                 RejectDL = "Open Borders Rejected"
             };
             Ship_Game.Gameplay.Relationship relationship = Relationship.Value;
             NAPactOffer.ValueToModify = new Ref<bool>(() => relationship.HaveRejected_OpenBorders, (bool x) => relationship.HaveRejected_OpenBorders = x);
             Offer OurOffer = new Offer()
             {
                 OpenBorders = true
             };
             if (Relationship.Key != EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty))
             {
                 Relationship.Key.GetGSAI().AnalyzeOffer(OurOffer, NAPactOffer, this.empire, Offer.Attitude.Pleading);
                 return;
             }
             this.empire.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(this.empire, EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty), "Offer Open Borders", OurOffer, NAPactOffer));
             return;
         }
     }
     else if (Relationship.Value.turnsSinceLastContact >= 10)
     {
         if (Relationship.Value.Known && Relationship.Key == EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty))
         {
             Ship_Game.Gameplay.Relationship r = Relationship.Value;
             if (r.Anger_FromShipsInOurBorders > (float)(this.empire.data.DiplomaticPersonality.Territorialism / 4) && !r.AtWar && !r.WarnedAboutShips && r.turnsSinceLastContact > 10)
             {
                 if (!r.WarnedAboutColonizing)
                 {
                     this.empire.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(this.empire, Relationship.Key, "Warning Ships"));
                 }
                 else
                 {
                     this.empire.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(this.empire, Relationship.Key, "Warning Colonized then Ships", r.GetContestedSystem()));
                 }
                 r.WarnedAboutShips = true;
                 return;
             }
         }
     }
     else if (Relationship.Value.HaveRejected_OpenBorders || Relationship.Value.TotalAnger > 50f && Relationship.Value.Trust < Relationship.Value.TotalAnger)
     {
         Relationship.Value.Posture = Posture.Neutral;
         return;
     }
 }
 public void getLeftHandUnderHip()
 {
     if (body.Joints[JointType.HandLeft].Position.Y < body.Joints[JointType.HipLeft].Position.Y)
     {
         leftHandUnderHips = true;
         bodyPosture = Posture.bad;
         PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.LEFTHANDUNDERHIP);
         currentMistakes.Add(pa);
     }
     else
     {
         leftHandUnderHips = false;
     }
 }
示例#56
0
        /// <summary>
        /// Determines which way to move the camera based on player input.
        /// The returned values are in the range [-1,1].
        /// </summary>
        /// <param name="direction">The direction vector.</param>
        private void GetMovementDirection(out Vector3 outDirection)
        {
            // Reset the direction vector to zero.
            outDirection.X = 0.0f;
            outDirection.Y = 0.0f;
            outDirection.Z = 0.0f;

            // Movement actions are tricky, because we don't simply want to check whether a
            // key has been pressed and released, and checking if it had been held would take
            // two frames instead of one to respond.

            // Check if the forwards key is pressed. If so, move forwards.
            if (mKeyboardService.CurrentlyDown(mActionKeys[Actions.MoveForwards]))
            {
                if (!bForwardsPressed)
                {
                    bForwardsPressed = true;
                    mCurrentVelocity.Z = 0.0f;
                }

                outDirection.Z += 1.0f;
            }
            else { bForwardsPressed = false; }

            // Check if the backwards key is pressed. If so, move backwards.
            if (mKeyboardService.CurrentlyDown(mActionKeys[Actions.MoveBackwards]))
            {
                if (!bBackwardsPressed)
                {
                    bBackwardsPressed = true;
                    mCurrentVelocity.Z = 0.0f;
                }

                outDirection.Z -= 1.0f;
            }
            else { bBackwardsPressed = false; }

            // Check if the strafe-left key is pressed. If so, move left.
            if (mKeyboardService.CurrentlyDown(mActionKeys[Actions.StrafeLeft]))
            {
                if (!bStrafeLeftPressed)
                {
                    bStrafeLeftPressed = true;
                    mCurrentVelocity.X = 0.0f;
                }

                outDirection.X -= 1.0f;
            }
            else { bStrafeLeftPressed = false; }

            // Check if the strafe-right key is pressed. If so, move right.
            if (mKeyboardService.CurrentlyDown(mActionKeys[Actions.StrafeRight]))
            {
                if (!bStrafeRightPressed)
                {
                    bStrafeRightPressed = true;
                    mCurrentVelocity.X = 0.0f;
                }

                outDirection.X += 1.0f;
            }
            else { bStrafeRightPressed = false; }

            if (mKeyboardService.CurrentlyDown(mActionKeys[Actions.Crouch]))
            {
                switch (ePosture)
                {
                    case Posture.Standing:
                        ePosture = Posture.Crouching;
                        outDirection.Y -= 1.0f;
                        mCurrentVelocity.Y = 0.0f;
                        break;

                    case Posture.Crouching:
                        outDirection.Y -= 1.0f;
                        break;

                    case Posture.Rising:
                        outDirection.Y += 1.0f;
                        break;

                    default:
                        break;
                }
            }
            else
            {
                switch (ePosture)
                {
                    case Posture.Crouching:
                        ePosture = Posture.Rising;
                        outDirection.Y += 1.0f;
                        mCurrentVelocity.Y = 0.0f;
                        break;

                    case Posture.Rising:
                        outDirection.Y += 1.0f;
                        break;

                    default:
                        break;
                }
            }

            if (mKeyboardService.IsKeyPressed(mActionKeys[Actions.Jump]))
            {
                switch (ePosture)
                {
                    case Posture.Standing:
                        ePosture = Posture.Jumping;
                        mCurrentVelocity.Y = mVelocity.Y;
                        outDirection.Y += 1.0f;
                        break;
                    case Posture.Jumping:
                        outDirection.Y += 1.0f;
                        break;
                    default:
                        break;
                }
            }
            else
            {
                if (ePosture == Posture.Jumping) { outDirection.Y += 1.0f; }
            }
        }
示例#57
0
    IEnumerator Schedule(Posture chunk)
    {
        yield return new WaitForSeconds(chunk.Start);
        DebugManager.Instance.OnChunkStart(chunk);
        float duration = chunk.End;
        //ignore stance for now
        while (posePriority > chunk.Priority && duration > 0f) {
            yield return new WaitForEndOfFrame();
            duration -= Time.deltaTime;
        }
        if (duration > 0) {
            foreach (Pose pose in chunk.Poses) {
                //ignoring affected parts
                switch (pose.Lexeme) {
                    case Behaviour.Lexemes.BodyPose.ARMS_AKIMBO:
                        break;
                    case Behaviour.Lexemes.BodyPose.ARMS_CROSSED:
                        StartCoroutine(Pose(1, 1, duration));
                        break;
                    case Behaviour.Lexemes.BodyPose.ARMS_NEUTRAL:
                        break;
                    case Behaviour.Lexemes.BodyPose.ARMS_OPEN:
                        break;
                    case Behaviour.Lexemes.BodyPose.LEGS_CROSSED:
                        break;
                    case Behaviour.Lexemes.BodyPose.LEGS_NEUTRAL:
                        break;
                    case Behaviour.Lexemes.BodyPose.LEGS_OPEN:
                        break;
                    case Behaviour.Lexemes.BodyPose.LEANING_FORWARD:
                        StartCoroutine(LeanIn(duration, pose.Degree));
                        break;
                    case Behaviour.Lexemes.BodyPose.FIST_COVER_MOUTH:
                        StartCoroutine(Pose(0, 2, duration));
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }

            yield return new WaitForSeconds(duration);
            if (posePriority == chunk.Priority) {
                posePriority = 0;
            }
        } else {
            Debug.Log("Chunk cancelled. " + chunk);
        }
    }
示例#58
0
	// ================================================================ //

	// 자세를 보간한다.
	public static Posture lerp(Posture posture0, Posture posture1, float rate)
	{
		Posture		dest = new Posture();

		Vector3		eye_vector0 = posture0.position - posture0.intererst;
		Vector3		eye_vector1 = posture1.position - posture1.intererst;

		Quaternion	eye_dir0 = Quaternion.LookRotation(eye_vector0);
		Quaternion	eye_dir1 = Quaternion.LookRotation(eye_vector1);

		Quaternion	dest_dir = Quaternion.Lerp(eye_dir0, eye_dir1, rate);

		float		dest_distance = Mathf.Lerp(eye_vector0.magnitude, eye_vector1.magnitude, rate);

		Vector3		dest_eye_vector = dest_dir*Vector3.forward*dest_distance;

		dest.intererst = Vector3.Lerp(posture0.intererst, posture1.intererst, rate);
		dest.position  = dest.intererst + dest_eye_vector;
		dest.up        = Vector3.Lerp(posture0.up, posture1.up, rate);

		return(dest);
	}
        public void getHunch()
        {
            

            double x1 = body.Joints[JointType.Head].Position.X * Math.Sin(shouldersAngle);
            double z1 = body.Joints[JointType.Head].Position.Z * Math.Cos(shouldersAngle);

            double x2 = body.Joints[JointType.SpineMid].Position.X * Math.Sin(shouldersAngle);
            double z2 = body.Joints[JointType.SpineMid].Position.Z * Math.Cos(shouldersAngle);

            if (-x1 + z1 < -x2 + z2)
            {
                
                hunch = true;
                bodyPosture = Posture.bad;
                PresentationAction pa = new PresentationAction(PresentationAction.MistakeType.HUNCHBACK);
                currentMistakes.Add(pa);
            }
            else
            {
                hunch = false;
            }
           
           
        }