示例#1
0
        public TweenerManager()
        {
            mTweeners = new List <Tweener>();

            FlatRedBallServices.AddManager(this);
        }
 public static void Initialize()
 {
                 #if !REQUIRES_PRIMARY_THREAD_LOADING
     FlatRedBall.Gum.GumIdb.StaticInitialize("content/gumproject/gumproject.gumx"); FlatRedBall.Gum.GumIdb.RegisterTypes();  FlatRedBall.Gui.GuiManager.BringsClickedWindowsToFront = false; FlatRedBallServices.AddManager(RenderingLibrary.SystemManagers.Default);
                 #endif
     IsInitialized = true;
 }
示例#3
0
        public static void StaticInitialize(string projectFileName)
        {
            if (mManagers == null)
            {
                mManagers = new SystemManagers();
                mManagers.Initialize(FlatRedBallServices.GraphicsDevice);
                mManagers.Renderer.Camera.AbsoluteLeft = 0;
                mManagers.Renderer.Camera.AbsoluteTop  = 0;


                // Need to do the zoom here in response to the FRB camera vs. the Gum camera
                mManagers.Renderer.Camera.CameraCenterOnScreen = CameraCenterOnScreen.TopLeft;
                mManagers.Renderer.Camera.X = 0;
                mManagers.Renderer.Camera.Y = 0;

                SystemManagers.Default = mManagers;
                FlatRedBallServices.AddManager(RenderingLibrary.SystemManagers.Default);

                RenderingLibrary.Graphics.Text.RenderBoundaryDefault = false;
                // FlatRedBall uses premult alpha.
                RenderingLibrary.Graphics.Renderer.NormalBlendState = Microsoft.Xna.Framework.Graphics.BlendState.AlphaBlend;

                UpdateDisplayToMainFrbCamera();


                var idb = new GumIdb();
                // We don't want the UI to be at Z=0 because it will render
                // at the same Z along with FRB entities and environments so UI might
                // be hidden. The proper way to solve this is to use Layers, but
                // this shouldn't be creating new Layers, that's up to the user.
                // Let's make it have a positive Z so it draws in more things at once
                idb.Z = 10;

                // This could be called on a secondary thread, like if called by GlobalContent, so we
                // want this to happen on the primary thread:
                Action primaryThreadAction = () =>
                {
                    FlatRedBall.SpriteManager.AddDrawableBatch(idb);
                    FlatRedBall.Screens.ScreenManager.PersistentDrawableBatches.Add(idb);
                };

                var instruction = new FlatRedBall.Instructions.DelegateInstruction(primaryThreadAction);
                FlatRedBall.Instructions.InstructionManager.Add(instruction);
            }

            if (projectFileName == null)
            {
                throw new Exception("The GumIDB must be initialized with a valid (non-null) project file.");
            }

            string errors;

            mProjectFileName = projectFileName;

            if (FlatRedBall.IO.FileManager.IsRelative(mProjectFileName))
            {
                mProjectFileName = FlatRedBall.IO.FileManager.RelativeDirectory + mProjectFileName;
            }

            // First let's set the relative directory to the file manager's relative directory so we can load
            // the file normally...
            ToolsUtilities.FileManager.RelativeDirectory = FlatRedBall.IO.FileManager.RelativeDirectory;

            GumLoadResult result;

            ObjectFinder.Self.GumProjectSave = GumProjectSave.Load(mProjectFileName, out result);

#if DEBUG
            if (ObjectFinder.Self.GumProjectSave == null)
            {
                throw new Exception("Could not find Gum project at " + mProjectFileName);
            }

            if (!string.IsNullOrEmpty(result.ErrorMessage))
            {
                throw new Exception(result.ErrorMessage);
            }

            if (result.MissingFiles.Count != 0)
            {
                throw new Exception("Missing files starting with " + result.MissingFiles[0]);
            }
#endif

            // Now we can set the directory to Gum's root:
            ToolsUtilities.FileManager.RelativeDirectory = ToolsUtilities.FileManager.GetDirectory(mProjectFileName);

            // The Gum tool does a lot more init than this, but we're going to only do a subset
            //of initialization for performance
            // reasons:
            foreach (var item in ObjectFinder.Self.GumProjectSave.Screens)
            {
                // Only initialize using the default state
                if (item.DefaultState != null)
                {
                    item.Initialize(item.DefaultState);
                }
            }
            foreach (var item in ObjectFinder.Self.GumProjectSave.Components)
            {
                // Only initialize using the default state
                if (item.DefaultState != null)
                {
                    item.Initialize(item.DefaultState);
                }
            }
            foreach (var item in ObjectFinder.Self.GumProjectSave.StandardElements)
            {
                // Only initialize using the default state
                if (item.DefaultState != null)
                {
                    item.Initialize(item.DefaultState);
                }
                //for atlased colored rectangles
                if (item.Name == "ColoredRectangle")
                {
                    RenderingLibrary.Graphics.SolidRectangle.AtlasedTextureName = "..\\Graphics\\Misc\\ColoredRectangle.png";
                }
            }

            StandardElementsManager.Self.Initialize();
        }
示例#4
0
        static CollisionManager()
        {
            Self = new CollisionManager();

            FlatRedBallServices.AddManager(Self);
        }
示例#5
0
        public static void StaticInitialize(string projectFileName)
        {
            if (mManagers == null)
            {
                mManagers = new SystemManagers();
                mManagers.Initialize(FlatRedBallServices.GraphicsDevice);
                mManagers.Renderer.Camera.AbsoluteLeft = 0;
                mManagers.Renderer.Camera.AbsoluteTop  = 0;

                var viewport = mManagers.Renderer.GraphicsDevice.Viewport;
                viewport.Width  = FlatRedBall.Math.MathFunctions.RoundToInt(FlatRedBall.Camera.Main.DestinationRectangle.Width);
                viewport.Height = FlatRedBall.Math.MathFunctions.RoundToInt(FlatRedBall.Camera.Main.DestinationRectangle.Height);
                mManagers.Renderer.GraphicsDevice.Viewport = viewport;

                GraphicalUiElement.CanvasHeight = FlatRedBall.Camera.Main.OrthogonalHeight;
                GraphicalUiElement.CanvasWidth  = FlatRedBall.Camera.Main.OrthogonalWidth;


                // Need to do the zoom here in response to the FRB camera vs. the Gum camera
                mManagers.Renderer.Camera.Zoom = viewport.Height / (float)GraphicalUiElement.CanvasHeight;
                mManagers.Renderer.Camera.CameraCenterOnScreen = CameraCenterOnScreen.TopLeft;
                mManagers.Renderer.Camera.X = 0;
                mManagers.Renderer.Camera.Y = 0;

                SystemManagers.Default = mManagers;
                FlatRedBallServices.AddManager(RenderingLibrary.SystemManagers.Default);

                RenderingLibrary.Graphics.Text.RenderBoundaryDefault = false;
            }

            if (projectFileName == null)
            {
                throw new Exception("The GumIDB must be initialized with a valid (non-null) project file.");
            }

            string errors;

            mProjectFileName = projectFileName;

            if (FlatRedBall.IO.FileManager.IsRelative(mProjectFileName))
            {
                mProjectFileName = FlatRedBall.IO.FileManager.RelativeDirectory + mProjectFileName;
            }

            // First let's set the relative directory to the file manager's relative directory so we can load
            // the file normally...
            ToolsUtilities.FileManager.RelativeDirectory = FlatRedBall.IO.FileManager.RelativeDirectory;

            ObjectFinder.Self.GumProjectSave = GumProjectSave.Load(projectFileName, out errors);

#if DEBUG
            if (ObjectFinder.Self.GumProjectSave == null)
            {
                throw new Exception("Could not find Gum project at " + projectFileName);
            }
#endif

            // Now we can set the directory to Gum's root:
            ToolsUtilities.FileManager.RelativeDirectory = ToolsUtilities.FileManager.GetDirectory(mProjectFileName);

            // The Gum tool does a lot more init than this, but we're going to only do a subset
            //of initialization for performance
            // reasons:
            foreach (var item in ObjectFinder.Self.GumProjectSave.Screens)
            {
                // Only initialize using the default state
                if (item.DefaultState != null)
                {
                    item.Initialize(item.DefaultState);
                }
            }
            foreach (var item in ObjectFinder.Self.GumProjectSave.Components)
            {
                // Only initialize using the default state
                if (item.DefaultState != null)
                {
                    item.Initialize(item.DefaultState);
                }
            }
            foreach (var item in ObjectFinder.Self.GumProjectSave.StandardElements)
            {
                // Only initialize using the default state
                if (item.DefaultState != null)
                {
                    item.Initialize(item.DefaultState);
                }
            }

            StandardElementsManager.Self.Initialize();
        }