Пример #1
0
        protected override void AddPrefabItems(MyTreeViewItem parentItem, MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum, BuildTypesEnum buildType, CategoryTypesEnum categoryType)
        {
            MyMwcLog.WriteLine("GAME AddPrefabItems - START");

            Vector2 itemSize = MyGuiConstants.CHECKBOX_SIZE * 3;

            foreach (MyMwcObjectBuilderTypeEnum enumValue in MyGuiPrefabHelpers.MyMwcPrefabTypesEnumValues)
            {
                foreach (int prefabId in MyMwcObjectBuilder_Base.GetObjectBuilderIDs(enumValue))
                {
                    MyPrefabConfiguration config             = MyPrefabConstants.GetPrefabConfiguration(enumValue, prefabId);
                    MyGuiPrefabHelper     prefabModuleHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(enumValue, prefabId) as MyGuiPrefabHelper;

                    if (config == null)
                    {
                        continue;
                    }

                    if (config.FactionSpecific.HasValue && config.FactionSpecific.Value != appearanceTextureEnum)
                    {
                        continue;
                    }

                    if (config.BuildType == buildType && config.CategoryType == categoryType && config.EnabledInEditor)
                    {
                        MyMwcObjectBuilder_PrefabBase prefabObjectBuilder   = MyPrefabFactory.GetInstance().CreatePrefabObjectBuilder(enumValue, prefabId, appearanceTextureEnum);
                        MyBuildingSpecification       buildingSpecification = MyBuildingSpecifications.GetBuildingSpecification(prefabObjectBuilder);
                        MyTexture2D previewTexture = MyGuiManager.GetPrefabPreviewTexture(enumValue, prefabId, appearanceTextureEnum);
                        AddTreeViewItem(parentItem, prefabModuleHelper.Description, previewTexture, itemSize, MyGuiManager.GetBlankTexture(), MyGuiManager.GetBlankTexture(), MyGuiConstants.CHECKBOX_SIZE, prefabObjectBuilder, buildingSpecification);
                    }
                }
            }

            MyMwcLog.WriteLine("GAME AddPrefabItems - END");
        }
Пример #2
0
        /// <summary>
        /// Returns new instance of object to build with specified amount
        /// </summary>
        /// <param name="objectBuilder">Object builder</param>
        /// <param name="amount">Amount</param>
        /// <returns>New instance of object to build</returns>
        public static MyObjectToBuild CreateFromObjectBuilder(MyMwcObjectBuilder_Base objectBuilder, float amount)
        {
            MyBuildingSpecification buildingSpecification = MyBuildingSpecifications.GetBuildingSpecification(objectBuilder);
            MyObjectToBuild         objectToBuild         = new MyObjectToBuild(objectBuilder, buildingSpecification, amount);

            return(objectToBuild);
        }
Пример #3
0
        private void AddSmallShipWeaponsItems(MyTreeViewItem parentItem)
        {
            Vector2 itemSize = MyGuiManager.GetNormalizedSizeFromScreenSize(new Vector2(64, 64));

            foreach (MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_Weapon_TypesEnumValues)
            {
                MyMwcObjectBuilder_SmallShip_Weapon weaponObjectBuilder   = new MyMwcObjectBuilder_SmallShip_Weapon(enumValue);
                MyBuildingSpecification             buildingSpecification = MyBuildingSpecifications.GetBuildingSpecification(weaponObjectBuilder);
                MyGuiSmallShipHelperWeapon          smallShipWeaponHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip_Weapon, (int)enumValue) as MyGuiSmallShipHelperWeapon;
                AddTreeViewItem(parentItem, smallShipWeaponHelper.Description, smallShipWeaponHelper.Icon, itemSize, MyGuiManager.GetBlankTexture(), MyGuiManager.GetBlankTexture(), MyGuiConstants.CHECKBOX_SIZE, weaponObjectBuilder, buildingSpecification);
            }
        }
Пример #4
0
        public MyMinerGame(ServiceContainer services)
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMinerGame()::constructor");
            MyMwcLog.WriteLine("MyMinerGame.Constructor() - START");
            MyMwcLog.IncreaseIndent();

            Services = services;

            // we want check objectbuilders, prefab's configurations, gameplay constants and building specifications
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Checks");
            MyMwcObjectBuilder_Base.Check();
            MyPrefabConstants.Check();
            MyGameplayConstants.Check();
            MyBuildingSpecifications.Check();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("Preallocate");

            Preallocate();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("IsAdmin");
            WindowsIdentity  windowsIdentity  = WindowsIdentity.GetCurrent();
            WindowsPrincipal windowsPrincipal = new WindowsPrincipal(windowsIdentity);
            bool             IsAdmin          = windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);

            MyMwcLog.WriteLine("IsAdmin " + IsAdmin.ToString());
            MyMwcLog.WriteLine("Game dir: " + GameDir);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyCustomGraphicsDeviceManagerDX");
#if !DEBUG
            try
            {
#endif

            this.Exiting      += MyMinerGame_Exiting;
            this.Activated    += MyMinerGame_OnActivated;
            this.Deactivated  += MyMinerGame_OnDeactivated;
            this.m_InvokeQueue = new ConcurrentQueue <Tuple <ManualResetEvent, Action> >();
            this.m_MainThread  = Thread.CurrentThread;

            GraphicsDeviceManager = new MyCustomGraphicsDeviceManagerDX(this);

            m_isGraphicsSupported = GraphicsDeviceManager.ChangeProfileSupport();
            m_isGraphicsSupported = true;

            if (m_isGraphicsSupported)
            {
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.HookEventHandlers");

                MyVideoModeManager.HookEventHandlers();

                //Content = new MyCustomContentManager(Services, ContentDir);
                //  Content = new SharpDX.Toolkit.Content.ContentManager(Services);

                RootDirectory      = Path.Combine(GameDir, "Content");
                RootDirectoryDebug = Path.GetFullPath(System.IO.Path.Combine(GameDir, "..\\..\\..\\Content"));

                RootDirectoryEffects = RootDirectory;

                Static = this;

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("InitNumberOfCores");
                InitNumberOfCores();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.LogApplicationInformation");


                MyVideoModeManager.LogApplicationInformation();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.LogInformation");

                MyVideoModeManager.LogInformation();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.LogEnvironmentInformation");

                MyVideoModeManager.LogEnvironmentInformation();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyPlugins.LoadContent");

                MyPlugins.LoadContent();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyConfig.Load");

                MyConfig.Load();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyMath.Init");

                MyMath.Init();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyTextsWrapper.Init");

                MyTextsWrapper.Init();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyDialoguesWrapper.Init");

                MyDialoguesWrapper.Init();

                //  If I don't set TargetElapsedTime, default value will be used, which is 60 times per second, and it will be more precise than if I calculate
                //  it like below - SO I MUST BE DOING THE WRONG CALCULATION !!!
                //  We use fixed timestep. Update() is called at this precise timesteps. If Update or Draw takes more time, Update will be called more time. Draw is called only after Update.
#if RENDER_PROFILING || GPU_PROFILING
                IsFixedTimeStep = false;
                MyMinerGame.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = false;
#else
                IsFixedTimeStep = MyFakes.FIXED_TIMESTEP;
#endif
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("InitMultithreading");

            InitMultithreading();
#if !DEBUG
        }

        catch (Exception ex)
        {
            //  We are catching exceptions in constructor, because if error occures here, it app will start unloading
            //  so we skip to UnloadContent and there we will get another exception (because app wasn't really loaded when unload started)
            //  So we want original exception in log.
            MyMwcLog.WriteLine(ex);
            throw;
        }
#endif

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyMinerGame.Constructor() - END");
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }