示例#1
0
 protected void NoisyHandlerStart()
 {
     if (advancedNoiseOverride != null && advancedNoiseOverride.Length > 0)
     {
         noise = Noisy.GetSound(advancedNoiseOverride);
     }
 }
示例#2
0
 public ChatMessage(string botUsername, string userId, string userName, string displayName, string colorHex, Color color, EmoteSet emoteSet,
                    string message, UserType userType, string channel, string id, bool isSubscriber, int subscribedMonthCount, string roomId, bool isTurbo, bool isModerator,
                    bool isMe, bool isBroadcaster, Noisy noisy, string rawIrcMessage, string emoteReplacedMessage, List <KeyValuePair <string, string> > badges,
                    CheerBadge cheerBadge, int bits, double bitsInDollars)
 {
     BotUsername          = botUsername;
     UserId               = userId;
     DisplayName          = displayName;
     ColorHex             = colorHex;
     Color                = color;
     EmoteSet             = emoteSet;
     Message              = message;
     UserType             = userType;
     Channel              = channel;
     Id                   = id;
     IsSubscriber         = isSubscriber;
     SubscribedMonthCount = subscribedMonthCount;
     RoomId               = roomId;
     IsTurbo              = isTurbo;
     IsModerator          = isModerator;
     IsMe                 = isMe;
     IsBroadcaster        = isBroadcaster;
     Noisy                = Noisy;
     RawIrcMessage        = rawIrcMessage;
     EmoteReplacedMessage = emoteReplacedMessage;
     Badges               = badges;
     CheerBadge           = cheerBadge;
     Bits                 = bits;
     BitsInDollars        = bitsInDollars;
 }
示例#3
0
 /// Plays the sound. Cannot have the sound follow the object because a position is given, not a transform
 /// <returns>The sound.</returns>
 /// <param name="p">where the noise is</param>
 public AudioSource PlaySound(Vector3 p)
 {
     if (!backgroundMusic)
     {
         activeAudioSource = Noisy.PlaySound(GetSoundToPlay(), p, !is2D, loop, onePlayAtATime ? name : null, 1 - volumeReduce);
     }
     else
     {
         activeAudioSource = Noisy.PlayBackgroundMusic(GetSoundToPlay(), 1 - volumeReduce);
     }
     return(activeAudioSource);
 }
示例#4
0
 void Start()
 {
     NoisyHandlerStart();
     if (noise.sounds == null || noise.sounds.Length == 0)
     {
         Noisy n = GetComponent <Noisy>();
         if (n != null && n.noises != null && n.noises.Length > 0)
         {
             this.noise = n.noises[0];
         }
     }
 }
        private void TryPerformInference(bool reloadImages = true)
        {
            if (CurrentImagePath != null)
            {
                if (reloadImages)
                {
                    Original = WinMLSamplesGalleryNative.OpenCVImage.CreateFromPath(CurrentImagePath);
                    Noisy    = WinMLSamplesGalleryNative.OpenCVImage.AddSaltAndPepperNoise(Original);
                    Denoised = WinMLSamplesGalleryNative.OpenCVImage.DenoiseMedianBlur(Noisy);

                    var baseImageBitmap = Original.AsSoftwareBitmap();
                    RenderingHelpers.BindSoftwareBitmapToImageControl(InputImage, baseImageBitmap);
                    RenderingHelpers.BindSoftwareBitmapToImageControl(NoisyImage, Noisy.AsSoftwareBitmap());
                    RenderingHelpers.BindSoftwareBitmapToImageControl(DenoisedImage, Denoised.AsSoftwareBitmap());

                    var tensorizationModel = TensorizationModels.CastResizeAndTranspose11(Height, Width, 1, 3, baseImageBitmap.PixelHeight, baseImageBitmap.PixelWidth, "nearest");
                    _tensorizationSession = CreateLearningModelSession(tensorizationModel, SelectedDeviceKind);
                }

                WinMLSamplesGalleryNative.OpenCVImage classificationImage = null;
                switch (InferenceChoice)
                {
                case ClassifyChoice.Original:
                    classificationImage = Original;
                    break;

                case ClassifyChoice.Noisy:
                    classificationImage = Noisy;
                    break;

                case ClassifyChoice.Denoised:
                    classificationImage = Denoised;
                    break;
                }

                // Classify
                var(labels, probabilities) = Classify(classificationImage);

                // Render the classification and probabilities
                RenderInferenceResults(labels, probabilities);
            }
        }
示例#6
0
        /// <summary>
        /// Invokes the message received.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="botUsername">The bot username.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="displayName">The display name.</param>
        /// <param name="colorHex">The color hexadecimal.</param>
        /// <param name="color">The color.</param>
        /// <param name="emoteSet">The emote set.</param>
        /// <param name="message">The message.</param>
        /// <param name="userType">Type of the user.</param>
        /// <param name="channel">The channel.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="isSubscriber">if set to <c>true</c> [is subscriber].</param>
        /// <param name="subscribedMonthCount">The subscribed month count.</param>
        /// <param name="roomId">The room identifier.</param>
        /// <param name="isTurbo">if set to <c>true</c> [is turbo].</param>
        /// <param name="isModerator">if set to <c>true</c> [is moderator].</param>
        /// <param name="isMe">if set to <c>true</c> [is me].</param>
        /// <param name="isBroadcaster">if set to <c>true</c> [is broadcaster].</param>
        /// <param name="noisy">The noisy.</param>
        /// <param name="rawIrcMessage">The raw irc message.</param>
        /// <param name="emoteReplacedMessage">The emote replaced message.</param>
        /// <param name="badges">The badges.</param>
        /// <param name="cheerBadge">The cheer badge.</param>
        /// <param name="bits">The bits.</param>
        /// <param name="bitsInDollars">The bits in dollars.</param>
        public static void InvokeMessageReceived(this TwitchClient client, string botUsername, string userId, string userName, string displayName, string colorHex,
                                                 Color color, EmoteSet emoteSet, string message, UserType userType, string channel, string id, bool isSubscriber, int subscribedMonthCount, string roomId, bool isTurbo,
                                                 bool isModerator, bool isMe, bool isBroadcaster, bool isVip, bool isPartner, bool isStaff, Noisy noisy, string rawIrcMessage, string emoteReplacedMessage, List <KeyValuePair <string, string> > badges,
                                                 CheerBadge cheerBadge, int bits, double bitsInDollars)
        {
            OnMessageReceivedArgs model = new OnMessageReceivedArgs()
            {
                ChatMessage = new ChatMessage(botUsername, userId, userName, displayName, colorHex, color, emoteSet, message, userType, channel, id, isSubscriber,
                                              subscribedMonthCount, roomId, isTurbo, isModerator, isMe, isBroadcaster, isVip, isPartner, isStaff, noisy, rawIrcMessage, emoteReplacedMessage, badges, cheerBadge, bits,
                                              bitsInDollars)
            };

            client.RaiseEvent("OnMessageReceived", model);
        }
示例#7
0
        /// <summary>
        /// Invokes the chat commands received.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="botUsername">The bot username.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="displayName">The display name.</param>
        /// <param name="colorHex">The color hexadecimal.</param>
        /// <param name="color">The color.</param>
        /// <param name="emoteSet">The emote set.</param>
        /// <param name="message">The message.</param>
        /// <param name="userType">Type of the user.</param>
        /// <param name="channel">The channel.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="isSubscriber">if set to <c>true</c> [is subscriber].</param>
        /// <param name="subscribedMonthCount">The subscribed month count.</param>
        /// <param name="roomId">The room identifier.</param>
        /// <param name="isTurbo">if set to <c>true</c> [is turbo].</param>
        /// <param name="isModerator">if set to <c>true</c> [is moderator].</param>
        /// <param name="isMe">if set to <c>true</c> [is me].</param>
        /// <param name="isBroadcaster">if set to <c>true</c> [is broadcaster].</param>
        /// <param name="noisy">The noisy.</param>
        /// <param name="rawIrcMessage">The raw irc message.</param>
        /// <param name="emoteReplacedMessage">The emote replaced message.</param>
        /// <param name="badges">The badges.</param>
        /// <param name="cheerBadge">The cheer badge.</param>
        /// <param name="bits">The bits.</param>
        /// <param name="bitsInDollars">The bits in dollars.</param>
        /// <param name="commandText">The command text.</param>
        /// <param name="argumentsAsString">The arguments as string.</param>
        /// <param name="argumentsAsList">The arguments as list.</param>
        /// <param name="commandIdentifier">The command identifier.</param>
        public static void InvokeChatCommandsReceived(this TwitchClient client, string botUsername, string userId, string userName, string displayName,
                                                      string colorHex, Color color, EmoteSet emoteSet, string message, UserType userType, string channel, string id, bool isSubscriber, int subscribedMonthCount,
                                                      string roomId, bool isTurbo, bool isModerator, bool isMe, bool isBroadcaster, Noisy noisy, string rawIrcMessage, string emoteReplacedMessage,
                                                      List <KeyValuePair <string, string> > badges, CheerBadge cheerBadge, int bits, double bitsInDollars, string commandText, string argumentsAsString,
                                                      List <string> argumentsAsList, char commandIdentifier)
        {
            ChatMessage msg = new ChatMessage(botUsername, userId, userName, displayName, colorHex, color, emoteSet, message, userType, channel, id,
                                              isSubscriber, subscribedMonthCount, roomId, isTurbo, isModerator, isMe, isBroadcaster, noisy, rawIrcMessage, emoteReplacedMessage,
                                              badges, cheerBadge, bits, bitsInDollars);
            OnChatCommandReceivedArgs model = new OnChatCommandReceivedArgs()
            {
                Command = new ChatCommand(msg, commandText, argumentsAsString, argumentsAsList, commandIdentifier)
            };

            client.RaiseEvent("OnChatCommandReceived", model);
        }
示例#8
0
    /// Plays the named sound (as a 2D sound, full volume)
    public static AudioSource PlaySound(string name)
    {
        Noise n = GetSound(name);

        return((n != null) ? Noisy.PlaySound(n.GetSoundToPlay()) : null);
    }
示例#9
0
    public void InfluenceMaslow(MaslowMeter influencer, Habits.Layer influenceLayer, float phappy, float psafety, float pfood)
    {
        if (phappy > 0)
        {
            Noisy.PlaySound("Mood Increased");
        }
        else if (phappy < 0)
        {
            Noisy.PlaySound("Mood Decreased");
        }

        // Assign the persons interacting with each other to facilitate animation during exchange
        influencer.RestoreInteractingWithColor();

        influencer.interactingWith = this;
        if (interactingWith != null)
        {
            interactingWith.RestoreInteractingWithColor();
        }

        interactingWith = influencer;

        Need receivedNeed   = needs[(int)influenceLayer];
        Need influencerNeed = influencer.needs[(int)influenceLayer];

        if ((int)influencerNeed.layer <= highestLayer + 1)
        {
            if (influencerNeed.habitPrimary != null)
            {
                // If we have no primary, get us started at max
                if (receivedNeed.habitPrimary == null)
                {
                    //Debug.Log("isPlayer:"+isPlayer);
                    //Debug.Log("highestLayer:"  + highestLayer);
                    highestLayer++;
                    happy += 2f;
                    interactingWith.happy += 2f;
                    //Debug.Log("highestLayer:"  + highestLayer);

                    // TODO: Make a way to share someone's secondary needs with yourself, otehrwise just always ask for their primary.
                    receivedNeed.habitPrimary      = influencerNeed.habitPrimary;
                    receivedNeed.habitPrimaryValue = MaslowMeter.maxHabitValue;
                    if (highestLayer + 1 == (int)receivedNeed.layer)
                    {
                        //highestLayer ++;
                    }
                }
                // otherwise check if its the primary we already have being boosted to max again
                else if (receivedNeed.habitPrimary.name != influencerNeed.habitPrimary.name)
                {
                    receivedNeed.habitSecondary    = influencerNeed.habitPrimary;
                    receivedNeed.habitPrimaryValue = MaslowMeter.maxHabitValue;
                }
                // or its our first secondary
                else if (receivedNeed.habitSecondary == null)
                {
                    receivedNeed.habitSecondary       = influencerNeed.habitPrimary;
                    receivedNeed.habitPrimaryValue   -= secondaryInfluenceAmount;
                    receivedNeed.habitSecondaryValue += secondaryInfluenceAmount;
                }
                // or a secondary we do have
                else if (receivedNeed.habitSecondary.name == influencerNeed.name)
                {
                    receivedNeed.habitSecondary    = influencerNeed.habitPrimary;
                    receivedNeed.habitPrimaryValue = MaslowMeter.maxHabitValue;
                }
                // or a secondary different from ours replaces our secondary
                else if (receivedNeed.habitSecondary.name != influencerNeed.habitPrimary.name)
                {
                    receivedNeed.habitSecondary       = influencerNeed.habitPrimary;
                    receivedNeed.habitPrimaryValue   -= secondaryInfluenceAmount;
                    receivedNeed.habitSecondaryValue += secondaryInfluenceAmount;
                }
                // or nothing is there to gain
                else
                {
                    UnityEngine.Debug.Log("Nothing to gain.");
                }
            }
            receivedNeed.Use(receivedNeed.ui, receivedNeed);

            // If our secondary beat our primary, bin the old and in with the new
            if (secondaryInfluenceAmount >= maxHabitValue)
            {
                receivedNeed.habitOld            = receivedNeed.habitPrimary;
                receivedNeed.habitPrimary        = receivedNeed.habitSecondary;
                receivedNeed.habitPrimaryValue   = maxHabitValue;
                receivedNeed.habitSecondaryValue = minHabitValue;
            }

            // else
            else
            {
            }

            /*
             * // Right now influence is always +/- 1 or 0
             * if ( Math.Abs( phappy ) >= 5 ) {
             *  happy += phappy / Math.Abs( phappy );
             *  happy = Mathf.Clamp( happy, -10, 10 );
             * }
             *
             * if ( Math.Abs( psafety ) >= 5 ) {
             *  safety += psafety / Math.Abs( psafety );
             *  safety = Mathf.Clamp( safety, -10, 10 );
             * }
             *
             * if ( Math.Abs( pfood ) >= 5 ) {
             *  health += pfood / Math.Abs( pfood );
             *  health = Mathf.Clamp( health, -10, 10 );
             * }*/
        } // end if not higher than next higher layer
        dirty = true;
    }
示例#10
0
 public ChatMessageBuilder WithNoisy(Noisy noisy)
 {
     _noisy = noisy;
     return(this);
 }
示例#11
0
    public void Vote(MaslowMeter.MyVote vote)
    {
        Sprite voteSprite = null;

        if (vote == MaslowMeter.MyVote.yea)
        {
            voteSprite = MaslowManager.Instance.emojiSprites[yesVotes[Random.Range(0, yesVotes.Length)]];
        }
        else
        {
            voteSprite = MaslowManager.Instance.emojiSprites[noVotes[Random.Range(0, noVotes.Length)]];
        }
        // TODO move a bunch of this code to Election...
        int yesVoteCountThisTime, noVoteCountThisTime;

        Election.Instance.Tally(out yesVoteCountThisTime, out noVoteCountThisTime);
        if (voteSprite != null)
        {
            voteSlot.sprite = voteSprite;
        }
        int totalVotes = noVoteCountThisTime + yesVoteCountThisTime;

        //Debug.Log("VOTES: " + totalVotes+"   "+ yesVoteCountThisTime+" vs "+ noVoteCountThisTime);
        if (noVoteCountThisTime >= 3 ||
            (totalVotes == 5 && noVoteCountThisTime >= 3))
        {
            Noisy.PlaySound("Judge made bad choice");
        }
        if (yesVoteCountThisTime >= 3 ||
            (totalVotes == 5 && yesVoteCountThisTime >= 3))
        {
            Noisy.PlaySound("Judge made good choice");
        }
        // after 5 votes, increment the round
        if (totalVotes == 5)
        {
            totalRounds++;
        }
        if (yesVoteCountThisTime >= 3)
        {
            Noisy.PlaySound("Win game");
            //UnityEngine.SceneManagement.SceneManager.LoadScene("Win Screen");
            gameIsWon = true;
            Camera.main.GetComponent <CharacterCamera>().target = Election.Instance.transform;
            Election.Instance.victory.gameObject.SetActive(true);
            Election.Instance.victory.Play();
            return;
        }
        if (noVoteCountThisTime >= 3 && totalRounds >= 5)
        {
            Noisy.PlaySound("Lose game");
            UnityEngine.SceneManagement.SceneManager.LoadScene("Lose Screen");
        }
        if (totalVotes == 5)
        {
            // clear votes
            Election.Instance.ResetVotes(unknownVote);
            // restart people at their start locations
            CharacterMove[] cms = FindObjectsOfType <CharacterMove>();
            System.Array.ForEach(cms, cm => { cm.transform.position = cm.startPosition; });
            // bring up water
            Election.Instance.sealevel.position = Election.Instance.sealevel.position + Vector3.up * 5;
        }
    }