Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
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;
    }
Ejemplo n.º 3
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);
    }
Ejemplo n.º 4
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;
        }
    }