示例#1
0
 // called when we repeat this message - clears all the validation and sets the type to voice-command
 public void prepareToBeRepeated()
 {
     if (metadata == null)
     {
         metadata = new SoundMetadata();
     }
     messageName        = "REPEAT_" + messageName;
     metadata.messageId = getMessageId();
     metadata.priority  = 5;
     metadata.type      = SoundType.VOICE_COMMAND_RESPONSE;
     dueTime            = 0;
     expiryTime         = 0;
     abstractEvent      = null;
     validationData     = null;
     secondsDelay       = 0;
 }
示例#2
0
        public QueuedMessage(String messageName, int expiresAfter, List <MessageFragment> messageFragments = null,
                             List <MessageFragment> alternateMessageFragments = null, DelayedMessageEvent delayedMessageEvent = null,
                             int secondsDelay = 0, AbstractEvent abstractEvent                 = null, Dictionary <String, Object> validationData = null,
                             int priority     = SoundMetadata.DEFAULT_PRIORITY, SoundType type = SoundType.AUTO)
        {
            this.messageId              = getMessageId();
            this.validationData         = validationData;
            this.creationTime           = GameStateData.CurrentTime.Ticks / TimeSpan.TicksPerMillisecond;
            this.dueTime                = secondsDelay == 0 ? 0 : this.creationTime + (secondsDelay * 1000) + updateInterval;
            this.expiryTime             = expiresAfter == 0 ? 0 : this.creationTime + (expiresAfter * 1000);
            this.secondsDelay           = secondsDelay;
            this.abstractEvent          = abstractEvent;
            this.metadata               = new SoundMetadata(type, priority);
            this.delayedMessageEvent    = delayedMessageEvent;
            this.delayMessageResolution = delayedMessageEvent != null;

            // for delayed message events, we collect up the message folder when the message when the message is about to be played, not here
            if (delayedMessageEvent != null)
            {
                this.messageName = delayedMessageIdentifier + messageName;
            }
            else if (messageFragments == null)
            {
                this.messageName = messageName;
                List <MessageFragment> singleMessageFragement = new List <MessageFragment>();
                singleMessageFragement.Add(MessageFragment.Text(messageName));
                this.messageFolders = getMessageFolders(singleMessageFragement, false);
            }
            else
            {
                this.messageName = compoundMessageIdentifier + messageName;
                Boolean hasAlternative = alternateMessageFragments != null;
                this.messageFolders = getMessageFolders(messageFragments, hasAlternative);
                if (!canBePlayed && hasAlternative)
                {
                    Console.WriteLine("Using secondary messages for event " + messageName);
                    canBePlayed         = true;
                    this.messageFolders = getMessageFolders(alternateMessageFragments, false);
                    if (!canBePlayed)
                    {
                        Console.WriteLine("Primary and secondary messages for event " +
                                          messageName + " can't be played");
                    }
                }
            }
        }