コード例 #1
0
		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();
		}
コード例 #2
0
		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();
		}
コード例 #3
0
		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();
		}
コード例 #4
0
		private void OnTurnStarted(Game sender)
		{
			playerView.SetPlayer(game.ActivePlayer);
		}