Пример #1
0
        /// <summary>
        /// Sets up the grid in terms of decoding the integer array into items
        /// and sets up the canvas.
        /// </summary>
        /// <param name="gameCanvas">The canvas reference is needed</param>
        /// <param name="enemyType"></param>
        public void SetupGrid(ref Canvas gameCanvas, ref Canvas exitCanvas, ProtagonistType protagonistType, EnemyType enemyType)
        {
            //setup protagonist types etc so that we know what pages to go etc
            this.protagonistType = protagonistType;
            this.enemyType       = enemyType;
            DecodeGridStartLocations(protagonistType, enemyType);
            //Add grid items
            for (int y = 0; y < GridStartLocations.GetLength(0); y++)
            {
                for (int x = 0; x < GridStartLocations.GetLength(1); x++)
                {
                    gameCanvas.Children.Add(_gridManager.GridItems[y, x]);
                    MoveItemToPlace(_gridManager.GridItems[y, x], _gridManager.GridItems[y, x].Position);
                }
            }

            //Add character
            for (int i = 0; i < 2; i++)
            {
                gameCanvas.Children.Add(_gridManager.CharactersViews[i]);
                MoveItemToPlace(_gridManager.CharactersViews[i], _gridManager.Characters[i].Position);
                //Add the characters weight if specified in level file (used in client/server to communicate
                //the weights to the clients)
                if (characterWeights != null && characterWeights.Length == 2)
                {
                    GameGridManager.Instance.Characters[i].Weight = characterWeights[i];
                }
            }

            //Add exit rectangle
            exitCanvas.Children.Add(ExitRectanglePlacement());
        }
Пример #2
0
 /// <summary>
 /// x
 /// </summary>
 /// <returns>The yLength of the GridStartLocations array</returns>
 private int xLength()
 {
     return(GridStartLocations.GetLength(1));
 }