void onDieConnectionStateChanged(Die die, Die.ConnectionState newState) { switch (newState) { case Die.ConnectionState.Ready: // Now we can check the type of the die if (die.dieType != Die.DieType.Unknown) { // Yay, good die! // We shouldn't need to filter double discovering the same die, but there is a bug // in the virtual bluetooth interface... if (!_dice.Contains(die)) { AddDieToGame(die); } } // Else we probably should disconnect and then keep a list // of invalid dice so we don't reconnected automatically break; case Die.ConnectionState.Disconnected: RemoveDieFromGame(die); break; default: break; } }
void OnDieConnectionStateChanged(Die die, Die.ConnectionState newConnected) { if (newConnected == Die.ConnectionState.Disconnected) { if (trackedDice.Count > 1) { var go = trackedDice[die].gameObject; GameObject.Destroy(go); } else { noDiceIndicator.SetActive(true); diceRoot.SetActive(false); } trackedDice.Remove(die); UnregisterDieEvents(die); } }
// void onWillDestroyDie(Die die) // { // var uidie = discoveredDice.Find(d => d.die == die); // if (uidie != null) // { // die.OnConnectionStateChanged -= OnDieStateChanged; // Debug.Assert(die.connectionState == Die.ConnectionState.New); // if not we should have been notified previously // discoveredDice.Remove(uidie); // DestroyDiscoveredDie(uidie); // } // } void OnDieStateChanged(Die die, Die.ConnectionState oldState, Die.ConnectionState newState) { RefreshView(); }
void OnConnectionStateChanged(Die die, Die.ConnectionState oldState, Die.ConnectionState newState) { UpdateState(); }
void UpdateConnectionState(Die die, Die.ConnectionState newState) { statusText.text = newState.ToString(); MonitorBatteryLevel(die.connectionState >= Die.ConnectionState.Ready); }