예제 #1
0
        protected void InitializeNewPoly(Polygon polygon)
        {
            ShapeManager.AddPolygon(polygon);

            ShapeManager.AddToLayer(polygon, Layer);

            polygon.Color = Color;
        }
예제 #2
0
        public ReactiveHud()
        {
            mWorldAxesDisplay = new WorldAxesDisplay();

            mCurrentObjectHighlight = Polygon.CreateRectangle(1, 1);
            ShapeManager.AddPolygon(mCurrentObjectHighlight);
            mCurrentObjectHighlight.Visible = false;
        }
예제 #3
0
        public static void LoadPolygonList(string fileName)
        {
            FlatRedBall.Content.Polygon.PolygonSaveList psl = FlatRedBall.Content.Polygon.PolygonSaveList.FromFile(fileName);

            PositionedObjectList <Polygon> polygonList = psl.ToPolygonList();

            // At a later time may want to support Insert and Replace.  For now, do Replace
            while (Polygons.Count != 0)
            {
                ShapeManager.Remove(Polygons[0]);
            }

            foreach (Polygon polygon in polygonList)
            {
                ShapeManager.AddPolygon(polygon);
                ShapeCollection.Polygons.Add(polygon);
                polygon.Color = EditorProperties.PolygonColor;
            }

#if FRB_MDX
            GameForm.TitleText = "PolygonEditor - Editing " + fileName;
#else
            FlatRedBallServices.Game.Window.Title = "PolygonEditor Editing - " + fileName;
#endif

            LastLoadedShapeCollection = null;
            LastLoadedPolygonList     = fileName;

            #region Load the SavedInformation if available

            fileName = FileManager.RemoveExtension(fileName) + ".pesix";
            if (System.IO.File.Exists(fileName))
            {
                try
                {
                    PolygonEditorSettings savedInformation = PolygonEditorSettings.FromFile(fileName);

                    if (savedInformation.LineGridSave != null)
                    {
                        savedInformation.LineGridSave.ToLineGrid(EditorData.LineGrid);
                    }

                    if (savedInformation.UsePixelCoordinates)
                    {
                        SpriteManager.Camera.UsePixelCoordinates(false);
                    }
                }
                catch
                {
                    GuiManager.ShowMessageBox(
                        "Could not load the settings file " + fileName + ".  \nThe data file was loaded with no problems",
                        "Error");
                }
            }
            #endregion
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        public void CopyCurrentPolygons()
        {
            foreach (Polygon polygon in CurrentShapeCollection.Polygons)
            {
                Polygon newPolygon = polygon.Clone <Polygon>();

                ShapeManager.AddPolygon(newPolygon);

                EditorData.ShapeCollection.Polygons.Add(newPolygon);

                FlatRedBall.Utilities.StringFunctions.MakeNameUnique <Polygon>(newPolygon, EditorData.Polygons);
            }
        }
예제 #6
0
        public Platform(World world, Vector2 size, Vector2 pos)
        {
            farWorld                = world;
            farPlatform             = BodyFactory.CreateRectangle(farWorld, size.X * 2, size.Y * 2, 1, pos);
            farPlatform.Restitution = 1f;
            farPlatform.Rotation    = 0f;
            // Dynamic objects respond to gravity.
            farPlatform.IsStatic = true;

            frbPlatform           = Polygon.CreateRectangle(size.X, size.Y);
            frbPlatform.X         = farPlatform.Position.X;
            frbPlatform.Y         = farPlatform.Position.Y;
            frbPlatform.RotationZ = farPlatform.Rotation;
            ShapeManager.AddPolygon(frbPlatform);
        }
예제 #7
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);
        }
예제 #8
0
        public void addEmitterOkClick(FlatRedBall.Gui.Window callingWindow)
        {
            Emitter newEmitter = new Emitter();

            SpriteManager.AddEmitter(newEmitter);

            ShapeManager.AddPolygon(newEmitter.EmissionBoundary);

            EditorData.SetDefaultValuesOnEmitter(newEmitter);

            EditorData.Emitters.Add(newEmitter);

            newEmitter.Name = ((TextInputWindow)callingWindow).Text;

            newEmitter.Texture = FlatRedBallServices.Load <Texture2D>("content/redball.bmp",
                                                                      AppState.Self.PermanentContentManager);
        }
예제 #9
0
        public PositionedObjectList <Polygon> LoadPolygonList(string name, bool addToShapeManager, bool makeVisible)
        {
            PolygonSaveList psl = PolygonSaveList.FromFile(name);

            PositionedObjectList <Polygon> loadedPolygons = psl.ToPolygonList();

            if (addToShapeManager)
            {
                foreach (Polygon polygon in loadedPolygons)
                {
                    ShapeManager.AddPolygon(polygon);
                }
            }

            foreach (Polygon polygon in loadedPolygons)
            {
                polygon.Visible = makeVisible;
            }

            mPolygons.AddRange(loadedPolygons);

            return(loadedPolygons);
        }
예제 #10
0
        public Polygon AddRectanglePolygon()
        {
            Polygon polygon = Polygon.CreateRectangle(1, 1);

            ShapeManager.AddPolygon(polygon);
            polygon.Color = EditorProperties.PolygonColor;

            polygon.X = SpriteManager.Camera.X;
            polygon.Y = SpriteManager.Camera.Y;

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

            polygon.ScaleBy(scale);

            EditorData.ShapeCollection.Polygons.Add(polygon);

            polygon.Name = "Polygon" + EditorData.Polygons.Count;

            StringFunctions.MakeNameUnique <Polygon>(polygon, EditorData.Polygons);

            return(polygon);
        }
예제 #11
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);
        }
예제 #12
0
 public SnappingManager()
 {
     mAfterSnappingPosition       = Polygon.CreateRectangle(1, 1);
     mAfterSnappingPosition.Color = System.Drawing.Color.White;
     ShapeManager.AddPolygon(mAfterSnappingPosition);
 }
예제 #13
0
        public void LoadEmitters(string fileName)
        {
            #region Clear all Emitters in memory
            while (AppState.Self.Emitters.Count != 0)
            {
                SpriteManager.RemoveEmitter(AppState.Self.Emitters[0]);
            }

            AppState.Self.CurrentEmitter = null;

            #endregion

            #region Load the Emitters and add them to the SpriteManager

            EmitterSaveList emitterSaveList = EmitterSaveList.FromFile(fileName);

            AppState.Self.Emitters = emitterSaveList.ToEmitterList(AppState.Self.PermanentContentManager);

            foreach (Emitter emitter in AppState.Self.Emitters)
            {
                SpriteManager.AddEmitter(emitter);
                ShapeManager.AddPolygon(emitter.EmissionBoundary);
            }

            CurrentEmixFileName = FileManager.RemoveExtension(fileName);
            #endregion

            bool haveAttachments = false;

#if FRB_MDX
            FlatRedBallServices.Owner.Text = "ParticleEditor - Currently editing " + CurrentEmixFileName;
#else
            FlatRedBallServices.Game.Window.Title = "ParticleEditor - Currently editing " + CurrentEmixFileName;
#endif

            for (int i = 0; i < AppState.Self.Emitters.Count; i++)
            {
                if (emitterSaveList.emitters[i].ParentSpriteName != null)
                {
                    // see if the emitter exists in the gameData.emitterArray and set the attachments.  If not, then
                    // we need to set haveAttachments to true, indicating there are attachments to .scn Sprites
                    Emitter e = AppState.Self.Emitters.FindWithNameContaining(emitterSaveList.emitters[i].ParentSpriteName);
                    if (e != null)
                    {
                        AppState.Self.Emitters[i].AttachTo(e, false);
                    }
                    else
                    {
                        haveAttachments = true;
                    }
                }
            }


            // TODO:  Handle when the ParticleEditor can't find attachments.

            if (haveAttachments)
            {
                EditorData.lastLoadedFile = emitterSaveList;

                if (EditorData.Scene == null || EditorData.Scene.Sprites.Count == 0)
                {
                    MultiButtonMessageBox mbmb = GuiManager.AddMultiButtonMessageBox();
                    mbmb.Name = ".emi attachments found";
                    mbmb.Text = fileName + " has one or more attachments.  There are no " +
                                "Sprites loaded.  What would you like to do with the attachment information?";

                    mbmb.ScaleX = 15;

                    mbmb.AddButton("Forget all attachment information.", new GuiMessage(FileMenuWindow.ForgetAttachmentInfo));
                    mbmb.AddButton("Remember attachment information, I will load a .scnx file later.", new GuiMessage(FileMenuWindow.RememberAttachmentInfo));
                    mbmb.AddButton("Manually search for .scnx file now.", new GuiMessage(FileMenuWindow.LoadScnxButtonClick));

                    mbmb.AddButton("Automatically search for .scnx with Sprites matching attachments.", new GuiMessage(FileMenuWindow.AutoSearchScn));
                }
                else
                {
                    FileMenuWindow.AttemptEmitterAttachment("");
                }
            }

            string settingsFileName = FileManager.RemoveExtension(fileName) + ".ess";

            bool doesSettingsFileExist = System.IO.File.Exists(settingsFileName);

            if (doesSettingsFileExist)
            {
                EmitterEditorSettingsSave settings = EmitterEditorSettingsSave.Load(settingsFileName);

                settings.Camera.SetCamera(Camera.Main);

                if (settings.Camera.OrthogonalHeight < 0)
                {
                    Camera.Main.UsePixelCoordinates();
                }
                else
                {
                    Camera.Main.FixAspectRatioYConstant();
                }
            }
        }