Esempio n. 1
0
        public void GivenMatchTilesDataLoadedWithExistingNullMatchTokenData_WhenExecute_ThenCreateFourRandomMatchTile()
        {
            MatchTileType type = MatchTileType.Null;

            GameObject gameObject = new GameObject();

            gameObject.name = type.ToString();

            MatchTileData data = new MatchTileData();

            data.position   = Vector2.zero;
            data.gameObject = gameObject;

            List <MatchTileData> matchTilesData = new List <MatchTileData> ();

            matchTilesData.Add(data);

            MatchTilesData layout = ScriptableObject.CreateInstance <MatchTilesData> ();

            layout.matchTilesData = matchTilesData;

            matchTileGridModel.matchTilesData.Returns(layout);
            matchTileGridModel.GetMatchTileType(gameObject.name).Returns(type);
            matchTileGridModel.gridSize = new Vector2(2, 2);

            createMatchTileGridCommand.Execute();

            matchTileFactory.Received(4).CreateRandomMatchTile(Arg.Any <Vector2> ());
        }
Esempio n. 2
0
        private void CreateGrid()
        {
            MatchTilesData layout = matchTileGridModel.matchTilesData;

            float yMax = matchTileGridModel.gridSize.y;
            float xMax = matchTileGridModel.gridSize.x;

            for (int y = 0; y < yMax; y++)
            {
                for (int x = 0; x < xMax; x++)
                {
                    Vector2 position = new Vector2(x, y);

                    if (layout.matchTiles.ContainsKey(position))
                    {
                        MatchTileData data = layout.matchTiles [position];
                        MatchTileType type = matchTileGridModel.GetMatchTileType(data.gameObject.name);

                        if (type != MatchTileType.Null)
                        {
                            matchTileFactory.CreateMatchTile(type, position);
                        }
                        else
                        {
                            matchTileFactory.CreateRandomMatchTile(position);
                        }
                    }
                    else
                    {
                        matchTileFactory.CreateRandomMatchTile(position);
                    }
                }
            }

            GridCreationComplete();
        }