Exemplo n.º 1
0
        public IStock CreateStockModel <T>(SerializableStock <T> stockToCreate)
            where T : IStock
        {
            switch (stockToCreate.type)
            {
            case StockTypes.Tech:
                return(new TechStock(stockToCreate.marketId, _iconMapping[stockToCreate.type]));

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 2
0
        private void Start()
        {
            var factory = new StockFactory(new Dictionary <string, Texture2D>()
            {
                { StockTypes.Tech, _placeholderIcon }
            });

            for (int i = 0; i < _numOfStockOptions; i++)
            {
                var stock = Instantiate(_stockPrefab) as GameObject;
                var agent = stock.GetComponent <StockAgent>();
                var model = new SerializableStock <TechStock>()
                {
                    startingValue = 7.5m,
                    marketId      = string.Format("PLA:{0}", i + 1),
                    type          = StockTypes.Tech
                };
                stock.name = model.marketId;
                agent.Initialize(factory.CreateStockModel(model));
                stock.transform.SetParent(_stockListDisplay, false);
            }
        }