public GameView(Game game, TextWriter output) { if (game == null) throw new ArgumentNullException("game", "[GameView.Constructor] Game must not be null."); if (output == null) throw new ArgumentNullException("output", "[GameView.Constructor] Output must not be null."); this.game = game; this.output = output; grid = new GridView<Entity>(output) { Descriptor = entity => entity.Symbol, PositionGetter = entity => entity.Position, ItemSource = () => game.AllEntities, GridWidth = game.Map.Width, GridHeight = game.Map.Height, DisplayWidth = 10, DisplayHeight = 10, }; if (output == System.Console.Out) { //grid.PreWrite = entity => System.Console.ForegroundColor = entity.Owner.Color.Value.ToConsoleColor(); //grid.PostWrite = entity => System.Console.ResetColor(); } game.TurnStarted += _ => Draw(); }
protected override void Initialize(IList<string> arguments) { game = new Game(10, 10); game.AddPlayer(new Player(game, "You")); gameView = new GameView(game, Output); game.Start(); }
public override void Start() { game = new Game(100, 100); map.Initialize(game.Map); foreach (City city in game.CityCollection) { EntityView entityView = Instantiate(cityPrefab).GetComponent<EntityView>(); entityView.Initialize(this, city); entityView.transform.SetParent(entityGroup, false); } //foreach (Player player in game.PlayerCollection) //{ // PlayerView playerView = Instantiate(PlayerViewPrefab).GetComponent<PlayerView>(); // playerView.gameObject.SetActive(false); // playerView.Initialize(player, map); // playerView.transform.SetParent(PlayerViewGroup, false); // playerViewCollection.Add(playerView); //} game.TurnStarted += OnTurnStarted; game.Start(); /*contentLoader = new ContentLoader("file:///E:/Projects/Overmind/Games/Mods"); DependencyReadyStatus.Add(contentLoader, false); contentLoader.Ready += OnDependencyReady; StartCoroutine(contentLoader.LoadAssetBundleAsync(Mod));*/ //DoStart(); }
private void OnTurnStarted(Game sender) { playerView.SetPlayer(game.ActivePlayer); }