Ejemplo n.º 1
0
        private void Start()
        {
            var initial = new VisualizerInitial();
            var state   = new GameState();

            var board = new IO.Models.Board()
            {
                Height = 1,
                Width  = 1
            };

            board.Grid.Add(new Tile()
            {
                GroundSprite = "mm26_tiles/dirt1.png",
                TileType     = Tile.Types.TileType.Blank,
            });

            state.BoardNames["pvp"] = board;

            initial.State = state;
            _data.Initial = initial;

            _lifeCycle.FetchData.Invoke();
            _lifeCycle.DataFetched.Invoke();

            StartCoroutine(this.Simulate(board));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Helper functions for converting a board in a test state
        /// to a board in the game state
        /// </summary>
        /// <param name="state"></param>
        /// <param name="testState"></param>
        private void ConvertBoard(GameState state, TestGameState testState)
        {
            var board = new IO.Models.Board();

            board.Height = testState.Board.Height;
            board.Width  = testState.Board.Width;

            foreach (var tile in testState.Board.Grid)
            {
                var ptile = new Tile()
                {
                    TileType     = tile.TileType,
                    GroundSprite = tile.GroundSprite,
                    AboveSprite  = tile.AboveSprite,
                };

                if (tile.HasItems)
                {
                    ptile.Items.Add(new Item());
                }

                board.Grid.Add(ptile);
            }

            state.BoardNames.Add(testState.Board.Name, board);
        }
        private static void ProcessTileChanges(
            SceneConfiguration configuration,
            GameState gameState,
            GameChange gameChange,
            TasksBatch batch)
        {
            if (gameChange == null || gameState == null)
            {
                return;
            }

            if (!gameState.BoardNames.ContainsKey(configuration.BoardName))
            {
                return;
            }

            IO.Models.Board board = gameState.BoardNames[configuration.BoardName];

            foreach (var change in gameChange.TileItemChanges)
            {
                if (change.BoardId != configuration.BoardName)
                {
                    continue;
                }

                Tile tile = board.Grid[change.X * board.Height + change.Y];
                batch.Add(
                    new UpdateTileItemTask(
                        new Vector2Int(change.X, change.Y),
                        tile.Items.Count > 0));
            }
        }
        private VisualizerTurn GetTurn(string playerBoard)
        {
            var state = new GameState();

            var board = new IO.Models.Board()
            {
                Width  = 1,
                Height = 1
            };

            var item = new Tile();

            item.Items.Add(new Item());

            board.Grid.Add(item);

            state.BoardNames[playerBoard] = board;

            var change = new GameChange();

            change.TileItemChanges.Add(new Position()
            {
                X       = 0,
                Y       = 0,
                BoardId = playerBoard
            });

            var turn = new VisualizerTurn()
            {
                State  = state,
                Change = change
            };

            return(turn);
        }
Ejemplo n.º 5
0
        private IEnumerator Simulate(IO.Models.Board board)
        {
            yield return(new WaitForSecondsRealtime(2.0f));

            var turn1State = new GameState();

            turn1State.BoardNames["player"] = board;

            _data.Turns.Enqueue(new VisualizerTurn()
            {
                State = turn1State
            });

            _data.Turns.Enqueue(new VisualizerTurn()
            {
                State = turn1State
            });
        }