Exemplo n.º 1
0
        private string BeginDraw()
        {
            if (_deviceService == null)
            {
                return(Text + "\n\n" + GetType());
            }

            string deviceResetError = HandleDeviceReset();

            if (!string.IsNullOrEmpty(deviceResetError))
            {
                return(deviceResetError);
            }

            GLControl control = GLControl.FromHandle(_deviceService.GraphicsDevice.PresentationParameters.DeviceWindowHandle) as GLControl;

            if (control != null)
            {
                control.Context.MakeCurrent(WindowInfo);
                _deviceService.GraphicsDevice.PresentationParameters.BackBufferHeight = ClientSize.Height;
                _deviceService.GraphicsDevice.PresentationParameters.BackBufferWidth  = ClientSize.Width;
            }

            Viewport viewport = new Viewport();

            viewport.X = 0;
            viewport.Y = 0;

            viewport.Width  = ClientSize.Width;
            viewport.Height = ClientSize.Height;

            viewport.MinDepth = 0;
            viewport.MaxDepth = 1;


            Viewport viewport2 = new Viewport();

            viewport2.X = 0;
            viewport2.Y = 0;

            viewport2.Width  = 0;
            viewport2.Height = 0;

            viewport2.MinDepth = 0;
            viewport2.MaxDepth = 1;

            if (GraphicsDevice.Viewport.Equals(viewport) == false)
            {
                GraphicsDevice.Viewport = viewport;
                var zoom = _camera.Zoom;
                _camera = new Camera(viewport2);

                _camera.Zoom = zoom;

                ServiceLocator.Add(_camera);
            }


            return(null);
        }
Exemplo n.º 2
0
        public HotelTest()
        {
            if (ServiceLocator.Get <ConfigLoader>() == null)
            {
                ServiceLocator.Add <ConfigLoader>(new ConfigLoader(""));
            }

            rooms = new List <Room>();
            rooms.Add(new EmptyRoom(-1, new Point(-1, 0), new Point(1, 1)));
            (rooms[0] as EmptyRoom).Entrance = true;
            rooms.Add(new ElevatorShaft(0, new Point(0, 0)));
            rooms.Add(new ElevatorShaft(1, new Point(0, 1)));
            rooms.Add(new ElevatorShaft(2, new Point(0, 2)));
            rooms.Add(new Lobby(3, new Point(1, 0), new Point(1, 1)));
            rooms.Add(new Lobby(4, new Point(2, 0), new Point(1, 1)));
            rooms.Add(new Lobby(5, new Point(3, 0), new Point(1, 1)));
            rooms.Add(new Lobby(6, new Point(4, 0), new Point(1, 1)));
            rooms.Add(new Staircase(7, new Point(5, 0)));
            rooms.Add(new Staircase(8, new Point(5, 1)));
            rooms.Add(new Staircase(9, new Point(5, 2)));
            for (int i = 1; i < 5; i++)
            {
                for (int j = 1; j < 3; j++)
                {
                    rooms.Add(new GuestRoom(j * i + 9, new Point(i, j), new Point(1, 1), 1));
                }
            }

            HotelBuilder builder = new HotelBuilder();

            foreach (Room r in rooms)
            {
                builder.PlaceRoom(r);
            }
        }
Exemplo n.º 3
0
 public ElevatorTest()
 {
     if (ServiceLocator.Get <ConfigLoader>() == null)
     {
         ServiceLocator.Add <ConfigLoader>(new ConfigLoader(""));
     }
 }
Exemplo n.º 4
0
 public RoomUnitTests()
 {
     if (ServiceLocator.Get <ConfigLoader>() == null)
     {
         ServiceLocator.Add <ConfigLoader>(new ConfigLoader(""));
     }
 }
        public App()
        {
            // Make sure the linker doesn't remove the plugin
            var workaround = typeof(VideoView);

            ServiceLocator.Add <ICloudService, AzureCloudService>();
            MainPage = new NavigationPage(new Pages.VideoList());
        }
Exemplo n.º 6
0
        private void neueMissionToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            currentMission = new Mission();
            ServiceLocator.Add("CurrentMission", currentMission);
            mp.Add(currentMission);

            NavigationService.Navigate(new GeneralPage());
        }
Exemplo n.º 7
0
        private void okButton_Click(object sender, System.EventArgs e)
        {
            MissionPack      = new MissionPack(); //MissionPack.Load(Application.StartupPath + "\\MissionPacks\\" + missionNameTextBox.Text + ".mp");
            MissionPack.Name = missionNameTextBox.Text;

            ServiceLocator.Add("filename", Application.StartupPath + "\\MissionPacks\\" + missionNameTextBox.Text + ".mp");
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 8
0
        private void newMissionPackButton_Click(object sender, System.EventArgs e)
        {
            var nmp = new NewMissionPackDialog();

            if (nmp.ShowDialog() == DialogResult.OK)
            {
                ServiceLocator.Add("MissionPack", nmp.MissionPack);
            }
        }
Exemplo n.º 9
0
        public App(string loadParameter = null)
        {
            ServiceLocator.Add <ICloudService, AzureCloudService>();

            MainPage = new NavigationPage(new EntryPage())
            {
                BarBackgroundColor = Color.FromHex("#2196F3")
            };
        }
Exemplo n.º 10
0
 private void mpComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (mpComboBox.SelectedItem != null)
     {
         var item = (mpComboBox.SelectedItem as ComboboxItem);
         ServiceLocator.Add("MissionPack", item.Value);
         ServiceLocator.Add("filename", item.Filename);
     }
 }
Exemplo n.º 11
0
        private void missionAuswählenToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            var selectMission = new MissionSelector(mp);

            if (selectMission.ShowDialog() == DialogResult.OK)
            {
                currentMission = selectMission.Mission;
                ServiceLocator.Add("CurrentMission", currentMission);
            }
        }
Exemplo n.º 12
0
        private void ladenToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                mp = MissionPack.Load(openFileDialog1.FileName);

                ServiceLocator.Add("MissionPack", mp);
                ServiceLocator.Add("filename", openFileDialog1.FileName);
            }
        }
Exemplo n.º 13
0
        public FragEngineGame()
        {
            // TODO: figure out a way to change this to use the IGraphicsDeviceManager interface
            // FIXME: this is f****d. In DIRECTX versions of this code, we _must_ instantiate GraphicsDeviceManager
            // in the initialize, but in OPENGL versions we have to do it here (check the code in Game.cs)
            // it throws an exception if GraphicsDevice is null???? WHAT THE F**K!?!?!?
            Graphics = new GraphicsDeviceManager(this);

            Content.RootDirectory = "Content";

            DataDirectory = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "Data"));

            ClearColor = Color.White;

            ServiceLocator.Apply(Services);

            if (!ServiceLocator.Has <GraphicsDevice>())
            {
                ServiceLocator.Add(Graphics.GraphicsDevice);
            }

            if (!ServiceLocator.Has <Camera>())
            {
                ServiceLocator.Add(new Camera(Graphics.GraphicsDevice.Viewport));
            }

            if (!ServiceLocator.Has <IEntityService>())
            {
                ServiceLocator.Add <IEntityService>(new EntityService());
            }

            if (!ServiceLocator.Has <ICollisionService>())
            {
                ServiceLocator.Add <ICollisionService>(new CollisionService());
            }

#if !DEBUG
            Graphics.IsFullScreen              = true;
            Graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            Graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            Graphics.PreferMultiSampling       = false;
#endif

            // TODO: GGGGGGGGAAAAAAAAAAAAAAAAAHHHHHHHHH WE'RE IO BOUND IN A CTOR!!!!!!!!!!!!!!!!!! FFFFFFFFFFFFFUUUUUUUUUUUUUUUUUUUUUUU
            // ContentCacheManager must be loaded first, this will scan
            // every directory in the content project and load all of the
            // content into a cache
            ContentCacheManager.LoadContent(Content);

            // TODO: in DIRECTX versions we'll have to do this in initialize...
            // maybe move this code there now?
            ScreenManager = new ScreenManager(this);
            Components.Add(ScreenManager);
        }
Exemplo n.º 14
0
        public void AddTest()
        {
            const string targetString = "This is a test";

            IServiceLocator sp = new ServiceLocator();

            sp.Add(typeof(string), targetString);

            var result = sp.Resolve <string>();

            Assert.AreEqual(targetString, result);
        }
Exemplo n.º 15
0
        public App()
        {
            InitializeComponent();

            FlowListView.Init();
            //CloudService = new AzureCloudService();
            ServiceLocator.Add <ICloudService, AzureCloudService>();

            //LoadSomeData();
            SetMainPage();

            //MainPage = new NavigationPage(new Views.EntryPage());
        }
Exemplo n.º 16
0
        public void InvalidCastTest()
        {
            object          obj = new object();
            IServiceLocator sp  = new ServiceLocator();

            sp.Add(typeof(IComparable), obj);

            var result = sp.Resolve <string>();

            Assert.AreEqual(null, result);

            sp.Resolve <IComparable>();
        }
Exemplo n.º 17
0
        public void LoadLevel(string levelName)
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data\\" + levelName + ".json");

            CurrentLevel = Level.Load(new FileInfo(path));

            var players = CurrentLevel.Entities.Where(e => e is Player);

            _playerLayer.Entities.AddRange(players);

            _layers.InsertRange(0, CurrentLevel.MapLayers);

#if DEBUG
            _layers.Add(CurrentLevel.CollisionLayer);
#endif

            // replace the collision service with one setup for this level
            var collisionMap     = new CollisionMap(CurrentLevel);
            var collisionService = new CollisionService(collisionMap);

            ServiceLocator.Add <ICollisionService>(collisionService);
        }
Exemplo n.º 18
0
        public PersonTest()
        {
            if (ServiceLocator.Get <ConfigLoader>() == null)
            {
                ServiceLocator.Add <ConfigLoader>(new ConfigLoader(""));
            }

            if (rooms != null)
            {
                return;
            }

            rooms = new List <Room>();
            rooms.Add(new ElevatorShaft(0, new Point(0, 0)));
            rooms.Add(new ElevatorShaft(1, new Point(0, 1)));
            rooms.Add(new ElevatorShaft(2, new Point(0, 2)));
            rooms.Add(new Lobby(3, new Point(1, 0), new Point(1, 1)));
            rooms.Add(new Lobby(4, new Point(2, 0), new Point(1, 1)));
            rooms.Add(new Lobby(5, new Point(3, 0), new Point(1, 1)));
            rooms.Add(new Lobby(6, new Point(4, 0), new Point(1, 1)));
            rooms.Add(new Staircase(7, new Point(5, 0)));
            rooms.Add(new Staircase(8, new Point(5, 1)));
            rooms.Add(new Staircase(9, new Point(5, 2)));
            for (int i = 1; i < 5; i++)
            {
                for (int j = 1; j < 3; j++)
                {
                    rooms.Add(new GuestRoom(j * (i + 1) + 9, new Point(i, j), new Point(1, 1), 1));
                }
            }

            HotelBuilder builder = new HotelBuilder();

            foreach (Room r in rooms)
            {
                builder.PlaceRoom(r);
            }
        }
Exemplo n.º 19
0
        public void BuildHotel()
        {
            ServiceLocator.Remove <ConfigLoader>();

            // This test requires a config file to work.
            // Make sure there is a config file present!
            ServiceLocator.Add <ConfigLoader>(new ConfigLoader(@"C:\Users\Thom\Source\Repos\ThemeHotelHHS\Hotel Simulator Debug\Config.cfg"));
            HotelBuilder hb = new HotelBuilder();

            // Register components to the roomfactory
            hb.RoomFactory.RegisterComponent("Room", new GuestRoomFactoryComponent());
            hb.RoomFactory.RegisterComponent("Cinema", new CinemaFactoryComponent());
            hb.RoomFactory.RegisterComponent("Restaurant", new CafeFactoryComponent());
            hb.RoomFactory.RegisterComponent("Empty", new EmptyRoomFactoryComponent());
            hb.RoomFactory.RegisterComponent("Lobby", new LobbyFactoryComponent());
            hb.RoomFactory.RegisterComponent("ElevatorShaft", new ElevatorShaftFactoryComponent());
            hb.RoomFactory.RegisterComponent("Staircase", new StaircaseFactoryComponent());
            hb.RoomFactory.RegisterComponent("Fitness", new FitnessFactoryComponent());
            hb.RoomFactory.RegisterComponent("Pool", new PoolFactoryComponent());

            List <Room> hotel = hb.BuildHotel();

            Assert.IsNotNull(hotel);
        }
Exemplo n.º 20
0
        public MissionPackSelector()
        {
            InitializeComponent();

            if (!Directory.Exists(Application.StartupPath + "\\MissionPacks"))
            {
                Directory.CreateDirectory(Application.StartupPath + "\\MissionPacks");
            }

            var sg = (SavedGame)ServiceLocator.Add("SavedGame", SavedGame.Load());

            //System.Globalization.CultureInfo.CurrentUICulture = new System.Globalization.CultureInfo(sg.Locale);
            ServiceLocator.Subscribe("LocaleChanged", _ =>
            {
                Title             = ServiceLocator._("Select Mission");
                okButton.Text     = ServiceLocator._("OK");
                cancelButton.Text = ServiceLocator._("Cancel");
            });

            ServiceLocator.LoadLocale();

            foreach (var m in Directory.GetFiles(Application.StartupPath + "\\MissionPacks", "*.mp"))
            {
                var mp   = MissionPack.Load(m);
                var item = new ComboboxItem();
                item.Text  = mp.Name;
                item.Value = mp;

                mpComboBox.Items.Add(item);
            }

            if (mpComboBox.Items.Count < 0)
            {
                mpComboBox.SelectedIndex = 0;
            }
        }
Exemplo n.º 21
0
        protected override void OnCreateControl()
        {
            if (!DesignMode)
            {
                _deviceService = GraphicsDeviceService.AddRef(Handle, ClientSize.Width, ClientSize.Height);

                ServiceLocator.Add <IGraphicsDeviceService>(_deviceService);
                ServiceLocator.Add(_deviceService.GraphicsDevice);
                ServiceLocator.Add <IEntityService>(new EntityService());
                ServiceLocator.Add <ICollisionService>(new CollisionService());

                _camera = new Camera(_deviceService.GraphicsDevice.Viewport);

                if (!ServiceLocator.Has <Camera>())
                {
                    ServiceLocator.Add(_camera);
                }

                if (ControlInitializing != null)
                {
                    ControlInitializing(this, EventArgs.Empty);
                }

                // Start the animation timer.
                _timer = Stopwatch.StartNew();

                Initialize();

                if (ControlInitialized != null)
                {
                    ControlInitialized(this, EventArgs.Empty);
                }

                Application.Idle += (o, args) => Invalidate(true);
            }
        }
Exemplo n.º 22
0
 private void SetupServiceLocator()
 {
     ServiceLocator.Add <ICloudService, AzureCloudService>();
 }
Exemplo n.º 23
0
 private static void InitializeServiceLocator()
 {
     ServiceLocator.Add <IAlgorithmService>(AlgorithmService.Instance);
     ServiceLocator.Add <ICoinService>(CoinService.Instance);
 }
Exemplo n.º 24
0
 private void mpComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     ServiceLocator.Add("MissionPack", (mpComboBox.SelectedItem as ComboboxItem).Value);
 }
Exemplo n.º 25
0
        private void mpComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            Mission = (mpComboBox.SelectedItem as ComboboxItem).Value as Mission;

            ServiceLocator.Add("CurrentMission", Mission);
        }
Exemplo n.º 26
0
        public void HandleConsole(ShellControl shell, Command cmd)
        {
            switch (cmd.Name)
            {
            case "help":
                Shell.WriteLine("Here are some Commands");
                foreach (var c in ConsolePage.Tools)
                {
                    var spl = c.HelpText.Split('|');
                    foreach (var ht in spl)
                    {
                        Shell.WriteLine(ht);
                    }
                }

                break;

            case "save":
                var sg = ServiceLocator.Get <SavedGame>("SavedGame");
                sg.Save();

                Shell.WriteLine("Successfully saved");

                break;

            case "load":
                var sg2 = ServiceLocator.Add("SavedGame", SavedGame.Load());
                ServiceLocator.CallEvent("Loaded", sg2);

                Shell.WriteLine("Successfully loaded");

                break;

            case "echo":
                Shell.WriteLine(cmd.Args[0]);

                break;

            case "cls":
                Shell.Clear();

                break;

            case "shutdown":
                Application.Exit();

                break;

            case "info":
                Shell.WriteLine(ServiceLocator._("Name:") + " " + ServiceLocator.Get <SavedGame>("SavedGame").Computer.Name);
                Shell.WriteLine(ServiceLocator._("Language:") + " " + ServiceLocator.Get <SavedGame>("SavedGame").Locale);
                break;

            case "settings":
                switch (cmd.Args[0])
                {
                case "language":
                    var sg3 = ServiceLocator.Get <SavedGame>("SavedGame");

                    sg3.Locale = cmd.Args[1];
                    CultureInfo.CurrentUICulture = new CultureInfo(sg3.Locale);

                    ServiceLocator.LoadLocale();


                    break;

                default:
                    break;
                }

                break;
            }
        }
Exemplo n.º 27
0
 public App()
 {
     ServiceLocator.Add <ICloudService, AzureCloudService>();
     MainPage = new NavigationPage(new Pages.EntryPage());
 }
Exemplo n.º 28
0
 // Adds game-specific global bindings.
 private static void addGlobalBindings(ServiceLocator serviceLocator)
 {
     serviceLocator.Add <ResourceManager>();
     serviceLocator.Add <Config>();
     serviceLocator.Add <GameSessionData>();
 }