Beispiel #1
0
        protected virtual void CreatePolygonForText(Text t)
        {
            //PropertyInfo scaleXProperty = t.GetType().GetProperty("ScaleX");
            //PropertyInfo scaleYProperty = t.GetType().GetProperty("ScaleY");

            // Why aren't we multiplying this by 2?
            float width  = t.ScaleX; // (float)scaleYProperty.GetValue(t, null);
            float height = t.ScaleY; // (float)scaleXProperty.GetValue(t, null);


            Polygon newPoly = Polygon.CreateRectangle(width, height);

            InitializeNewPoly(newPoly);
            mHighlightShapes.Add(newPoly);

            Vector3 pos = new Vector3(t.HorizontalCenter, t.VerticalCenter, t.Z);

            newPoly.Position = pos;

            newPoly.RotationMatrix = t.RotationMatrix;

            newPoly.Color = new Color(1, 1, 1, .5f);
            newPoly.AttachTo((PositionedObject)t, true);

            if (!float.IsInfinity(t.MaxWidth))
            {
                newPoly = Polygon.CreateRectangle(t.MaxWidth / 2.0f, height);
                InitializeNewPoly(newPoly);
                mHighlightShapes.Add(newPoly);


                float x;
                if (t.HorizontalAlignment == HorizontalAlignment.Left)
                {
                    x = t.X + t.MaxWidth / 2.0f;
                }
                else if (t.HorizontalAlignment == HorizontalAlignment.Center)
                {
                    x = t.X;
                }
                else
                {
                    x = t.X - t.MaxWidth / 2.0f;
                }

                pos = new Vector3(x, t.VerticalCenter, t.Z);
                newPoly.Position = pos;

                newPoly.RotationMatrix = t.RotationMatrix;

                newPoly.AttachTo((PositionedObject)t, true);

                newPoly.Color = new Color(1, .25f, 0, .5f);
            }
        }
Beispiel #2
0
        protected virtual void CreatePolygonForScalableEntity(ElementRuntime element)
        {
            NamedObjectSave namedObjectSave = element.AssociatedNamedObjectSave;

            object scaleXAsObject = namedObjectSave.GetEffectiveValue("ScaleX");
            object scaleYAsObject = namedObjectSave.GetEffectiveValue("ScaleY");

            if (scaleXAsObject != null && scaleYAsObject != null)
            {
                float scaleX = (float)scaleXAsObject;
                float scaleY = (float)scaleYAsObject;

                Polygon newPoly = Polygon.CreateRectangle(scaleX, scaleY);

                InitializeNewPoly(newPoly);

                newPoly.Position = element.Position;

                mHighlightShapes.Add(newPoly);

                newPoly.AttachTo(element, true);

                newPoly.RelativeRotationZ = 0;
            }
        }
Beispiel #3
0
        public ScalableSelector()
        {
            mDarkPolygon       = Polygon.CreateRectangle(1, 1);
            mDarkPolygon.Color = Color.Black;

            mLightPolygon = Polygon.CreateRectangle(1, 1);

            SpriteManager.AddPositionedObject(this);

            ShapeManager.AddPolygon(mDarkPolygon);
            ShapeManager.AddPolygon(mLightPolygon);

            mDarkPolygon.AttachTo(this, false);
            mLightPolygon.AttachTo(this, false);
        }
Beispiel #4
0
        protected virtual void CreatePolygonForCircle(object o)
        {
            Circle asCircle = o as Circle;

            Polygon newPoly = Polygon.CreateRectangle(asCircle.Radius, asCircle.Radius);

            InitializeNewPoly(newPoly);

            Vector3 pos = asCircle.Position;

            newPoly.Position = pos;

            mHighlightShapes.Add(newPoly);

            newPoly.AttachTo(asCircle, true);

            newPoly.RelativeRotationZ = 0;
        }
Beispiel #5
0
        protected virtual Polygon CreatePolygonForIScalable(object obj)
        {
            Polygon newPoly = Polygon.CreateRectangle((IReadOnlyScalable)obj);

            InitializeNewPoly(newPoly);

            Vector3 pos = (Vector3)typeof(PositionedObject).GetField("Position").GetValue(obj);

            newPoly.Position = pos;

            mHighlightShapes.Add(newPoly);

            newPoly.AttachTo((PositionedObject)obj, true);

            newPoly.RelativeRotationZ = 0;

            return(newPoly);
        }
Beispiel #6
0
        public Emitter()
            : base()
        {
            mEmissionSettings = new EmissionSettings();
            mRandom           = FlatRedBallServices.Random;

            // Justin Johnson, 04/2015 - retiring particle blueprints
            //ParticleBlueprint = new Sprite();

            mEmissionBoundary = Polygon.CreateRectangle(32, 32);
            mEmissionBoundary.AttachTo(this, false);

            mAreaEmission = AreaEmissionType.Point;

            this.ParentRotationChangesPosition     = true;
            this.ParentRotationChangesRotation     = true;
            mParentVelocityChangesEmissionVelocity = true;

            mSecondsModifier = 1.0f;
        }
Beispiel #7
0
        private void CreatePolygonForPolygon(Polygon polygon)
        {
            Polygon newPoly = new Polygon();

            Vector3 pos = polygon.Position;

            newPoly.Position = pos;

            mHighlightShapes.Add(newPoly);

            newPoly.AttachTo(polygon, true);

            newPoly.RelativeRotationZ = 0;

            newPoly.Points = polygon.Points;

            const int pixelsOut = 2;

            GrowPolygonByPixels(pixelsOut, polygon.Z, newPoly);
            InitializeNewPoly(newPoly);
        }
Beispiel #8
0
        public void SetCollision(Polygon polygon)
        {
            mCollisionCircle = null;
            mCollisionAxisAlignedRectangle = null;
            mCollisionLine = null;

            mCollisionPolygon = polygon;

            mCollisionPolygon.AttachTo(this, false);
            mCollisionPolygon.ForceUpdateDependencies();
        }
Beispiel #9
0
        private void CreatePolygonForPolygon(Polygon polygon)
        {

            Polygon newPoly = new Polygon();

            Vector3 pos = polygon.Position;

            newPoly.Position = pos;

            mHighlightShapes.Add(newPoly);

            newPoly.AttachTo(polygon, true);

            newPoly.RelativeRotationZ = 0;

            newPoly.Points = polygon.Points;

            const int pixelsOut = 2;

            GrowPolygonByPixels(pixelsOut, polygon.Z, newPoly);
            InitializeNewPoly(newPoly);

        }
 private void createCollision()
 {
     // The polygon will be visible by default, so this will serve as both our visible representation
     // as well as collision.
     pCollision = ShapeManager.AddPolygon();
     Point[] polygonPoints = new Point[4];
     polygonPoints[0] = new Point(11, 0);
     polygonPoints[1] = new Point(-11, -8);
     polygonPoints[2] = new Point(-11, 8);
     polygonPoints[3] = polygonPoints[0];
     pCollision.Points = polygonPoints;
     // Finally attach the collision to this: That makes it eaasier to access all its properties.
     pCollision.AttachTo(this, false);
 }