コード例 #1
0
        private void UpdateCornerRectangleCount()
        {
            int numberOfEdges = 0;

            foreach (Polygon polygon in CurrentShapeCollection.Polygons)
            {
                // Polygons of 1 point should still draw their point

                if (polygon.Points.Count == 1)
                {
                    numberOfEdges++;
                }
                else
                {
                    numberOfEdges +=
                        polygon.Points.Count - 1; // assume the last point repeats
                }
            }

            while (mCorners.Count < numberOfEdges)
            {
                AxisAlignedRectangle newRectangle = ShapeManager.AddAxisAlignedRectangle();
                newRectangle.Color = Color.Red;

                newRectangle.ScaleX = newRectangle.ScaleY = .3f;

                mCorners.Add(newRectangle);
            }

            while (mCorners.Count > numberOfEdges)
            {
                ShapeManager.Remove(mCorners[mCorners.Count - 1]);
            }
        }
コード例 #2
0
 private void CreateCollision()
 {
     frbCollision        = ShapeManager.AddAxisAlignedRectangle();
     frbCollision.ScaleX = 4;
     frbCollision.ScaleY = 4;
     frbCollision.AttachTo(this, false);
 }
コード例 #3
0
        public TextWidthHandles()
        {
            mLeftLine        = ShapeManager.AddLine();
            mTopSolidLine    = ShapeManager.AddLine();
            mBottomSolidLine = ShapeManager.AddLine();
            mTopSoftLine     = ShapeManager.AddLine();
            mBottomSoftLine  = ShapeManager.AddLine();
            mRightLine       = ShapeManager.AddLine();

            mRightBox = ShapeManager.AddAxisAlignedRectangle();

            mLeftLine.Color        = Color.Green;
            mTopSolidLine.Color    = Color.Green;
            mBottomSolidLine.Color = Color.Green;
            mRightLine.Color       = Color.Green;

#if FRB_MDX
            mTopSoftLine.Color = Color.FromArgb(
                128, Color.Green);

            mBottomSoftLine.Color = mTopSoftLine.Color;
#else
            throw new NotImplementedException();
#endif

            mRightBox.Color = Color.Orange;
        }
コード例 #4
0
        public CameraBounds(Camera cameraShowing)
        {
            if (cameraShowing == null)
            {
                throw new NullReferenceException("Need a non-null Camera to show");
            }

            mCamera = cameraShowing;

            mRectangle = ShapeManager.AddAxisAlignedRectangle();
        }
コード例 #5
0
        public SplinePointSelectionMarker()
        {
            mRectangle       = ShapeManager.AddAxisAlignedRectangle();
            mLine            = ShapeManager.AddLine();
            mRectangle.Color = Color.LightBlue;

            mEndpoint1       = ShapeManager.AddCircle();
            mEndpoint1.Color = Color.Yellow;
            mEndpoint2       = ShapeManager.AddCircle();
            mEndpoint2.Color = Color.Yellow;
        }
コード例 #6
0
        public override void Initialize(bool addToManagers)
        {
            base.Initialize(addToManagers);

            mObjectHighlight       = new ObjectHighlight();
            mObjectHighlight.Color = Color.Orange;
            mEditingHandles        = new EditingHandles();

            mRectangle = ShapeManager.AddAxisAlignedRectangle();
            mSprite    = SpriteManager.AddSprite("redball.bmp");
            mSprite.X  = 5;
        }
コード例 #7
0
ファイル: ShapeTest.cs プロジェクト: profexorgeek/FlatRedBall
        public override void Initialize(bool addToManagers)
        {
            base.Initialize(addToManagers);

            for (var i = 0; i < 1000; i++)
            {
                var angle = FlatRedBallServices.Random.Between(-3.14f, 3.14f);
                var c     = ShapeManager.AddCircle();
                c.Radius     = FlatRedBallServices.Random.Between(4f, 15f);
                c.Position.X = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteLeftXEdgeAt(0), Camera.Main.AbsoluteRightXEdgeAt(0));
                c.Position.Y = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteBottomYEdgeAt(0), Camera.Main.AbsoluteTopYEdgeAt(0));
                c.Color      = Microsoft.Xna.Framework.Color.Aquamarine;
                c.Velocity.X = (float)Math.Sin(angle) * movementVelocity;
                c.Velocity.Y = (float)Math.Cos(angle) * movementVelocity;
                circles.Add(c);
            }

            for (var i = 0; i < 1000; i++)
            {
                var angle = FlatRedBallServices.Random.Between(-3.14f, 3.14f);
                var r     = ShapeManager.AddAxisAlignedRectangle();
                r.Width      = FlatRedBallServices.Random.Between(4f, 15f);
                r.Height     = FlatRedBallServices.Random.Between(4f, 15f);
                r.Position.X = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteLeftXEdgeAt(0), Camera.Main.AbsoluteRightXEdgeAt(0));
                r.Position.Y = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteBottomYEdgeAt(0), Camera.Main.AbsoluteTopYEdgeAt(0));
                r.Color      = Microsoft.Xna.Framework.Color.GreenYellow;
                r.Velocity.X = (float)Math.Sin(angle) * movementVelocity;
                r.Velocity.Y = (float)Math.Cos(angle) * movementVelocity;
                rectangles.Add(r);
            }

            for (var i = 0; i < 1000; i++)
            {
                var angle = FlatRedBallServices.Random.Between(-3.14f, 3.14f);
                var p     = ShapeManager.AddPolygon();
                p.Points = new List <Point>()
                {
                    new Point(-8, 8),
                    new Point(8, 8),
                    new Point(8, -8),
                    new Point(-8, -8),
                    new Point(-8, 8)
                };
                p.Position.X        = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteLeftXEdgeAt(0), Camera.Main.AbsoluteRightXEdgeAt(0));
                p.Position.Y        = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteBottomYEdgeAt(0), Camera.Main.AbsoluteTopYEdgeAt(0));
                p.Color             = Microsoft.Xna.Framework.Color.Pink;
                p.Velocity.X        = (float)Math.Sin(angle) * movementVelocity;
                p.Velocity.Y        = (float)Math.Cos(angle) * movementVelocity;
                p.RotationZVelocity = FlatRedBallServices.Random.Between(-1.5f, 1.5f);
                polygons.Add(p);
            }
        }
コード例 #8
0
        internal void HandleElementLoaded()
        {
            if (GlueViewState.Self.CurrentGlueProject != null)
            {
                if (boundsRectangle == null)
                {
                    boundsRectangle = ShapeManager.AddAxisAlignedRectangle();
                }

                boundsRectangle.Width  = GlueViewState.Self.CurrentGlueProject.OrthogonalWidth;
                boundsRectangle.Height = GlueViewState.Self.CurrentGlueProject.OrthogonalHeight;
            }
        }
コード例 #9
0
        void CustomInitialize()
        {
            mStatic  = new AxisAlignedRectangle();
            mFalling = new AxisAlignedRectangle();
            ShapeManager.AddAxisAlignedRectangle(mStatic);
            ShapeManager.AddAxisAlignedRectangle(mFalling);

            mStatic.ScaleX = 32;
            mStatic.ScaleY = 32;

            mFalling.ScaleX = 16;
            mFalling.ScaleY = 16;
        }
コード例 #10
0
        public void CopyCurrentAxisAlignedRectangles()
        {
            foreach (AxisAlignedRectangle rectangle in CurrentShapeCollection.AxisAlignedRectangles)
            {
                AxisAlignedRectangle newRectangle = rectangle.Clone <AxisAlignedRectangle>();

                ShapeManager.AddAxisAlignedRectangle(newRectangle);

                EditorData.ShapeCollection.AxisAlignedRectangles.Add(newRectangle);

                FlatRedBall.Utilities.StringFunctions.MakeNameUnique <AxisAlignedRectangle>(newRectangle, EditorData.AxisAlignedRectangles);
            }
        }
コード例 #11
0
        private void RefreshBounds()
        {
            if (GlueViewState.Self.CurrentGlueProject != null)
            {
                if (boundsRectangle == null)
                {
                    boundsRectangle = ShapeManager.AddAxisAlignedRectangle();
                }

                var glueProject = GlueViewState.Self.CurrentGlueProject;

                if (glueProject.DisplaySettings != null)
                {
                    if (glueProject.DisplaySettings.Is2D)
                    {
                        boundsRectangle.Width  = glueProject.DisplaySettings.ResolutionWidth;
                        boundsRectangle.Height = glueProject.DisplaySettings.ResolutionHeight;
                    }
                }
                else
                {
                    boundsRectangle.Width  = glueProject.OrthogonalWidth;
                    boundsRectangle.Height = glueProject.OrthogonalHeight;
                }

                var currentElement        = GlueViewState.Self.CurrentElement;
                var recursiveNamedObjects = currentElement.GetAllNamedObjectsRecurisvely();

                // see if the current element has a camera and if it's offset...
                var cameraNoses = recursiveNamedObjects
                                  .Where(item =>
                                         item.SourceType == FlatRedBall.Glue.SaveClasses.SourceType.FlatRedBallType &&
                                         item.SourceClassType == "Camera");

                foreach (var cameraNos in cameraNoses)
                {
                    var xAsObject = cameraNos.GetPropertyValue("X");
                    var yAsObject = cameraNos.GetPropertyValue("Y");

                    if (xAsObject is float)
                    {
                        boundsRectangle.X = (float)xAsObject;
                    }
                    if (yAsObject is float)
                    {
                        boundsRectangle.Y = (float)yAsObject;
                    }
                }
            }
        }
コード例 #12
0
        public ReactiveHud()
        {
            mCameraBounds = new CameraBounds(EditorData.BoundsCamera);

            mCurrentAxisAlignedRectangleHighlight         = ShapeManager.AddAxisAlignedRectangle();
            mCurrentAxisAlignedRectangleHighlight.Visible = false;

            mCurrentAxisAlignedCubeHighlight         = ShapeManager.AddAxisAlignedRectangle();
            mCurrentAxisAlignedCubeHighlight.Visible = false;

            mCurrentCircleHighlight         = ShapeManager.AddAxisAlignedRectangle();
            mCurrentCircleHighlight.Visible = false;

            mCurrentSphereHighlight         = ShapeManager.AddAxisAlignedRectangle();
            mCurrentSphereHighlight.Visible = false;

            mCrossHair         = new Crosshair();
            mCrossHair.Visible = false;


            float   screensize     = 5f;
            Vector3 forwardVector  = MathFunctions.ForwardVector3;
            Matrix  rotationMatrix = SpriteManager.Camera.RotationMatrix;

            MathFunctions.TransformVector(ref forwardVector, ref rotationMatrix);


            float planeDistance = Vector3.Dot(forwardVector, -SpriteManager.Camera.Position);

            float planeScreenHeight = 2f * planeDistance * (float)Math.Tan((double)SpriteManager.Camera.FieldOfView);
            float planeScreenWidth  = planeScreenHeight / SpriteManager.Camera.FieldOfView;


            float width  = screensize * planeScreenWidth / (float)SpriteManager.Camera.DestinationRectangle.Width;
            float height = screensize * planeScreenHeight / (float)SpriteManager.Camera.DestinationRectangle.Height;


            mNewPointPolygon       = Polygon.CreateEquilateral(3, Math.Min(width, height), 0); //.3f, 0);
            mNewPointPolygon.Color = EditorProperties.NewPointPolygonColor;

            mPointText = TextManager.AddText("");

            NewPointPolygonScale = 10 / SpriteManager.Camera.PixelsPerUnitAt(mNewPointPolygon.Z);
        }
コード例 #13
0
        private void UpdateCornerRectangleCount()
        {
            int numberOfEdges = AppState.Self.CurrentEmitter.EmissionBoundary.Points.Count - 1; // assume the last point repeats

            while (mCurrentEmitterBoundaryCorners.Count < numberOfEdges)
            {
                AxisAlignedRectangle newRectangle = ShapeManager.AddAxisAlignedRectangle();
                newRectangle.Color = Color.Red;

                newRectangle.ScaleX = newRectangle.ScaleY = .3f;

                mCurrentEmitterBoundaryCorners.Add(newRectangle);
            }

            while (mCurrentEmitterBoundaryCorners.Count > numberOfEdges)
            {
                ShapeManager.Remove(mCurrentEmitterBoundaryCorners[mCurrentEmitterBoundaryCorners.Count - 1]);
            }
        }
コード例 #14
0
        public void AddAxisAlignedRectangle()
        {
            AxisAlignedRectangle rectangle = new AxisAlignedRectangle();

            ShapeManager.AddAxisAlignedRectangle(rectangle);
            rectangle.Color = EditorProperties.AxisAlignedRectangleColor;

            rectangle.X = SpriteManager.Camera.X;
            rectangle.Y = SpriteManager.Camera.Y;

            float scale = (float)Math.Abs(
                18 / SpriteManager.Camera.PixelsPerUnitAt(0));

            rectangle.ScaleX = scale;
            rectangle.ScaleY = scale;

            EditorData.ShapeCollection.AxisAlignedRectangles.Add(rectangle);

            rectangle.Name = "AxisAlignedRectangle" + EditorData.AxisAlignedRectangles.Count;

            StringFunctions.MakeNameUnique <AxisAlignedRectangle>(rectangle, EditorData.AxisAlignedRectangles);
        }
コード例 #15
0
 public CameraBounds(CameraSave cameraSave)
 {
     mCameraSave = cameraSave;
     mRectangle  = ShapeManager.AddAxisAlignedRectangle();
 }
コード例 #16
0
        private object CreateFlatRedBallTypeNos(NamedObjectSave namedObjectSave,
                                                PositionedObjectList <ElementRuntime> listToPopulate, Layer layerToPutOn)
        {
            object returnObject = null;

            ElementRuntime newElementRuntime = null;

            switch (namedObjectSave.SourceClassType)
            {
            case "Layer":
            case "FlatRedBall.Graphics.Layer":
                returnObject = CreateLayerObject(namedObjectSave, returnObject);
                break;

            case "AxisAlignedRectangle":
            case "FlatRedBall.Math.Geometry.AxisAlignedRectangle":
                AxisAlignedRectangle aaRectangle = ShapeManager.AddAxisAlignedRectangle();
                if (layerToPutOn != null)
                {
                    ShapeManager.AddToLayer(aaRectangle, layerToPutOn);
                }
                aaRectangle.Name = namedObjectSave.InstanceName;
                returnObject     = aaRectangle;
                break;

            case "Camera":
            case "FlatRedBall.Camera":
                if (namedObjectSave.IsNewCamera)
                {
                    returnObject = null;
                }
                else
                {
                    returnObject = SpriteManager.Camera;
                }
                break;

            case "Circle":
            case "FlatRedBall.Math.Geometry.Circle":
                Circle circle = ShapeManager.AddCircle();
                circle.Name = namedObjectSave.InstanceName;
                if (layerToPutOn != null)
                {
                    ShapeManager.AddToLayer(circle, layerToPutOn);
                }
                returnObject = circle;

                break;

            case "Polygon":
            case "FlatRedBall.Math.Geometry.Polygon":
                Polygon polygon = ShapeManager.AddPolygon();
                polygon.Name = namedObjectSave.InstanceName;

                if (layerToPutOn != null)
                {
                    ShapeManager.AddToLayer(polygon, layerToPutOn);
                }
                returnObject = polygon;

                break;

            case "Sprite":
            case "FlatRedBall.Sprite":
                Sprite sprite = SpriteManager.AddSprite((Texture2D)null);
                if (layerToPutOn != null)
                {
                    SpriteManager.AddToLayer(sprite, layerToPutOn);
                }
                sprite.Name  = namedObjectSave.InstanceName;
                returnObject = sprite;
                break;

            case "SpriteFrame":
            case "FlatRedBall.ManagedSpriteGroups.SpriteFrame":
                SpriteFrame spriteFrame = SpriteManager.AddSpriteFrame(null, SpriteFrame.BorderSides.All);
                if (layerToPutOn != null)
                {
                    SpriteManager.AddToLayer(spriteFrame, layerToPutOn);
                }
                spriteFrame.Name = namedObjectSave.InstanceName;
                returnObject     = spriteFrame;
                break;

            case "Text":
            case "FlatRedBall.Graphics.Text":
                Text text = TextManager.AddText("");
                if (layerToPutOn != null)
                {
                    TextManager.AddToLayer(text, layerToPutOn);
                    text.SetPixelPerfectScale(layerToPutOn);
                }
                text.Name    = namedObjectSave.InstanceName;
                returnObject = text;
                break;

            case "Scene":
            case "FlatRedBall.Scene":
                Scene scene = new Scene();

                scene.Name   = namedObjectSave.InstanceName;
                returnObject = scene;
                break;

            default:
                // do nothing - need to add more types?
                break;
            }

            if (returnObject != null)
            {
                if (returnObject is IScalable)
                {
                    newElementRuntime = new ScalableElementRuntime(null, layerToPutOn, namedObjectSave, CreationOptions.OnBeforeVariableSet, CreationOptions.OnAfterVariableSet);
                }
                else
                {
                    newElementRuntime = new ElementRuntime(null, layerToPutOn, namedObjectSave, CreationOptions.OnBeforeVariableSet, CreationOptions.OnAfterVariableSet);
                }
                newElementRuntime.mDirectObjectReference = returnObject;

                if (returnObject is Camera && !namedObjectSave.IsNewCamera)
                {
                    SpriteManager.Camera.AttachTo(newElementRuntime, false);
                    SpriteManager.Camera.RelativePosition = Vector3.Zero;
                    newElementRuntime.Z    = 40;
                    newElementRuntime.Name = namedObjectSave.InstanceName;
                }
                else if (returnObject is FlatRedBall.Utilities.INameable)
                {
                    newElementRuntime.Name = ((FlatRedBall.Utilities.INameable)returnObject).Name;
                }
                else
                {
                    object nameValueAsObject;
                    if (LateBinder.TryGetValueStatic(returnObject, "Name", out nameValueAsObject))
                    {
                        newElementRuntime.Name = (string)nameValueAsObject;
                    }
                }

                listToPopulate.Add(newElementRuntime);
            }

            return(returnObject);
        }
コード例 #17
0
 public RectangleSelector()
 {
     mRectangle         = ShapeManager.AddAxisAlignedRectangle();
     mRectangle.Visible = false;
 }
コード例 #18
0
ファイル: Spline.cs プロジェクト: Riva3000/FlatRedBall
        public void UpdateShapes()
        {
            #region If Invisible, remove everything
            if (mVisible == false)
            {
                while (mSplinePointsCircles.Count != 0)
                {
                    ShapeManager.Remove(mSplinePointsCircles.Last);
                }

                while (mPathRectangles.Count != 0)
                {
                    ShapeManager.Remove(mPathRectangles.Last);
                }
            }
            #endregion

            else
            {
                float radius = SplinePointVisibleRadius;

                #region Create enough SplinePoint Circles for the Spline


                while (mSplinePoints.Count > mSplinePointsCircles.Count)
                {
                    Circle newCircle = ShapeManager.AddCircle();
                    mSplinePointsCircles.Add(newCircle);
                }

                #endregion

                #region Remove any extra SplinePoints

                while (mSplinePoints.Count < mSplinePointsCircles.Count)
                {
                    ShapeManager.Remove(mSplinePointsCircles.Last);
                }

                #endregion

                double duration           = Duration;
                int    numberOfRectangles = 1 + (int)(duration / PointFrequency);

                #region Create enough Path Rectangles for the Spline

                while (numberOfRectangles > mPathRectangles.Count)
                {
                    AxisAlignedRectangle aar = ShapeManager.AddAxisAlignedRectangle();
                    mPathRectangles.Add(aar);
                }

                #endregion

                #region Remove any extra Path Rectangles

                while (numberOfRectangles < mPathRectangles.Count)
                {
                    ShapeManager.Remove(mPathRectangles.Last);
                }

                #endregion

                #region Update the SplinePoint Circle Positions and Colors

                for (int i = 0; i < mSplinePoints.Count; i++)
                {
                    mSplinePointsCircles[i].Position = mSplinePoints[i].Position;
                    mSplinePointsCircles[i].Color    = PointColor;
                    mSplinePointsCircles[i].Radius   = radius;
                }

                #endregion

                #region Update the Path Rectangle Positions and Colors

                double fractionOfTime = this.Duration / (double)mPathRectangles.Count;

                double startTime = 0;

                if (mSplinePoints.Count != 0)
                {
                    startTime = mSplinePoints[0].Time;
                }

                for (int i = 0; i < mPathRectangles.Count; i++)
                {
                    mPathRectangles[i].Position = GetPositionAtTime(startTime + i * fractionOfTime);
                    mPathRectangles[i].Color    = PathColor;
                    mPathRectangles[i].ScaleX   = mPathRectangles[i].ScaleY = radius / 2.0f;
                }

                #endregion
            }
        }
コード例 #19
0
ファイル: GameScreen.cs プロジェクト: dgkane/KamiClimberRepo
        // *** Updates game screen each frame based on entity activity, user input ***
        public override void Activity(bool firstTimeCalled)
        {
            base.Activity(firstTimeCalled);


            // Farseer : step (update) world; rate defined in Game1.cs
            //
            farWorld.Step(TimeManager.SecondDifference);


            getKeyboard();


            #region invoke_entity_activity

            frbRGripButton.Activity();
            frbLGripButton.Activity();

            frbClimber.Activity();

            frbCursor.Activity();

            foreach (GripEntity grip in frbGrips)
            {
                grip.Activity();
            }

            // frbRGripButton.Activity();
            // frbLGripButton.Activity();

            // frbRSwingButton.Activity();
            // frbLSwingButton.Activity();

            // frbPullUpButton.Activity();


            #endregion


            // ***
            //
            // Check whether each of climber's hands is in the 'release' state
            //
            // If so, they are open to attaching to a grip on collision
            //
            if (frbClimber.getRHandFree == true)
            // {
            //     frbClimber.setRHandGrip(false, frbClimber.RHandBody.Position);
            // }
            // else
            {
                frbRGripButton.setActive(false);
                foreach (GripEntity grip in frbGrips)
                {
                    if (frbClimber.RHandCollision.CollideAgainst(grip.Collision))
                    {
                        if (grip.checkIsActive == false)
                        {
                            grip.setActive(true, TimeManager.CurrentTime);
                        }
                        frbClimber.setRHandGrip(true, new Vector2(grip.Position.X, grip.Position.Y));
                        frbClimber.setRHandFree(false);
                        frbRGripButton.setActive(true);
                        if (grip.getTimeLeft < 0)
                        {
                            frbClimber.RHandRelease();
                        }
                    }
                }
            }
            //
            if (frbClimber.getLHandFree == true)
            // {
            //     frbClimber.setLHandGrip(false, frbClimber.LHandBody.Position);
            // }
            // else
            {
                frbLGripButton.setActive(false);
                foreach (GripEntity grip in frbGrips)
                {
                    if (frbClimber.LHandCollision.CollideAgainst(grip.Collision))
                    {
                        if (grip.checkIsActive == false)
                        {
                            grip.setActive(true, TimeManager.CurrentTime);
                        }
                        grip.setActive(true, TimeManager.CurrentTime);
                        frbClimber.setLHandGrip(true, new Vector2(grip.Position.X, grip.Position.Y));
                        frbClimber.setLHandFree(false);
                        frbLGripButton.setActive(true);
                        if (grip.getTimeLeft < 0)
                        {
                            frbClimber.LHandRelease();
                        }
                    }
                }
            }
            //
            // ***


            // >> Perhaps incorporate into entity class?
            //
            // ***
            //
            // Check if climber's left/right swinging property is true
            //
            // If so, apply a force to body in respective direction
            //
            if (frbClimber.getSwingLeft == true)
            {
                frbClimber.TorsoBody.ApplyForce(new Vector2(-50, 0));
            }
            //
            if (frbClimber.getSwingRight == true)
            {
                frbClimber.TorsoBody.ApplyForce(new Vector2(50, 0));
            }
            //
            //
            // Check if climber's pulling up property is true
            //
            // If so, apply upward force to body
            //
            if (frbClimber.getPullUp == true && frbClimber.getIsRecharging == false)
            {
                frbClimber.TorsoBody.ApplyForce(new Vector2(0, 100));
            }
            //


            // >>> This will need to be modified for touch input where two buttons are not available for L/R hand reach
            // >>> Possibly incorporate into entity class
            //
            // ***
            //
            // If one of climber's hands 'grip' property is true,
            //
            // and the opposite hand's 'reach' property is true,
            //
            // Apply a linear velocity to that hand
            //
            //
            // First 'if' condition necessary?
            if (frbClimber.getRHandGrip == true && frbClimber.getLHandGrip == false)
            {
                if (frbClimber.getReach == true)
                {
                    frbClimber.TorsoBody.ApplyForce(new Vector2(-20, 20));
                    Vector2 vec = new Vector2(frbCursor.X - frbClimber.LHandCollision.X, frbCursor.Y - frbClimber.LHandCollision.Y);
                    vec.Normalize();
                    frbClimber.LHandBody.LinearVelocity = vec * 20;
                }
            }
            //
            if (frbClimber.getRHandGrip == false && frbClimber.getLHandGrip == true)
            {
                if (frbClimber.getReach == true)
                {
                    frbClimber.TorsoBody.ApplyForce(new Vector2(20, 20));
                    Vector2 vec = new Vector2(frbCursor.X - frbClimber.RHandCollision.X, frbCursor.Y - frbClimber.RHandCollision.Y);
                    vec.Normalize();
                    frbClimber.RHandBody.LinearVelocity = vec * 20;
                }
            }

            foreach (CheckpointEntity cp in frbCheckpoints)
            {
                if (frbClimber.TorsoCollision.CollideAgainst(cp.Collision))
                {
                    float f = cp.getTimeBonus;
                    timeLimit += f;
                    cp.Destroy();
                }
            }

            // if (frbClimber.getRHandGrip == true && frbClimber.getLHandGrip == true)
            // {
            //     frbClimber.setRHandGrip(false, new Vector2(0, 0));
            //     frbClimber.RHandBody.LinearVelocity = new Vector2(frbCursor.X - frbClimber.RHandCollision.X, frbCursor.Y - frbClimber.RHandCollision.Y);
            //
            // }


            #region ui_operations

            // *** UI operations ***
            //
            // Center view on center of climber's body
            //
            SpriteManager.Camera.X = frbClimber.getClimberCentre.X;
            if (frbClimber.getClimberCentre.Y > -50)
            {
                SpriteManager.Camera.Y = frbClimber.getClimberCentre.Y;
            }
            //
            //
            // *** Update HUD each frame so it stays relative to camera position ***
            //
            TextManager.RemoveText(Strength);
            Strength         = TextManager.AddText("Strength : ");
            Strength.Spacing = 2f;
            Strength.Scale   = 2.5f;
            Strength.X       = SpriteManager.Camera.X - 65;
            Strength.Y       = SpriteManager.Camera.Y + 36;
            //
            //
            // Get climber's current 'exertion' value to inform length of UI meter
            //
            if (exertionMeter != null)
            {
                ShapeManager.Remove(exertionMeter);
            }
            exertionMeter        = new AxisAlignedRectangle();
            exertionMeter.Y      = SpriteManager.Camera.Y + 36;
            exertionMeter.X      = SpriteManager.Camera.X - 38;
            exertionMeter.ScaleY = 2;
            exertionMeter.ScaleX = 8 - (frbClimber.getExertion / 30);
            ShapeManager.AddAxisAlignedRectangle(exertionMeter);
            //
            //
            // Display 'OK!' if exertion meter has recharged and climber can 'pull up' again
            //
            TextManager.RemoveText(okText);
            if (frbClimber.getIsExerting == false && frbClimber.getIsRecharging == false)
            {
                okText         = TextManager.AddText("O K !");
                okText.Spacing = 2f;
                okText.Scale   = 2.5f;
                okText.X       = SpriteManager.Camera.X - 26;
                okText.Y       = SpriteManager.Camera.Y + 36;
            }
            //
            //
            // Display time remaining to reach next checkpoint
            //
            TextManager.RemoveText(timer);
            timer         = TextManager.AddText("Checkpoint : " + (int)(timeLimit - TimeManager.CurrentTime));
            timer.Spacing = 2f;
            timer.Scale   = 2.5f;
            timer.X       = SpriteManager.Camera.X + 38;
            timer.Y       = SpriteManager.Camera.Y + 36;
            //
            //
            // Instruction overlay
            //
            // >>> To be replaced with help screen
            // TextManager.RemoveText(instructions);
            // instructions = TextManager.AddText("Arrow keys swing left and right and pull up.\nQ and W release left and right hand from grips.\nLMB and RMB reach with left and right hand.");
            // instructions.Spacing = 2f;
            // instructions.NewLineDistance = 4f;
            // instructions.Scale = 2.5f;
            // instructions.Alpha = 0.5f;
            // instructions.X = SpriteManager.Camera.X - 65;
            // instructions.Y = SpriteManager.Camera.Y - 32;
            //
            if (frbClimber.RHandCollision.CollideAgainst(frbGrip2.Collision))
            {
                frbTut.setPhase(2);
            }
            if (frbClimber.RHandCollision.CollideAgainst(frbGrip2.Collision) && frbClimber.LHandCollision.CollideAgainst(frbGrip2.Collision))
            {
                frbTut.setPhase(3);
            }
            if (frbClimber.RHandCollision.CollideAgainst(frbGrip3.Collision) && frbClimber.LHandCollision.CollideAgainst(frbGrip3.Collision))
            {
                frbTut.setPhase(4);
            }
            if (frbClimber.RHandCollision.CollideAgainst(frbGrip4.Collision))
            {
                frbTut.setPhase(5);
            }
            if (frbClimber.RHandCollision.CollideAgainst(frbGrip4.Collision) && frbClimber.LHandCollision.CollideAgainst(frbGrip4.Collision))
            {
                frbTut.setPhase(6);
            }
            //
            if (frbClimber.getClimberCentre.Y < -100)
            {
                this.Destroy();
            }

            frbTut.Activity();

            // ***

            #endregion
        }
コード例 #20
0
 public ObjectHighlight()
 {
     mHighlightRectangle = ShapeManager.AddAxisAlignedRectangle();
 }