Beispiel #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> ());
        }
Beispiel #2
0
        public void GivenMatchTilesDataSetToNotBeNull_WhenExecute_ThenMatchTilesDataIsNullAsItHasBeenModified()
        {
            MatchTilesData matchTilesData = ScriptableObject.CreateInstance <MatchTilesData> ();

            matchTileGridModel.matchTilesData = matchTilesData;

            Assert.NotNull(matchTileGridModel.matchTilesData);

            loadMatchTileGridDataCommand.Execute();

            Assert.Null(matchTileGridModel.matchTilesData);
        }
Beispiel #3
0
        public void GivenMatchTilesDataLoadedTwoByTwoWithNoMatchTokenData_WhenExecute_ThenCreateFourRandomMatchTile()
        {
            MatchTilesData layout = ScriptableObject.CreateInstance <MatchTilesData> ();

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

            matchTileGridModel.matchTilesData.Returns(layout);
            matchTileGridModel.gridSize = new Vector2(2, 2);

            createMatchTileGridCommand.Execute();

            matchTileFactory.Received(4).CreateRandomMatchTile(Arg.Any <Vector2> ());
        }
Beispiel #4
0
        public void SetUp()
        {
            matchTileGridModel            = Substitute.For <IMatchTileGridModel>();
            matchTileGridModel.gridHolder = new GameObject();

            eventDispatcher = Substitute.For <IEventDispatcher> ();

            createMatchTileGridHolderCommand = new CreateMatchTileGridHolderCommand();
            createMatchTileGridHolderCommand.matchTileGridModel = matchTileGridModel;
            createMatchTileGridHolderCommand.eventDispatcher    = eventDispatcher;

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

            matchTileGridModel.matchTilesData.Returns(matchTilesData);

            eventDispatcher.CleanAndDestroy();
        }
Beispiel #5
0
        private void CreateGameHolder()
        {
            MatchTilesData layout = matchTileGridModel.matchTilesData;

            GameObject gameHolder = new GameObject();

            gameHolder.name             = matchTileGridModel.gameHolderName;
            gameHolder.transform.parent = matchTileGridModel.gridHolder.transform;

            matchTileGridModel.gridSize   = layout.gridSize;
            matchTileGridModel.gridParent = gameHolder;

            float xMax = matchTileGridModel.gridSize.x;
            float xpos = -((xMax - 1) / 2f);
            float ypos = matchTileGridModel.gridYPos;

            gameHolder.transform.localPosition = new Vector3(xpos, ypos, 0);
        }
Beispiel #6
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();
        }
Beispiel #7
0
        public void Execute()
        {
            MatchTilesData matchTilesData = Resources.Load(matchTileGridModel.matchTileLayout) as MatchTilesData;

            matchTileGridModel.matchTilesData = matchTilesData;
        }