Exemplo n.º 1
0
        private RessourcesManager()
        {
            _gameboard = Gameboard.Instance;
            _ressourcesProduction = RessourcesProduction.Instance;
            _researchHandler = ResearchHandler.Instance;

            // Default time = 1 min
            _timeScale = 60;
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            MIns = this;
            InitializeComponent();

            // Set the music to play
            _musicPlayer = MusicPlayer.Instance;
            _musicPlayer.Play("Resources/Audio/main_theme.mp3");

            // Set the gameboard Instance
            _gameboard = Gameboard.Instance;
            ResetMap.Instance.VerifyMap();

            // Set the user instance
            label_player_name.Content = User.User.Instance.Name;

            // Dispatcher pour programme Idle
            ComponentDispatcher.ThreadIdle += IdleUiThread.Instance.IdleThreadWork;

            // Insert images in UI
            UIImagesInit.Instance.InitImages();

            // Insertion des elements dans la carte
            GameboardInit.Instance.InsertMap();

            // Level indicators
            _levelIndicatorVisibility = LevelIndicatorVisibility.Instance;

            // Hide building menu
            _buildingMenuVisibility = BuildingMenuVisibility.Instance;
            _buildingMenuVisibility.HideBuildingMenu();

            // Hide Building Details menu
            _buildingDetailsVisibility = BuildingDetailsVisibility.Instance;
            _buildingDetailsVisibility.HideBuildingDetails();

            // Hide Dungeon page
            _dungeonManager = DungeonManager.Instance;
            _dungeonManager.CloseDungeon();

            // Initialise Research
            _researchHandler = ResearchHandler.Instance;
            _researchHandler.Initialise();

            // Disable Unit recruitment
            UnitRecruitmentVisibility.Instance.DisableAllUnits();

            // load game
            if (!SaveGame.Instance.Load())
            {
                // If no game is found, load a new one
                ResetMap.Instance.InitialiseNewGame();

                // Set default ressources
                Ressources.Instance.Initialise();
                Ressources.Instance.SetDefault();

                // Count Units
                UnitManager.Instance.UpdateUnitCount();
            }

            // Start Error dispatching
            ErrorManager.Instance.StartErrorDispatch();

            // First update of ressources
            RessourcesBuildingCheck.Instance.cheakAllNeighbourRessources();

            // Check Building count with townhall
            BuildingCount.Instance.CountBuildings();

            // Update Storage
            Storage.Instance.UpdateStorageCapacity();

            // Start Ressource management
            RessourcesManager.Instance.StartRessourcesManager();
            RessourcesManager.Instance.TimeScale = LordOfUltima.Properties.Settings.Default.UpdateTime;

            // Settings initialisation
            SetSettings.Instance.Set();

            // Hide research
            ResearchPageVisibility.HideResearchPage();

            // Hide recruitment
            RecruitmentPageVisibility.HideRecruitmentPage();

            // Chatbox state
            ChatboxVisibility.Instance.HandleChatboxVisibility();

            // Start Recruitment Manager
            _recruitmentManager = RecruitmentManager.Instance;

            // Update recruitment window visibility
            UnitRecruitmentVisibility.Instance.UpdateVisibility();

            // Hide Dungeon
            DungeonVisibility.Instance.HideDungeon();

            // Start Chat thread
            _chatEvents = ChatEvents.Instance;
            /*BackgroundWorker bw = new BackgroundWorker();
            bw.DoWork += _chatEvents.UpdateChat;
            bw.RunWorkerAsync();*/
        }