Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (!m_bSetup)
        {
            m_bSetup = true;
            uiManager.OnClickMarkets();
            uiManager.OnCashChanged(PlayerCash);
            return;
        }

        // determine if any market events occur this frame
        if (m_marketEvent == null)
        {
            m_marketEvent = marketEvents[0];
            GameEvents.BroadcastMarketEvent(m_marketEvent, null);
            return;
        }

        /*
         * List<MarketEvents> selected = new List<MarketEvents>();
         * foreach (MarketEvents marketEvent in marketEvents)
         * {
         *  float probability = Time.deltaTime * 1000f / (marketEvent.Periodicity * 1000f);
         *  float rando = Random.Range(0f, 1000f);
         *  if (rando < probability)
         *  {
         *      Debug.Log("Market Event: " + marketEvent.EventType.ToString());
         *      selected.Add(marketEvent);
         *  }
         * }
         * if (selected.Count > 0)
         * {
         *  int select = Random.Range(0, selected.Count);
         *  m_marketEvent = selected[select];
         *  selected.Clear();
         *  Stock stockAffected = null;
         *  switch (m_marketEvent.StocksAffected)
         *  {
         *      case MarketEvents.EStocksAffected.One:
         *          stockAffected = Markets[Random.Range(0, Markets.Count)];
         *          break;
         *      case MarketEvents.EStocksAffected.All:
         *          break;
         *      default:
         *          break;
         *  }
         *  GameEvents.BroadcastMarketEvent(m_marketEvent, stockAffected);
         *  Debug.Log("Market Event: " + m_marketEvent.EventType.ToString());
         * }
         */
    }