Beispiel #1
0
        public override void OnConnect()
        {
            Console.WriteLine("Device Connected!");

            Windesheart.PairedDevice = this;

            //Check if bluetooth-state changes to off and then on, to enable reconnection management
            BluetoothService.StartListeningForAdapterChanges();

            Characteristics?.Clear();

            CharacteristicDisposable?.Dispose();
            //Find unique characteristics
            CharacteristicDisposable = IDevice.WhenAnyCharacteristicDiscovered().Subscribe(async characteristic =>
            {
                if (characteristic != null && !Characteristics.Contains(characteristic))
                {
                    Characteristics.Add(characteristic);

                    //Check if authCharacteristic has been found, then authenticate
                    if (characteristic.Uuid == MiBand3Resource.GuidCharacteristicAuth)
                    {
                        //Check if this is a new connection that needs authentication
                        await _authenticationService.Authenticate();
                    }
                }
            });
        }
 private void SetCardableObject()
 {
     if (Characteristics.Contains(Characteristic.Type.Poison))
     {
         CardableObject.Set(Unit.AttitudePower.Max, new List <Card> {
             new Card(new EatAction("сьел с огрызком"))
         });
         CardableObject.Set(Unit.AttitudePower.Hight, new List <Card> {
             new Card(new EatAction("сьел"))
         });
         CardableObject.Set(Unit.AttitudePower.Normal, new List <Card> {
             new Card(new PeekAction("взял с собой"))
         });
         CardableObject.Set(Unit.AttitudePower.Low, new List <Card> {
             new Card(new IgnoreAction("проигнорировал"))
         });
         CardableObject.Set(Unit.AttitudePower.Min, new List <Card> {
             new Card(new IgnoreAction("выбросил"))
         });
     }
     else
     {
     }
 }
Beispiel #3
0
        public int this[string key]
        {
            get
            {
                if (!Characteristics.Contains(key))
                {
                    throw new ArgumentOutOfRangeException(nameof(key), key,
                                                          message: "Characteristic must be one of " + string.Join(",", Characteristics));
                }

                switch (key)
                {
                case "Health":
                    return(Health);

                case "Mana":
                    return(Mana);

                case "Strength":
                    return(Strength);

                case "Toughness":
                    return(Toughness);

                case "Agility":
                    return(Agility);

                case "Intelligence":
                    return(Intelligence);

                case "Willpower":
                    return(Willpower);
                }

                return(0);
            }

            set
            {
                if (!Characteristics.Contains(key))
                {
                    throw new ArgumentOutOfRangeException(nameof(key), key,
                                                          message: "Characteristic must be one of " + string.Join(",", Characteristics));
                }
                switch (key)
                {
                case "Health":
                    Health = value;
                    break;

                case "Mana":
                    Mana = value;
                    break;

                case "Strength":
                    Strength = value;
                    break;

                case "Toughness":
                    Toughness = value;
                    break;

                case "Agility":
                    Agility = value;
                    break;

                case "Intelligence":
                    Intelligence = value;
                    break;

                case "Willpower":
                    Willpower = value;
                    break;
                }
            }
        }