Ejemplo n.º 1
0
    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;
        }
    }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
    // 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();
    }
Ejemplo n.º 4
0
 void OnConnectionStateChanged(Die die, Die.ConnectionState oldState, Die.ConnectionState newState)
 {
     UpdateState();
 }
Ejemplo n.º 5
0
 void UpdateConnectionState(Die die, Die.ConnectionState newState)
 {
     statusText.text = newState.ToString();
     MonitorBatteryLevel(die.connectionState >= Die.ConnectionState.Ready);
 }