コード例 #1
0
        private IEnumerator <YieldInstruction> Run()
        {
            var actions = new GameViewAction[]
            {
                new DeclareResourceAction()
                {
                    Client             = Player1,
                    ResourceIdentifier = "x"
                },
                new PlaceResourceAction()
                {
                    Client             = Player1,
                    ResourceIdentifier = "x",
                    ResourcePosition   = new Integer2(1, 1)
                },
                new PlaceResourceAction()
                {
                    Client             = Player2,
                    ResourceIdentifier = "x",
                    ResourcePosition   = new Integer2(3, 3)
                },
                new EndTurnAction()
                {
                    Client = Player1
                },

                new DeclareResourceAction()
                {
                    Client             = Player2,
                    ResourceIdentifier = "x"
                },
                new PlaceResourceAction()
                {
                    Client             = Player1,
                    ResourceIdentifier = "x",
                    ResourcePosition   = new Integer2(0, 1)
                },
                new PlaceResourceAction()
                {
                    Client             = Player2,
                    ResourceIdentifier = "x",
                    ResourcePosition   = new Integer2(2, 3)
                },
                new EndTurnAction()
                {
                    Client = Player2
                },

                new DeclareResourceAction()
                {
                    Client             = Player1,
                    ResourceIdentifier = "x"
                },
                new PlaceResourceAction()
                {
                    Client             = Player1,
                    ResourceIdentifier = "x",
                    ResourcePosition   = new Integer2(1, 2)
                },
                new PlaceResourceAction()
                {
                    Client             = Player2,
                    ResourceIdentifier = "x",
                    ResourcePosition   = new Integer2(2, 2)
                },
                new BuildBuildingAction()
                {
                    Client             = Player1,
                    BuildingIdentifier = "building",
                    BuildingPosition   = new Integer2(3, 3),
                    Offset             = new Integer2(2, 1),
                    Orientation        = BuildingOrientation.MirrorXandY
                },
                new EndTurnAction()
                {
                    Client = Player1
                }
            };

            UpdateRendering();

            foreach (var action in actions)
            {
                while (!Input.GetKeyDown(KeyCode.Space))
                {
                    yield return(null);
                }

                Debug.Log($"<b>{action.Client}</b>: Running action {action.GetType().Name}\n");

                Game.Apply(action);

                UpdateRendering();
                yield return(null);
            }
        }
コード例 #2
0
ファイル: GameViewShould.cs プロジェクト: MengQidaNa/RPGCore
        public void CreateSuccessfully()
        {
            var player1 = LocalId.NewShortId();
            var player2 = LocalId.NewShortId();

            PackageExplorer explorer = null;
            var             gameView = new GameView();

            gameView.Create(explorer);
            gameView.Players = new GamePlayer[]
            {
                new GamePlayer()
                {
                    OwnerId = player1,
                    Board   = new GameBoard(4, 4),
                },
                new GamePlayer()
                {
                    OwnerId = player2,
                    Board   = new GameBoard(4, 4),
                }
            };

            gameView.Apply(new DeclareResourceAction()
            {
                Client             = player1,
                ResourceIdentifier = "1"
            });
            gameView.Apply(new PlaceResourceAction()
            {
                Client             = player1,
                ResourceIdentifier = "1",
                ResourcePosition   = new Integer2(1, 1)
            });
            gameView.Apply(new PlaceResourceAction()
            {
                Client             = player2,
                ResourceIdentifier = "1",
                ResourcePosition   = new Integer2(3, 3)
            });
            gameView.Apply(new EndTurnAction()
            {
                Client = player1
            });

            gameView.Apply(new DeclareResourceAction()
            {
                Client             = player2,
                ResourceIdentifier = "2"
            });
            gameView.Apply(new PlaceResourceAction()
            {
                Client             = player1,
                ResourceIdentifier = "2",
                ResourcePosition   = new Integer2(2, 1)
            });
            gameView.Apply(new PlaceResourceAction()
            {
                Client             = player2,
                ResourceIdentifier = "2",
                ResourcePosition   = new Integer2(2, 1)
            });
            gameView.Apply(new EndTurnAction()
            {
                Client = player2
            });

            gameView.Apply(new DeclareResourceAction()
            {
                Client             = player1,
                ResourceIdentifier = "3"
            });
            gameView.Apply(new PlaceResourceAction()
            {
                Client             = player1,
                ResourceIdentifier = "3",
                ResourcePosition   = new Integer2(1, 2)
            });
            gameView.Apply(new PlaceResourceAction()
            {
                Client             = player2,
                ResourceIdentifier = "3",
                ResourcePosition   = new Integer2(1, 2)
            });

            DrawGameState(gameView);

            gameView.Apply(new BuildBuildingAction()
            {
                Client             = player1,
                BuildingIdentifier = "building",
                BuildingPosition   = new Integer2(2, 2),
                Offset             = new Integer2(1, 1),
                Orientation        = BuildingOrientation.None
            });
            gameView.Apply(new EndTurnAction()
            {
                Client = player1
            });

            DrawGameState(gameView);
        }