Exemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            Global.Content = Content;

            // Allow mouse
            //IsMouseVisible = true;
            cursor = CustomCusor.GetInstance();

            // Initialize map
            gridMap = WordGrid.GetInstance();
            //gridMap.Load(Content.Load<GridData>(Utils.GetMapFileName(Consts.DEFALT_MAP_NAME)));

            // Initialize dictionary
            dictionary = TrieDictionary.GetInstance();
            dictionary.Load(Content.Load<string[]>(Utils.GetDictionaryFileName(Consts.DEFAULT_DICTIONARY_NAME)));

            // Initialize logo panel
            logoPanel = LogoPanel.GetInstance();

            // Initialize menu
            menuContainer = MenuContainer.GetInstance();

            // Initialize background
            background = new Sprite2D(0, 0, Utils.LoadTextures(Utils.GetImageFileName("Background")));

            // Initialize notification
            notification = GameNotification.GetInstance();

            // Initialize controller
            mouseController = MouseController.GetInstance();
            keyboardController = KeyboardController.GetInstance();

            // Initialize button
            backButton = new TileButton(25, 620, Utils.GetImageFileName("Back"));
            soundButton = new TileButton(70, 620, Utils.GetImageFileName("Sound"));

            // Load sound effects
            Global.clickSound = Content.Load<SoundEffect>(@"Sound\click");
            Global.achieveSound = Content.Load<SoundEffect>(@"Sound\achieve");
            Global.themeSong = Content.Load<Song>(@"Sound\theme");

            Global.UpdatePhase(Phase.MENU_LOADING);
        }
Exemplo n.º 2
0
        private void Travel(Tuple<int, int> index, TrieDictionary.TrieNode node)
        {
            if (node == null)
                return;

            correctedWord.Push(index);

            if (node.Word.Length > 0)
                correctedWords.Enqueue(new Queue<Tuple<int, int>>(correctedWord.ToList()));

            for (int k = 0; k < 4; k++)
            {
                Tuple<int, int> adjacentIndex = new Tuple<int, int>(index.Item1 + delta1[k], index.Item2 + delta2[k]);
                if (IsInside(adjacentIndex) && Char.IsLetter(grid[adjacentIndex.Item1, adjacentIndex.Item2]))
                    Travel(adjacentIndex, node.ChildAt(grid[adjacentIndex.Item1, adjacentIndex.Item2]));
            }

            correctedWord.Pop();
        }
Exemplo n.º 3
0
 private WordGrid()
 {
     dictionary = TrieDictionary.GetInstance();
 }
Exemplo n.º 4
0
 public static TrieDictionary GetInstance()
 {
     if (instance == null)
         instance = new TrieDictionary();
     return instance;
 }