public void Initialize() { // Set the singleton object. singleton = this; // Set some default values CurrentPickup = PickupType.Normal; _currentChamberNumber = -1; _lastCoinChamberNumber = short.MinValue; // must be further than minimum coin distance from 0, but not too small that it'd overflow on distance calculation. // Create our random number generators, and store/restore the chamber generator state. _pickupRNG = new RandomGen(); _chamberRNG = new RandomGen(); if (!string.IsNullOrEmpty(_initialChamberRNGState)) { _chamberRNG.SetStateJson(_initialChamberRNGState); } else { _initialChamberRNGState = _chamberRNG.GetStateJson(); } // Sort our chambers for quick lookups. _continuousChambersByDirection = new Dictionary <ChamberDirection, List <Chamber> >(); _continuousChambersByDirection[ChamberDirection.Straight] = new List <Chamber>(); _continuousChambersByDirection[ChamberDirection.Turn] = new List <Chamber>(); foreach (Chamber chamber in _continuousChambers) { _continuousChambersByDirection[chamber.ChamberDirection].Add(chamber); } // Sort our pickups for quick lookups. _pickupsByType = new Dictionary <PickupType, List <Pickup> >(); foreach (Pickup pickup in _pickups) { if (!_pickupsByType.ContainsKey(pickup.PickupType)) { _pickupsByType[pickup.PickupType] = new List <Pickup>(); } _pickupsByType[pickup.PickupType].Add(pickup); } }