public virtual void MapToServerObject(Server.Application.MemberCaseCarePlanAssessmentCareMeasure serverObject)
        {
            base.MapToServerObject((Server.Application.CoreObject)serverObject);


            serverObject.MemberCaseCarePlanAssessmentId = MemberCaseCarePlanAssessmentId;

            serverObject.CareMeasureDomainId = CareMeasureDomainId;

            serverObject.CareMeasureDomainName = CareMeasureDomainName;

            serverObject.CareMeasureClassId = CareMeasureClassId;

            serverObject.CareMeasureClassName = CareMeasureClassName;

            serverObject.CareMeasureId = CareMeasureId;

            serverObject.TargetValue = TargetValue;



            serverObject.Goals = new Server.Application.MemberCaseCarePlanAssessmentCareMeasureGoal[Goals.Count];

            foreach (MemberCaseCarePlanAssessmentCareMeasureGoal currentAssessmentGoal in Goals)
            {
                Server.Application.MemberCaseCarePlanAssessmentCareMeasureGoal serverAssessmentGoal = (Server.Application.MemberCaseCarePlanAssessmentCareMeasureGoal)currentAssessmentGoal.ToServerObject();

                serverObject.Goals[Goals.IndexOf(currentAssessmentGoal)] = serverAssessmentGoal;
            }

            serverObject.Components = new Server.Application.MemberCaseCarePlanAssessmentCareMeasureComponent[Components.Count];

            foreach (MemberCaseCarePlanAssessmentCareMeasureComponent currentAssessmentComponent in Components)
            {
                Server.Application.MemberCaseCarePlanAssessmentCareMeasureComponent serverAssessmentComponent = (Server.Application.MemberCaseCarePlanAssessmentCareMeasureComponent)currentAssessmentComponent.ToServerObject();

                serverObject.Components[Components.IndexOf(currentAssessmentComponent)] = serverAssessmentComponent;
            }

            return;
        }
Beispiel #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            var bounds = GraphicsDevice.Viewport.Bounds;

            PaddleBottom.X = MathHelper.Clamp(PaddleBottom.X, bounds.Left, bounds.Right - PaddleBottom.Width);
            PaddleTop.X    = MathHelper.Clamp(PaddleTop.X, bounds.Left, bounds.Right - PaddleTop.Width);


            var ballPositionChange = Ball.Direction * (float)(gameTime.ElapsedGameTime.TotalMilliseconds * Ball.Speed);

            Ball.X += ballPositionChange.X;
            Ball.Y += ballPositionChange.Y;

            var touchState = Keyboard.GetState();

            if (touchState.IsKeyDown(Keys.Left))
            {
                PaddleBottom.X = PaddleBottom.X - (float)(PaddleBottom.Speed
                                                          * gameTime.ElapsedGameTime.TotalMilliseconds);
            }
            if (touchState.IsKeyDown(Keys.Right))
            {
                PaddleBottom.X = PaddleBottom.X + (float)(PaddleBottom.Speed
                                                          * gameTime.ElapsedGameTime.TotalMilliseconds);
            }

            if (touchState.IsKeyDown(Keys.A))
            {
                PaddleTop.X = PaddleTop.X - (float)(PaddleTop.Speed
                                                    * gameTime.ElapsedGameTime.TotalMilliseconds);
            }
            if (touchState.IsKeyDown(Keys.D))
            {
                PaddleTop.X = PaddleTop.X + (float)(PaddleTop.Speed
                                                    * gameTime.ElapsedGameTime.TotalMilliseconds);
            }

            foreach (Wall wall in Walls)
            {
                if (CollisionDetector.Overlaps(Ball, wall))
                {
                    switch (Ball.Direction.Course)
                    {
                    case Ball.MyVector.Direction.SouthEast:
                    {
                        Ball.Direction = new Ball.MyVector(Ball.MyVector.Direction.SouthWest);
                        break;
                    }

                    case Ball.MyVector.Direction.SouthWest:
                    {
                        Ball.Direction = new Ball.MyVector(Ball.MyVector.Direction.SouthEast);
                        break;
                    }

                    case Ball.MyVector.Direction.NorthEast:
                    {
                        Ball.Direction = new Ball.MyVector(Ball.MyVector.Direction.NorthWest);
                        break;
                    }

                    case Ball.MyVector.Direction.NorthWest:
                    {
                        Ball.Direction = new Ball.MyVector(Ball.MyVector.Direction.NorthEast);
                        break;
                    }
                    }
                    if (Ball.Speed < GameConstants.DefaultBallMaxSpeed)
                    {
                        Ball.Speed *= GameConstants.DefaultIBallBumpSpeedIncreaseFactor;
                    }
                }
            }

            if ((Ball.Direction.Course.Equals(Ball.MyVector.Direction.SouthEast) ||
                 Ball.Direction.Course.Equals(Ball.MyVector.Direction.SouthWest)) &&
                CollisionDetector.Overlaps(Ball, PaddleBottom))
            {
                if (Ball.Direction.Course.Equals(Ball.MyVector.Direction.SouthEast))
                {
                    Ball.Direction = new Ball.MyVector(Ball.MyVector.Direction.NorthEast);
                }
                else
                {
                    Ball.Direction = new Ball.MyVector(Ball.MyVector.Direction.NorthWest);
                }
                if (Ball.Speed < GameConstants.DefaultBallMaxSpeed)
                {
                    Ball.Speed *= GameConstants.DefaultIBallBumpSpeedIncreaseFactor;
                }
            }
            else if ((Ball.Direction.Course.Equals(Ball.MyVector.Direction.NorthEast) ||
                      Ball.Direction.Course.Equals(Ball.MyVector.Direction.NorthWest)) &&
                     CollisionDetector.Overlaps(Ball, PaddleTop))
            {
                if (Ball.Direction.Course.Equals(Ball.MyVector.Direction.NorthEast))
                {
                    Ball.Direction = new Ball.MyVector(Ball.MyVector.Direction.SouthEast);
                }
                else
                {
                    Ball.Direction = new Ball.MyVector(Ball.MyVector.Direction.SouthWest);
                }
                if (Ball.Speed < GameConstants.DefaultBallMaxSpeed)
                {
                    Ball.Speed *= GameConstants.DefaultIBallBumpSpeedIncreaseFactor;
                }
            }

            foreach (Wall goal in Goals)
            {
                if (CollisionDetector.Overlaps(Ball, goal))
                {
                    if (Goals.IndexOf(goal) == 0)
                    {
                        scoreTop++;
                    }
                    else
                    {
                        scoreBottom++;
                    }
                    Ball.X     = bounds.Width / 2f;
                    Ball.Y     = bounds.Height / 2f;
                    Ball.Speed = GameConstants.DefaultInitialBallSpeed;
                    HitSound.Play();
                }
            }
            base.Update(gameTime);
        }