Ejemplo n.º 1
0
        /// <summary>
        /// Increase the number of loaded bullets, decrease BulletInventory. Execute FullyLoaded event.
        /// </summary>
        public override bool LoadMagazine()
        {
            if (BulletInventory > 0 && LoadedBullets < MagazineSize)
            {
                LoadedBullets = 0;

                var addition = BulletInventory;
                if (addition > MagazineSize)
                {
                    addition = MagazineSize;
                }

                BulletInventory -= addition;
                LoadedBullets   += addition;

                for (int i = 0; i < Listeners.Length; i++)
                {
                    Listeners[i].OnFullyLoaded();
                }

                if (FullyLoaded != null)
                {
                    FullyLoaded.Invoke();
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Increase LoadedBullets, decrease BulletInventory. Execute related events (may include FullyLoaded).
        /// </summary
        public override bool LoadBullet()
        {
            if (BulletInventory > 0 && LoadedBullets < MagazineSize)
            {
                LoadedBullets++;

                for (int i = 0; i < Listeners.Length; i++)
                {
                    Listeners[i].OnBulletLoad();
                }

                if (BulletLoaded != null)
                {
                    BulletLoaded.Invoke();
                }

                if (LoadedBullets >= MagazineSize)
                {
                    for (int i = 0; i < Listeners.Length; i++)
                    {
                        Listeners[i].OnFullyLoaded();
                    }

                    if (FullyLoaded != null)
                    {
                        FullyLoaded.Invoke();
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        private IEnumerable <IdleStatus> finishInitialization()
        {
            splashScreen.updateStatus(10, "Loading Solution");
            yield return(IdleStatus.Ok);

            //Load the config file and set the resource root up.
            VirtualFileSystem.Instance.addArchive(solution.ResourceRoot);

            resourceController = new ResourceController(this);

            solution.loadExternalFiles(this);

            MyGUIPlugin.ResourceManager.Instance.load("Anomaly.Resources.AnomalyImagesets.xml");

            //Initialize controllers
            instanceBuilder = new InstanceBuilder();
            sceneController.initialize(this);
            sceneController.OnSceneLoaded    += sceneController_OnSceneLoaded;
            sceneController.OnSceneUnloading += sceneController_OnSceneUnloading;
            simObjectController = new SimObjectController(this);

            fixedUpdate = new FullSpeedUpdateListener(sceneController);
            mainTimer.addUpdateListener(fixedUpdate);

            splashScreen.updateStatus(60, "Creating GUI");
            yield return(IdleStatus.Ok);

            propertiesEditor = new PropertiesEditor("Properties", "Anomaly.GUI.Properties", false);
            guiManager.addManagedDialog(propertiesEditor);

            interfaceRenderer = new EditInterfaceRendererController(pluginManager.RendererPlugin, mainTimer, sceneController, propertiesEditor);

            solutionWindow = new SolutionWindow();
            guiManager.addManagedDialog(solutionWindow);

            mainObjectEditor = new PropertiesEditor("Object Editor", "Anomaly.GUI.ObjectEditor", true);
            mainObjectEditor.AllowedDockLocations = DockLocation.Floating;
            mainObjectEditor.CurrentDockLocation  = DockLocation.Floating;
            guiManager.addManagedDialog(mainObjectEditor);

            solutionController = new SolutionController(solution, solutionWindow, this, propertiesEditor);

            //Initialize the windows
            propertiesEditor.AutoExpand = true;

            //Create GUI
            consoleWindow = new LogWindow();
            guiManager.addManagedDialog(consoleWindow);
            Log.Default.addLogListener(consoleWindow);

            debugVisualizer = new DebugVisualizer(pluginManager, sceneController);
            guiManager.addManagedDialog(debugVisualizer);


            if (File.Exists(AnomalyConfig.WindowsFile))
            {
                ConfigFile configFile = new ConfigFile(AnomalyConfig.WindowsFile);
                configFile.loadConfigFile();
                guiManager.loadSavedUI(configFile, new Version("1.0.0.0"));

                //Show Windows Default
                solutionWindow.Visible   = true;
                propertiesEditor.Visible = true;
                consoleWindow.Visible    = true;
                debugVisualizer.Visible  = true;
            }
            else
            {
                //Show Windows Default
                solutionWindow.Visible = true;
                propertiesEditor.showRelativeTo(solutionWindow, WindowAlignment.Right);
                consoleWindow.Visible   = true;
                debugVisualizer.Visible = true;
            }

            yield return(IdleStatus.Ok);

            splashScreen.updateStatus(80, "Building Scene");

            buildScene();
            yield return(IdleStatus.Ok);

            splashScreen.updateStatus(100, "Loaded");

            splashScreen.hide();
            yield return(IdleStatus.Ok);

            if (FullyLoaded != null)
            {
                FullyLoaded.Invoke(this);
            }
        }