Beispiel #1
0
        IEnumerator GetDieInfoCr(System.Action <bool> callback)
        {
            void updateDieInfo(DieMessage msg)
            {
                var  idMsg             = (DieMessageIAmADie)msg;
                bool appearanceChanged = faceCount != idMsg.faceCount || designAndColor != idMsg.designAndColor;

                faceCount         = idMsg.faceCount;
                designAndColor    = idMsg.designAndColor;
                deviceId          = idMsg.deviceId;
                dataSetHash       = idMsg.dataSetHash;
                flashSize         = idMsg.flashSize;
                firmwareVersionId = System.Text.Encoding.UTF8.GetString(idMsg.versionInfo, 0, DieMessages.VERSION_INFO_SIZE);
                Debug.Log("Die " + name + " has " + flashSize + " bytes available for data, current dataset hash " + dataSetHash.ToString("X08"));
                if (appearanceChanged)
                {
                    OnAppearanceChanged?.Invoke(this, faceCount, designAndColor);
                }
                callback?.Invoke(true);
            }

            var whoAreYouMsg = new DieMessageWhoAreYou();

            yield return(StartCoroutine(SendMessageWithAckOrTimeoutCr(whoAreYouMsg, DieMessageType.IAmADie, 5, updateDieInfo, () => callback?.Invoke(false), () => callback?.Invoke(false))));
        }
Beispiel #2
0
 public Coroutine SetCurrentDesignAndColor(DesignAndColor design, System.Action <bool> callback)
 {
     return(StartCoroutine(SendMessageWithAckOrTimeoutCr(
                               new DieMessageSetDesignAndColor()
     {
         designAndColor = design
     },
                               DieMessageType.SetDesignAndColorAck,
                               3,
                               (ignore) =>
     {
         designAndColor = design;
         OnAppearanceChanged?.Invoke(this, faceCount, designAndColor);
         callback?.Invoke(true);
     },
                               () => callback?.Invoke(false),
                               () => callback?.Invoke(false))));
 }
Beispiel #3
0
        public async Task ChangeAppearance(byte hair, byte face, byte size, byte sex)
        {
            Hair   = hair;
            Face   = face;
            Height = size;
            Gender = (Gender)sex;

            var character = await _database.Characters.FindAsync(_ownerId);

            if (character is null)
            {
                _logger.LogError("Character {id} is not found", _ownerId);
                return;
            }

            character.Face   = Face;
            character.Hair   = Hair;
            character.Height = Height;
            character.Gender = Gender;

            await _database.SaveChangesAsync();

            OnAppearanceChanged?.Invoke(_ownerId, Hair, Face, Height, (byte)Gender);
        }
Beispiel #4
0
 public void InvokeAppearanceChangedEvent(string value)
 {
     OnAppearanceChanged?.Invoke(value);
     onAppearanceChanged?.Invoke(value);
 }