Example #1
0
    // Use this for initialization
    void Awake()
    {
        loader = this.GetComponent <Loader>();
        loader.AddEventListener(this.gameObject);
        loader.LoadScene(sceneToLoad);

        sadMax   = this.transform.Find("Sprites/headlogoSad").GetComponent <SpriteRenderer>();
        happyMax = this.transform.Find("Sprites/headlogoHappy").GetComponent <SpriteRenderer>();

        if (isLoadedFromIntroScene)
        {
            backgroundMusic = GameObject.Find("BackgroundMusic").GetComponent <SoundObject>();
            DontDestroyOnLoad(backgroundMusic);
        }

        if (sceneToLoad == Scene.EndScene)
        {
            backgroundMusic = GameObject.Find("BackgroundMusic").GetComponent <SoundObject>();
            if (backgroundMusic)
            {
                backgroundMusic.Mute();
            }
        }

        if (sceneToLoad == Scene.FinalMainScene ||
            sceneToLoad == Scene.EndScene || sceneToLoad == Scene.AlternativeEndScene)
        {
            sadMax.enabled   = true;
            happyMax.enabled = false;
        }
    }
Example #2
0
    public void PlaySFX(string audioName)
    {
        if (pool_Parent.transform.childCount <= 0)
        {
            Debug.LogWarning("Sound pool is empty, this sound will not be played.");
            return;
        }

        AudioClip clip = null;

        if (soundDictionary.TryGetValue(audioName, out clip))
        {
            SoundObject sfx = GrabFromPool();
            if (sfx == null)
            {
                return;
            }


            sfx.transform.SetParent(SFX_Parent);
            sfx.gameObject.name = audioName;
            sfx.SetAudioClip(clip);
            sfx.SetVolume(defaultSFXVolume);
            sfx.SetLoop(false);
            sfx.Play();
            activeSFX.Add(sfx);
            SFX_Parent.name = "SFX (" + activeSFX.Count.ToString() + ")";
        }
        else
        {
            Debug.LogWarning("Unable to play SFX sound, " + audioName + " does not exist.");
        }
    }
Example #3
0
        private static IEnumerator AudioFade(SoundObject soundObject, Direction direction)
        {
            // set variables based on the direction
            bool  fadeIn     = direction == Direction.FadeIn;
            float step       = fadeIn ? 1 * (1f / soundObject.fadeDuration) : -1 * (1f / soundObject.fadeDuration);
            float fadeTarget = fadeIn ? soundObject.audioSource.volume : 0;
            float fadeValue  = fadeIn ? 0 : soundObject.audioSource.volume;

            if (fadeIn)
            {
                while (fadeValue < fadeTarget)
                {
                    fadeValue += Time.deltaTime * step;
                    soundObject.audioSource.volume = fadeValue;

                    yield return(null);
                }
            }
            else
            {
                while (fadeValue > fadeTarget)
                {
                    fadeValue += Time.deltaTime * step;
                    soundObject.audioSource.volume = fadeValue;

                    yield return(null);
                }

                soundObject.audioSource.Stop();
            }

            soundObject.volume = soundObject.audioSource.volume = fadeTarget;
        }
Example #4
0
    // main logic
    void Init()
    {
        // keep this object alive
        DontDestroyOnLoad(this.gameObject);

        // we will grab the volume from PlayerPrefs when this script first starts
        string stKey = string.Format("{0}_SFXVol", gamePrefsName);

        if (PlayerPrefs.HasKey(stKey))
        {
            volume = PlayerPrefs.GetFloat(stKey);
        }
        else
        {
            volume = 0.5f;
        }

        soundObjectList = new List <SoundObject> ();

        // make sound objects for all of the sounds in GameSounds array
        foreach (AudioClip theSound in GameSounds)
        {
            tempSoundObj = new SoundObject(theSound, theSound.name, volume);
            soundObjectList.Add(tempSoundObj);

            // keep this object alive
            DontDestroyOnLoad(tempSoundObj.sourceGO);

            totalSounds++;
        }
    }
Example #5
0
    public void PlayAmbience(string audioName)
    {
        AudioClip clip = null;

        if (activeAmbience.ContainsKey(audioName))
        {
            Debug.LogWarning("Ambience sound is already playing.");
            return;
        }

        if (soundDictionary.TryGetValue(audioName, out clip))
        {
            SoundObject ambient = GrabFromPool();
            if (bgm == null)
            {
                return;
            }

            ambient.transform.SetParent(ambience_Parent);
            ambient.gameObject.name = audioName;
            ambient.SetAudioClip(clip);
            ambient.SetVolume(defaultAmbientVolume);
            ambient.SetLoop(true);
            ambient.Play();

            activeAmbience.Add(audioName, ambient);
            ambience_Parent.name = "Ambience (" + activeAmbience.Count.ToString() + ")";
        }
        else
        {
            Debug.Log("Unable to play Ambient sound, " + audioName + " does not exist.");
        }
    }
Example #6
0
    /// <summary>
    /// Plays the specified sound once, and deletes the sound object after playback.
    /// </summary>
    public override void PlayOneShot(SoundInfo.SFXID soundID)
    {
        SoundObject oneShotSFX = CreateSoundObject(soundID);

        oneShotSFX.Initialize(this, SoundInfo.SoundType.ONE_SHOT, !m_areSoundsOn);
        oneShotSFX.Play();
    }
Example #7
0
    void  Start()
    {
        playButtons = this.transform.Find("PlayButtons");
        yesButton   = playButtons.GetComponentInChildren <YesButton>();
        yesButton.AddEventListener(this.gameObject);
        noButton = playButtons.GetComponentInChildren <NoButton>();
        noButton.AddEventListener(this.gameObject);

        playButtons.active = false;

        bombChain       = this.transform.Find("BombChain").gameObject;
        maxHand         = this.transform.Find("MaxHand").GetComponent <Hand>();
        bombAttachSound = this.transform.Find("BombAttachSound").GetComponent <SoundObject>();
        maxHand.AddEventListener(this.gameObject);
        chainHand = this.transform.Find("ChainHand").GetComponent <Hand>();
        chainHand.AddEventListener(this.gameObject);

        textBoxManagerAfterFirstDialogue = this.transform.Find("TextBoxManagerAfterFirstDialogue").GetComponent <TextBoxManager>();
        textBoxManagerAfterFirstDialogue.AddEventListener(this.gameObject);

        textBoxManagerAfterFirstDialogue.active = false;

        playerControl = this.GetComponentInChildren <MenuPlayerControl>();
        maxHand.AddEventListener(playerControl.gameObject);

        AttachChainToMax();
    }
Example #8
0
    /// <summary>
    /// Starts the win animation.
    /// </summary>
    protected override void StartWinAnimation()
    {
        // Change face into a happy one
        m_browLeft.SetScaleY(-m_browLeft.transform.localScale.y);
        m_browLeft.Rotate(Vector3.forward * 35.0f);
        m_browRight.SetScaleY(-m_browRight.transform.localScale.y);
        m_browRight.Rotate(Vector3.forward * -35.0f);
        m_mouth.Rotate(Vector3.forward * 180.0f);
        m_chin.gameObject.SetActive(false);

        // Disable wasp sound
        if (m_waspSound != null)
        {
            RemoveFromSoundObjectList(m_waspSound);
            m_waspSound.Delete();
            m_waspSound = null;
        }

        // Hide that last wasp...
        foreach (Wasp wasp in m_wasps)
        {
            if (wasp != null)
            {
                wasp.gameObject.SetActive(false);
            }
        }
    }
 /// <summary>
 /// Notifies of a sound object's deletion via means external to SoundSystem.
 /// </summary>
 /// <param name="soundObject">Sound object to delete.</param>
 public virtual void NotifySoundObjectDeletion(SoundObject soundObject)
 {
     if (m_soundObjectList.Contains(soundObject))
     {
         m_soundObjectList.Remove(soundObject);
     }
 }
    private void PlaySound(SoundObject sound, AudioMixerGroup mixerGroup, bool restartIfPlayingAlready, SoundConfiguration configurations)
    {
        //The reproduction is allowed?
        if ((mixerGroup == fxGroup && !_FXAllowed) || (mixerGroup == musicGroup && !_MusicAllowed))
        {
            /*
             * WARNING If the game logic use the returned sound on previous calls to wait for stop event we could have problems.
             * TODO Maybe play the sound with volume zero? Or dispatch stop right away?
             */
            //Denied!
            return;
        }

        //We should avoid the PlayCall?
        if (!restartIfPlayingAlready && sound.isPlaying)
        {
            return;
        }

        //We store the audio so it can be globally paused/stoped
        playingSounds[mixerGroup][sound.soundName] = sound;
        sound.OnAudioStopped += OnAudioStopped;

        //correct group
        sound.audioSource.outputAudioMixerGroup = mixerGroup;
        sound.Play(configurations);
    }
Example #11
0
        /// <summary>
        /// Gets sound effect by name. Searches for it in cache.
        /// If found retuns cached one, otherwise creates a new one.
        /// </summary>
        /// <param name="name">sound effect name.</param>
        /// <returns>cached or newly created sound effect object.</returns>
        internal SoundObject GetSound(String name)
        {
            if ((null == name) || (name == ""))
            {
                return(null);
            }

            lock (this.sounds)
            {
                SoundObject value = null;

                this.sounds.TryGetValue(name, out value);

                if (null == value)
                {
                    value = new SoundObject(this, name);

                    this.sounds.Add(name, value);
                }

                value.AddRef();

                return(value);
            }
        }
Example #12
0
    public void PlayBGM(string audioName)
    {
        AudioClip clip = null;

        if (activeBGM.ContainsKey(audioName))
        {
            Debug.LogWarning("BGM sound is already playing.");
            return;
        }

        if (soundDictionary.TryGetValue(audioName, out clip))
        {
            SoundObject bgm = GrabFromPool();
            if (bgm == null)
            {
                return;
            }

            bgm.transform.SetParent(BGM_Parent);
            bgm.gameObject.name = audioName;
            bgm.SetAudioClip(clip);
            bgm.SetVolume(defaultBGMVolume);
            bgm.SetLoop(true);
            bgm.Play();

            activeBGM.Add(audioName, bgm);
            BGM_Parent.name = "BGM (" + activeBGM.Count.ToString() + ")";
        }
        else
        {
            Debug.Log("Unable to play BGM sound, " + audioName + " does not exist.");
        }
    }
Example #13
0
    /// <summary>
    /// Raises the balloon press event.
    /// </summary>
    private void OnBalloonPress(object sender, System.EventArgs e)
    {
        // Process only one touch per balloon
        if (m_isStrung)
        {
            return;
        }
        m_isStrung = true;

        // Play connect sound
        if (m_connectSound == null)
        {
            m_connectSound = Locator.GetSoundSystem().PlaySound(SoundInfo.SFXID.BALLOON_CONNECT);
        }
        else
        {
            m_connectSound.Play();
        }

        // Initialize move variables
        m_moveStartPos = this.transform.position;

        // Find and store a reference to the touch
        foreach (ITouch touch in m_pressGesture.ActiveTouches)
        {
            if (m_pressGesture.HasTouch(touch))
            {
                m_balloonTouch = touch;
                break;
            }
        }
    }
Example #14
0
    /// <summary>
    /// Plays the specified BGM.
    /// </summary>
    public override SoundObject PlayBGM(SoundInfo.BGMID soundID, bool setPersistent = false)
    {
        SoundObject bgm = base.PlayBGM(soundID, setPersistent);

        bgm.transform.parent = this.transform;
        return(bgm);
    }
Example #15
0
    public void PlaySound(string name)
    {
        SoundObject sound = AllSounds.Find((SoundObject s) => s.Name == name);

        ShuffleList(AllSounds);

        if (sound != null)
        {
            soundPrefab.GetComponent <AudioSource>().pitch       = sound.pitch;
            soundPrefab.GetComponent <AudioSource>().volume      = sound.volume;
            soundPrefab.GetComponent <AudioSource>().clip        = sound.clip;
            soundPrefab.GetComponent <AudioSource>().loop        = sound.loop;
            soundPrefab.GetComponent <AudioSource>().playOnAwake = true;
            GameObject obj = Instantiate(soundPrefab);

            if (!sound.loop)
            {
                Destroy(obj, sound.clip.length + 0.25f);
            }
        }
        else
        {
            Debug.Log(name + " sound not found.");
        }
    }
Example #16
0
    public void CreateSoundObject()
    {
        if (noOfSoundObjects >= 100)
        {
            return;
        }

        recording = true;

        GameObject soundObj = (GameObject)GameObject.Instantiate(SoundObject, Vector3.zero, Quaternion.identity);

        soundObj.transform.SetParent(FocusManager.Instance.transform, false);

        soundObj.transform.localPosition = new Vector3(0, 0, 1f);

        soundObj.transform.SetParent(transform, true);


        SoundObjectInstance = soundObj.GetComponent <SoundObject>();

        SoundObjectInstance.StartRecording();

        SoundObjectInstance.Index = noOfSoundObjects;

        Debug.Log(noOfSoundObjects);

        soundObjects[noOfSoundObjects++] = SoundObjectInstance;
    }
Example #17
0
    /// <summary>
    /// Starts the game.
    /// </summary>
    protected override void StartGame()
    {
        m_tapCounter = 0;
        m_tapTimer   = m_tapCooldown;

        // Play the fire sound
        m_fireBurningSound = Locator.GetSoundSystem().PlaySound(SoundInfo.SFXID.FIRE_BURNING);
        AddToSoundObjectList(m_fireBurningSound);

        // Add animators to list
        AddToAnimatorList(m_characterAnimator);
        AddToAnimatorList(m_fireAnimator);

        // Initialize input for the entire screen
        InitializeInput();

        // Initialize the lerp variables
        m_lerpTimer            = m_lerpDuration;
        m_characterTargetPos   = m_character.transform.position;
        m_characterStartPos    = m_characterTargetPos;
        m_characterTargetScale = m_character.transform.localScale.x;
        m_characterStartScale  = m_characterTargetScale;
        m_fireTargetPos        = m_fire.transform.position;
        m_fireStartPos         = m_fireTargetPos;
        m_fireTargetScale      = m_fire.transform.localScale.x;
        m_fireStartScale       = m_fireTargetScale;
    }
Example #18
0
    /// <summary>
    /// Raises the wire press event.
    /// </summary>
    private void OnWirePress(object sender, System.EventArgs e)
    {
        // Process only one touch per wire
        if (m_isGuideActive)
        {
            return;
        }
        m_isGuideActive = true;

        // Lazy init
        if (m_connectGuide == null)
        {
            m_connectGuide = CreateConnectGuide();
        }

        // Play connect sound
        if (m_connectSound == null)
        {
            m_connectSound = Locator.GetSoundSystem().PlaySound(SoundInfo.SFXID.WIRE_CONNECT);
        }
        else
        {
            m_connectSound.Play();
        }

        // Find and store a reference to the touch
        foreach (ITouch touch in m_pressGesture.ActiveTouches)
        {
            if (m_pressGesture.HasTouch(touch))
            {
                m_wireTouch = touch;
                break;
            }
        }
    }
        private void Dgv_Modify(object sender, RoutedEventArgs e)
        {
            SoundObject     soundObject     = (SoundObject)dgv_sounds.SelectedItem;
            Window_SoundAdd window_SoundAdd = new Window_SoundAdd(soundObject);

            window_SoundAdd.ShowDialog();
        }
        public bool OnCollision(Fixture a, Fixture b, Contact contact)
        {
            if (isActivated && b.isPlayer == true && !b.IsSensor)
            {
                foreach (SoundObject so in this.list)
                {
                    if ((Sound2 is SoundObject))
                    {
                        SoundObject so2 = (SoundObject)Sound2;
                        if (so2.volume < so.volume)
                        {
                            so.Crossfade(so2, _Channel2Gain, _Channel1Loss, _fadeTime);
                        }
                        else
                        {
                            so2.Crossfade(so, _Channel2Gain, _Channel1Loss, _fadeTime);
                        }
                    }
                }
                isActivated = false;
                return(true);
            }


            else
            {
                return(false);
            }
        }
Example #21
0
    public override void OnInspectorGUI()
    {
        SoundObject soundObject = target as SoundObject;

        if (soundObject.SubItem != null)
        {
            EditorGUILayout.LabelField("Category", soundObject.SubItem.Item.Category.Name);
            EditorGUILayout.LabelField("Item", soundObject.SubItem.Item.Name);
            EditorGUILayout.LabelField("SubItem", soundObject.SubItem.Name);
        }

//        EditorGUILayout.PropertyField (this.m_AudioClip, ms_Styles.audioClipLabel, new GUILayoutOption[0]);
//        EditorGUILayout.Space ();
        soundObject.Mute = EditorGUILayout.Toggle("Mute", soundObject.Mute, new GUILayoutOption[0]);
//        soundObject.BypassEffects = EditorGUILayout.Toggle ("BypassEffects", soundObject.BypassEffects, new GUILayoutOption[0]);
//        soundObject.BypassListenerEffects = EditorGUILayout.Toggle ("BypassListenerEffects", soundObject.BypassListenerEffects, new GUILayoutOption[0]);
//        soundObject.BypassReverbZones =  EditorGUILayout.Toggle ("BypassReverbZones", soundObject.BypassReverbZones, new GUILayoutOption[0]);
//        soundObject.PlayOnAwake = EditorGUILayout.Toggle ("PlayOnAwake", soundObject.PlayOnAwake, new GUILayoutOption[0]);
        soundObject.Loop = EditorGUILayout.Toggle("Loop", soundObject.Loop, new GUILayoutOption[0]);
        EditorGUILayout.Space();
        soundObject.Priority = (int)Slider(this.ms_Styles.priorityLabel, soundObject.Priority, 0, 256, ms_Styles.priorityLeftLabel, ms_Styles.priorityRightLabel, new GUILayoutOption[0]);
        EditorGUILayout.Space();
        soundObject.Volume = EditorGUILayout.Slider(ms_Styles.volumeLabel, soundObject.Volume, 0, 1, new GUILayoutOption[0]);
        EditorGUILayout.Space();
        GUI.enabled = false;
        EditorGUILayout.Slider("Total volume", soundObject.TotalVolume, 0, 1, new GUILayoutOption[0]);
        GUI.enabled = true;
        EditorGUILayout.Space();
        soundObject.Pitch = EditorGUILayout.Slider(ms_Styles.pitchLabel, soundObject.Pitch, -3, 3, new GUILayoutOption[0]);
        EditorGUILayout.Space();
        soundObject.Pan = Slider(ms_Styles.panStereoLabel, soundObject.Pan, -1, 1, ms_Styles.panLeftLabel, ms_Styles.priorityRightLabel, new GUILayoutOption[0]);
        EditorGUILayout.Space();
        soundObject.SpatialBlend = Slider(ms_Styles.spatialBlendLabel, soundObject.SpatialBlend, 0, 1, ms_Styles.spatialLeftLabel, ms_Styles.spatialRightLabel, new GUILayoutOption[0]);
        EditorGUILayout.Space();

        soundObject.Spread      = EditorGUILayout.Slider(ms_Styles.spreadLabel, soundObject.Spread, 0, 360, new GUILayoutOption[0]);
        soundObject.MinDistance = EditorGUILayout.FloatField("Min Distance", soundObject.MinDistance);
        soundObject.MaxDistance = EditorGUILayout.FloatField("Max Distance", soundObject.MaxDistance);

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Pause", EditorStyles.miniButton))
        {
            soundObject.Pause(true, "");
        }
        if (GUILayout.Button("Unpause", EditorStyles.miniButton))
        {
            soundObject.Pause(false, "");
        }
        if (GUILayout.Button("Stop", EditorStyles.miniButton))
        {
            soundObject.Stop(soundObject.SubItem.FadeOut);
        }
        EditorGUILayout.EndHorizontal();

        EditorUtility.SetDirty(soundObject);
    }
Example #22
0
 /// <summary>
 /// Plays a new win/lose SFX.
 /// </summary>
 /// <param name="sfxID">Sfx I.</param>
 private void PlayNewWinLoseSFX(SoundInfo.SFXID sfxID)
 {
     if (m_winLoseSFX != null)
     {
         m_winLoseSFX.Delete();
     }
     m_winLoseSFX = Locator.GetSoundSystem().PlaySound(sfxID);
 }
    /// <summary>
    /// Plays the specified sound.
    /// </summary>
    public virtual SoundObject PlaySound(SoundInfo.SFXID soundID)
    {
        SoundObject sound = CreateSoundObject(soundID);

        sound.Initialize(this, SoundInfo.SoundType.REGULAR, !m_areSoundsOn);
        sound.Play();
        return(sound);
    }
 /// <summary>
 /// Stops the river sound
 /// </summary>
 private void StopRiverSound()
 {
     if (m_riverSound != null)
     {
         m_riverSound.Delete();
         m_riverSound = null;
     }
 }
    /// <summary>
    /// Plays the specified BGM.
    /// </summary>
    public virtual SoundObject PlayBGM(SoundInfo.BGMID soundID, bool setPersistent = false)
    {
        SoundObject bgm = CreateSoundObject(soundID, setPersistent);

        bgm.Initialize(this, SoundInfo.SoundType.BGM, !m_areSoundsOn);
        bgm.Play();
        return(bgm);
    }
Example #26
0
        public void CreatePDF(Stream stream)
        {
            var doc  = new GcPdfDocument();
            var page = doc.NewPage();
            var g    = page.Graphics;
            // User names for annotations' authors:
            var user1 = "Aiff Ding";
            var user2 = "Wav Dong";

            TextFormat tf = new TextFormat()
            {
                Font = StandardFonts.Helvetica, FontSize = 10
            };
            var noteWidth = 72 * 3;
            var gap       = 8;

            var rc = Common.Util.AddNote(
                "This sample demonstrates adding sound annotations using GcPdf. " +
                "The track associated with an annotation can be played in a viewer that supports it. " +
                "PDF supports AIFF and WAV tracks in sound annotations.",
                page);

            // AIFF sound annotation:
            var ip = new PointF(rc.X, rc.Bottom + gap);

            rc = Common.Util.AddNote("A red sound annotation is placed to the right of this note. Double click the icon to play the sound.",
                                     page, new RectangleF(ip.X, ip.Y, noteWidth, 100));
            var aiffAnnot = new SoundAnnotation()
            {
                UserName = user1,
                Contents = "Sound annotation with an AIFF track.",
                Rect     = new RectangleF(rc.Right, rc.Top, 24, 24),
                Icon     = SoundAnnotationIcon.Speaker,
                Color    = Color.Red,
                Sound    = SoundObject.FromFile(Path.Combine("Resources", "Sounds", "ding.aiff"), AudioFormat.Aiff)
            };

            page.Annotations.Add(aiffAnnot);

            // WAV sound annotation:
            ip = new PointF(rc.X, rc.Bottom + gap);
            rc = Common.Util.AddNote("A blue sound annotation is placed to the right of this note. Double click the icon to play the sound.",
                                     page, new RectangleF(ip.X, ip.Y, noteWidth, 100));
            var wavAnnot = new SoundAnnotation()
            {
                UserName = user2,
                Contents = "Sound annotation with a WAV track.",
                Rect     = new RectangleF(rc.Right, rc.Top, 24, 24),
                Icon     = SoundAnnotationIcon.Mic,
                Color    = Color.Blue,
                Sound    = SoundObject.FromFile(Path.Combine("Resources", "Sounds", "dong.wav"), AudioFormat.Wav)
            };

            page.Annotations.Add(wavAnnot);

            // Done:
            doc.Save(stream);
        }
Example #27
0
    //Exemple :  AudioManager.PlaySound(AudioManager.Sound.THEME_YouWin);
    public static void PlaySound(Sound sound)
    {
        if (!GameAssets.i)
        {
            Debug.LogWarning("NO AUDIO MANAGER ON SCENE");
            return;
        }

        GameAssets.SoundAudioClip soundParameters = GameAssets.i.GetAudioClip(sound);

        if (soundParameters == null)
        {
            return;
        }

        GameObject  soundGameObject = new GameObject("Sound");
        AudioSource audioSource     = soundGameObject.AddComponent <AudioSource>();

        float volume = 1f;

        switch (soundParameters.volumeMultiplier.mode)
        {
        case ParticleSystemCurveMode.Constant:
            if (soundParameters.volumeMultiplier.constant > 0)
            {
                volume = soundParameters.volumeMultiplier.constant;
            }
            break;

        case ParticleSystemCurveMode.TwoConstants:
            volume = Random.Range(soundParameters.volumeMultiplier.constantMin, soundParameters.volumeMultiplier.constantMax);
            break;
        }

        float pitch = 1f;

        switch (soundParameters.pitch.mode)
        {
        case ParticleSystemCurveMode.Constant:
            if (soundParameters.pitch.constant > 0)
            {
                pitch = soundParameters.pitch.constant;
            }
            break;

        case ParticleSystemCurveMode.TwoConstants:
            pitch = Random.Range(soundParameters.pitch.constantMin, soundParameters.pitch.constantMax);
            break;
        }

        audioSource.volume = volume;
        audioSource.pitch  = pitch;
        audioSource.PlayOneShot(soundParameters.AudioClip);

        SoundObject soundObj = soundGameObject.AddComponent <SoundObject>();

        soundObj.SetAudioSource(audioSource);
    }
Example #28
0
 /// <summary>
 /// Plays the train animation.
 /// </summary>
 private void TriggerTrainApproach()
 {
     // Set camera to perspective to properly show train animation
     Camera.main.orthographic = false;
     // Play train animation
     m_trainAnimator.enabled = true;
     // Play train sound
     m_trainSound = Locator.GetSoundSystem().PlaySound(SoundInfo.SFXID.BALLOON_TRAIN);
 }
Example #29
0
 void ReturnToPool(SoundObject sound)
 {
     sound.Stop();
     sound.gameObject.name = "SoundObject";
     sound.transform.SetParent(pool_Parent);
     sound.SetVolume(1f);
     soundPool.Enqueue(sound);
     pool_Parent.name = "SoundPool (" + soundPool.Count.ToString() + ")";
 }
Example #30
0
 public void PlaySound(Vector3 position)
 {
     audioSource = GetComponent <AudioSource> ();
     if (soundObject == null)
     {
         soundObject = new SoundObject(audioSource.clip, "ExplosionSound", PlayerPrefsManager.Instance.GetEffectsVolume(), audioSource);
     }
     soundObject.PlaySound(position);
 }
Example #31
0
	public void PlaySoundByIndex(int anIndexNumber, Vector3 aPosition) {
		// make sure we're not trying to play a sound indexed higher than exists in the array
		if (anIndexNumber>soundObjectList.Count) {
			Debug.LogWarning ("BaseSoundController>Trying to do PlaySoundByIndex with invalid index number. Playing last sound in array, instead.");
			anIndexNumber = soundObjectList.Count-1;
		}
		
		tempSoundObj = (SoundObject)soundObjectList[anIndexNumber];
		tempSoundObj.PlaySound(aPosition);  
	}
Example #32
0
	void Start () {
		// we will grab the volume from PlayerPrefs when this script first starts
        if (gamePrefsName != "") {
            volume = PlayerPrefs.GetFloat(gamePrefsName+"_SFXVol");
        }
		Debug.Log ("BaseSoundController gets volume from prefs "+gamePrefsName+"_SFXVol at "+volume);
		soundObjectList = new ArrayList();
		
		// make sound objects for all of the sounds in GameSounds array
		foreach (AudioClip theSound in GameSounds) {
			tempSoundObj = new SoundObject(theSound, theSound.name, volume);
			soundObjectList.Add(tempSoundObj);
			totalSounds++;
		}
	}
Example #33
0
        private static void Game_OnGameLoad(EventArgs args)
        {
            if (!Player.IsChampion("Leblanc"))
            {
                return;
            }

            #region Menu

            Menu = new Menu("LeBlanc The Schemer", "LeBlanc", true);

            Orbwalker = Menu.AddOrbwalker();
            Menu.AddTargetSelector();

            var combo = new Combo();
            Menu.AddSubMenu(Combo.LocalMenu);

            var harass = new Harass();
            Menu.AddSubMenu(Harass.LocalMenu);

            var laneclear = new LaneClear();
            Menu.AddSubMenu(LaneClear.LocalMenu);

            var flee = new Flee();
            Menu.AddSubMenu(Flee.LocalMenu);

            var clone = new Clone();
            Menu.AddSubMenu(Clone.LocalMenu);

            var draw = Menu.AddMenu("Draw Settings", "Draw");
            draw.AddItem(new MenuItem("Draw0", "Draw Q Range").SetValue(new Circle(true, Color.Red, Q.Range)));
            draw.AddItem(new MenuItem("Draw1", "Draw W Range").SetValue(new Circle(false, Color.Red, W.Range)));
            draw.AddItem(new MenuItem("Draw2", "Draw E Range").SetValue(new Circle(true, Color.Purple, E.Range)));
            draw.AddBool("DrawCD", "Draw on CD");
            draw.AddBool("DamageIndicator", "Damage Indicator");

            var misc = Menu.AddMenu("Misc Settings", "Misc");

            var ks = new KillSteal();
            misc.AddSubMenu(KillSteal.LocalMenu);

            misc.AddBool("Interrupt", "Interrupt Spells");
            misc.AddBool("AntiGapcloser", "AntiGapCloser");
            misc.AddBool("Sounds", "Sounds");
            misc.AddBool("Troll", "Troll");

            Menu.AddToMainMenu();

            #endregion

            DamageIndicator.DamageToUnit = GetComboDamage;

            if (misc.Item("Sounds").GetValue<bool>())
            {
                var sound = new SoundObject(Resources.OnLoad);
                sound.Play();
            }

            Game.PrintChat(
                "<b><font color =\"#FFFFFF\">LeBlanc the Schemer by </font><font color=\"#0033CC\">Trees</font><font color =\"#FFFFFF\"> loaded!</font></b>");

            Drawing.OnDraw += Drawing_OnDraw;
            Interrupter2.OnInterruptableTarget += Interrupter2_OnInterruptableTarget;
            //Interrupter2_OnInterruptableTarget;
            AntiGapcloser.OnEnemyGapcloser += AntiGapcloser_OnEnemyGapcloser;
        }
Example #34
0
        public override void InitalizeGraphics(RenderSystem rs)
        {
            FileLocation fl = FileSystem.Instance.Locate("citybase.mesh", GameFileLocs.Model);
            cityBase = new Model(ModelManager.Instance.CreateInstance(rs, fl));
            cityBase.CurrentAnimation.Clear();
            cityBase.CurrentAnimation.Add(new NoAnimaionPlayer(Matrix.Scaling(2, 2, 0.25f) * Matrix.RotationX(-MathEx.PiOver2)));


            catching = new Model[2];
            catchingRelease = new Model[2];
            throwing = new Model[2];
            throwingPrepare = new Model[2];
            fear = new Model[2];
            idle = new Model[2];
            laugh = new Model[2];
            sleeping = new Model[2];
            stopped = new Model[2];
            wakeingUp = new Model[2];

            currentForm = Randomizer.GetRandomBool() ? 1 : 0;

            switch (Type)
            {
                case CityType.Oil:
                case CityType.Green:
                    {
                        NoAnimaionPlayer scaling = new NoAnimaionPlayer(Matrix.Scaling(0.67f, 0.67f, 0.67f));
                        #region Oil
                        fl = FileSystem.Instance.Locate("ch_oil_catch.mesh", GameFileLocs.Model);
                        catching[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catching[0].AnimationCompeleted += Animation_Completed;
                        catching[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_oil_catchrelease.mesh", GameFileLocs.Model);
                        catchingRelease[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catchingRelease[0].AnimationCompeleted += Animation_Completed;
                        catchingRelease[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_oil_throwrelease.mesh", GameFileLocs.Model);
                        throwing[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwing[0].AnimationCompeleted += Animation_Completed;
                        throwing[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_oil_throw.mesh", GameFileLocs.Model);
                        throwingPrepare[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwingPrepare[0].AnimationCompeleted += Animation_Completed;
                        throwingPrepare[0].CurrentAnimation.Insert(0, scaling);


                        fl = FileSystem.Instance.Locate("ch_oil_fear.mesh", GameFileLocs.Model);
                        fear[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        fear[0].AnimationCompeleted += Animation_Completed;
                        fear[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_oil_idle.mesh", GameFileLocs.Model);
                        idle[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        idle[0].AnimationCompeleted += Animation_Completed;
                        idle[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_oil_laugh.mesh", GameFileLocs.Model);
                        laugh[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        laugh[0].AnimationCompeleted += Animation_Completed;
                        laugh[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_oil_sleeping.mesh", GameFileLocs.Model);
                        sleeping[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        sleeping[0].AnimationCompeleted += Animation_Completed;
                        sleeping[0].CurrentAnimation.Insert(0, scaling);
                        sleeping[0].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_oil_stopped.mesh", GameFileLocs.Model);
                        stopped[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        stopped[0].AnimationCompeleted += Animation_Completed;
                        stopped[0].CurrentAnimation.Insert(0, scaling);
                        stopped[0].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_oil_wakeup.mesh", GameFileLocs.Model);
                        wakeingUp[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        wakeingUp[0].AnimationCompeleted += Animation_Completed;
                        wakeingUp[0].CurrentAnimation.Insert(0, scaling);
                        #endregion

                        #region Green

                        fl = FileSystem.Instance.Locate("ch_green_catch.mesh", GameFileLocs.Model);
                        catching[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catching[1].AnimationCompeleted += Animation_Completed;
                        catching[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_green_catchrelease.mesh", GameFileLocs.Model);
                        catchingRelease[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catchingRelease[1].AnimationCompeleted += Animation_Completed;
                        catchingRelease[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_green_throwrelease.mesh", GameFileLocs.Model);
                        throwing[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwing[1].AnimationCompeleted += Animation_Completed;
                        throwing[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_green_throw.mesh", GameFileLocs.Model);
                        throwingPrepare[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwingPrepare[1].AnimationCompeleted += Animation_Completed;
                        throwingPrepare[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_green_fear.mesh", GameFileLocs.Model);
                        fear[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        fear[1].AnimationCompeleted += Animation_Completed;
                        fear[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_green_idle.mesh", GameFileLocs.Model);
                        idle[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        idle[1].AnimationCompeleted += Animation_Completed;
                        idle[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_green_laugh.mesh", GameFileLocs.Model);
                        laugh[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        laugh[1].AnimationCompeleted += Animation_Completed;
                        laugh[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_green_sleeping.mesh", GameFileLocs.Model);
                        sleeping[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        sleeping[1].AnimationCompeleted += Animation_Completed;
                        sleeping[1].CurrentAnimation.Insert(0, scaling);
                        sleeping[1].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_green_stopped.mesh", GameFileLocs.Model);
                        stopped[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        stopped[1].AnimationCompeleted += Animation_Completed;
                        stopped[1].CurrentAnimation.Insert(0, scaling);
                        stopped[1].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_green_wakeup.mesh", GameFileLocs.Model);
                        wakeingUp[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        wakeingUp[1].AnimationCompeleted += Animation_Completed;
                        wakeingUp[1].CurrentAnimation.Insert(0, scaling);
                        #endregion
                        break;
                    }
                case CityType.Education:
                case CityType.Volience:
                    {

                        NoAnimaionPlayer scaling = new NoAnimaionPlayer(Matrix.Scaling(40, 40, 40));
                        #region Volience
                        fl = FileSystem.Instance.Locate("ch_volience_catch.mesh", GameFileLocs.Model);
                        catching[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catching[0].AnimationCompeleted += Animation_Completed;
                        catching[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_volience_catchrelease.mesh", GameFileLocs.Model);
                        catchingRelease[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catchingRelease[0].AnimationCompeleted += Animation_Completed;
                        catchingRelease[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_volience_throwrelease.mesh", GameFileLocs.Model);
                        throwing[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwing[0].AnimationCompeleted += Animation_Completed;
                        throwing[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_volience_throw.mesh", GameFileLocs.Model);
                        throwingPrepare[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwingPrepare[0].AnimationCompeleted += Animation_Completed;
                        throwingPrepare[0].CurrentAnimation.Insert(0, scaling);


                        fl = FileSystem.Instance.Locate("ch_volience_fear.mesh", GameFileLocs.Model);
                        fear[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        fear[0].AnimationCompeleted += Animation_Completed;
                        fear[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_volience_idle.mesh", GameFileLocs.Model);
                        idle[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        idle[0].AnimationCompeleted += Animation_Completed;
                        idle[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_volience_laugh.mesh", GameFileLocs.Model);
                        laugh[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        laugh[0].AnimationCompeleted += Animation_Completed;
                        laugh[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_volience_sleeping.mesh", GameFileLocs.Model);
                        sleeping[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        sleeping[0].AnimationCompeleted += Animation_Completed;
                        sleeping[0].CurrentAnimation.Insert(0, scaling);
                        sleeping[0].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_volience_stopped.mesh", GameFileLocs.Model);
                        stopped[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        stopped[0].AnimationCompeleted += Animation_Completed;
                        stopped[0].CurrentAnimation.Insert(0, scaling);
                        stopped[0].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_volience_wakeup.mesh", GameFileLocs.Model);
                        wakeingUp[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        wakeingUp[0].AnimationCompeleted += Animation_Completed;
                        wakeingUp[0].CurrentAnimation.Insert(0, scaling);
                        #endregion

                        scaling = new NoAnimaionPlayer(Matrix.Translation(0, -2.5f, 0) * Matrix.Scaling(40, 40, 40));
                        #region Education

                        fl = FileSystem.Instance.Locate("ch_school_catch.mesh", GameFileLocs.Model);
                        catching[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catching[1].AnimationCompeleted += Animation_Completed;
                        catching[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_school_catchrelease.mesh", GameFileLocs.Model);
                        catchingRelease[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catchingRelease[1].AnimationCompeleted += Animation_Completed;
                        catchingRelease[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_school_throwrelease.mesh", GameFileLocs.Model);
                        throwing[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwing[1].AnimationCompeleted += Animation_Completed;
                        throwing[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_school_throw.mesh", GameFileLocs.Model);
                        throwingPrepare[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwingPrepare[1].AnimationCompeleted += Animation_Completed;
                        throwingPrepare[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_school_fear.mesh", GameFileLocs.Model);
                        fear[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        fear[1].AnimationCompeleted += Animation_Completed;
                        fear[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_school_idle.mesh", GameFileLocs.Model);
                        idle[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        idle[1].AnimationCompeleted += Animation_Completed;
                        idle[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_school_laugh.mesh", GameFileLocs.Model);
                        laugh[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        laugh[1].AnimationCompeleted += Animation_Completed;
                        laugh[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_school_sleeping.mesh", GameFileLocs.Model);
                        sleeping[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        sleeping[1].AnimationCompeleted += Animation_Completed;
                        sleeping[1].CurrentAnimation.Insert(0, scaling);
                        sleeping[1].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_school_stopped.mesh", GameFileLocs.Model);
                        stopped[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        stopped[1].AnimationCompeleted += Animation_Completed;
                        stopped[1].CurrentAnimation.Insert(0, scaling);
                        stopped[1].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_school_wakeup.mesh", GameFileLocs.Model);
                        wakeingUp[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        wakeingUp[1].AnimationCompeleted += Animation_Completed;
                        wakeingUp[1].CurrentAnimation.Insert(0, scaling);
                        #endregion
                        break;
                    }
                case CityType.Disease:
                case CityType.Health:
                    {
                        NoAnimaionPlayer scaling = new NoAnimaionPlayer(Matrix.Scaling(50, 50, 50) * Matrix.RotationY(-MathEx.PiOver2));
                        #region Disease
                        fl = FileSystem.Instance.Locate("ch_virus_catch.mesh", GameFileLocs.Model);
                        catching[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catching[0].AnimationCompeleted += Animation_Completed;
                        catching[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_virus_catchRelease.mesh", GameFileLocs.Model);
                        catchingRelease[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catchingRelease[0].AnimationCompeleted += Animation_Completed;
                        catchingRelease[0].CurrentAnimation.Insert(0, scaling);


                        fl = FileSystem.Instance.Locate("ch_virus_throw.mesh", GameFileLocs.Model);
                        throwingPrepare[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwingPrepare[0].AnimationCompeleted += Animation_Completed;
                        throwingPrepare[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_virus_throwRelease.mesh", GameFileLocs.Model);
                        throwing[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwing[0].AnimationCompeleted += Animation_Completed;
                        throwing[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_virus_fear.mesh", GameFileLocs.Model);
                        fear[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        fear[0].AnimationCompeleted += Animation_Completed;
                        fear[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_virus_idle.mesh", GameFileLocs.Model);
                        idle[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        idle[0].AnimationCompeleted += Animation_Completed;
                        idle[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_virus_laugh.mesh", GameFileLocs.Model);
                        laugh[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        laugh[0].AnimationCompeleted += Animation_Completed;
                        laugh[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_virus_sleeping.mesh", GameFileLocs.Model);
                        sleeping[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        sleeping[0].AnimationCompeleted += Animation_Completed;
                        sleeping[0].CurrentAnimation.Insert(0, scaling);
                        sleeping[0].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_virus_stopped.mesh", GameFileLocs.Model);
                        stopped[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        stopped[0].AnimationCompeleted += Animation_Completed;
                        stopped[0].CurrentAnimation.Insert(0, scaling);
                        stopped[0].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_virus_wakeup.mesh", GameFileLocs.Model);
                        wakeingUp[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        wakeingUp[0].AnimationCompeleted += Animation_Completed;
                        wakeingUp[0].CurrentAnimation.Insert(0, scaling);
                        #endregion


                        scaling = new NoAnimaionPlayer(Matrix.Scaling(26, 26, 26));
                        #region Health

                        fl = FileSystem.Instance.Locate("ch_hospital_catch.mesh", GameFileLocs.Model);
                        catching[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catching[1].AnimationCompeleted += Animation_Completed;
                        catching[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_hospital_catchRelease.mesh", GameFileLocs.Model);
                        catchingRelease[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catchingRelease[1].AnimationCompeleted += Animation_Completed;
                        catchingRelease[1].CurrentAnimation.Insert(0, scaling);


                        fl = FileSystem.Instance.Locate("ch_hospital_throwRelease.mesh", GameFileLocs.Model);
                        throwing[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwing[1].AnimationCompeleted += Animation_Completed;
                        throwing[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_hospital_throw.mesh", GameFileLocs.Model);
                        throwingPrepare[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwingPrepare[1].AnimationCompeleted += Animation_Completed;
                        throwingPrepare[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_hospital_fear.mesh", GameFileLocs.Model);
                        fear[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        fear[1].AnimationCompeleted += Animation_Completed;
                        fear[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_hospital_idle.mesh", GameFileLocs.Model);
                        idle[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        idle[1].AnimationCompeleted += Animation_Completed;
                        idle[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_hospital_laugh.mesh", GameFileLocs.Model);
                        laugh[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        laugh[1].AnimationCompeleted += Animation_Completed;
                        laugh[1].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_hospital_sleeping.mesh", GameFileLocs.Model);
                        sleeping[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        sleeping[1].AnimationCompeleted += Animation_Completed;
                        sleeping[1].CurrentAnimation.Insert(0, scaling);
                        sleeping[1].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_hospital_stopped.mesh", GameFileLocs.Model);
                        stopped[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        stopped[1].AnimationCompeleted += Animation_Completed;
                        stopped[1].CurrentAnimation.Insert(0, scaling);
                        stopped[1].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_hospital_wakeup.mesh", GameFileLocs.Model);
                        wakeingUp[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        wakeingUp[1].AnimationCompeleted += Animation_Completed;
                        wakeingUp[1].CurrentAnimation.Insert(0, scaling);
                        #endregion
                        break;
                    }
                case CityType.Neutral:
                    {
                        NoAnimaionPlayer scaling = new NoAnimaionPlayer(Matrix.Scaling(0.67f, 0.67f, 0.67f));

                        #region Neutral
                        fl = FileSystem.Instance.Locate("ch_neutral_catch.mesh", GameFileLocs.Model);
                        catching[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catching[0].AnimationCompeleted += Animation_Completed;
                        catching[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_neutral_catchrelease.mesh", GameFileLocs.Model);
                        catchingRelease[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        catchingRelease[0].AnimationCompeleted += Animation_Completed;
                        catchingRelease[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_neutral_throwrelease.mesh", GameFileLocs.Model);
                        throwing[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwing[0].AnimationCompeleted += Animation_Completed;
                        throwing[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_neutral_throw.mesh", GameFileLocs.Model);
                        throwingPrepare[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        throwingPrepare[0].AnimationCompeleted += Animation_Completed;
                        throwingPrepare[0].CurrentAnimation.Insert(0, scaling);


                        fl = FileSystem.Instance.Locate("ch_neutral_fear.mesh", GameFileLocs.Model);
                        fear[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        fear[0].AnimationCompeleted += Animation_Completed;
                        fear[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_neutral_idle.mesh", GameFileLocs.Model);
                        idle[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        idle[0].AnimationCompeleted += Animation_Completed;
                        idle[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_neutral_laugh.mesh", GameFileLocs.Model);
                        laugh[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        laugh[0].AnimationCompeleted += Animation_Completed;
                        laugh[0].CurrentAnimation.Insert(0, scaling);

                        fl = FileSystem.Instance.Locate("ch_neutral_sleeping.mesh", GameFileLocs.Model);
                        sleeping[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        sleeping[0].AnimationCompeleted += Animation_Completed;
                        sleeping[0].CurrentAnimation.Insert(0, scaling);
                        sleeping[0].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_neutral_stopped.mesh", GameFileLocs.Model);
                        stopped[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        stopped[0].AnimationCompeleted += Animation_Completed;
                        stopped[0].CurrentAnimation.Insert(0, scaling);
                        stopped[0].AutoLoop = true;

                        fl = FileSystem.Instance.Locate("ch_neutral_wakeup.mesh", GameFileLocs.Model);
                        wakeingUp[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                        wakeingUp[0].AnimationCompeleted += Animation_Completed;
                        wakeingUp[0].CurrentAnimation.Insert(0, scaling);
                        #endregion

                        catching[1] = catching[0];
                        catchingRelease[1] = catchingRelease[0];
                        throwing[1] = throwing[0];
                        throwingPrepare[1] = throwingPrepare[0];
                        fear[1] = fear[0];
                        idle[1] = idle[0];
                        laugh[1] = laugh[0];
                        sleeping[1] = sleeping[0];
                        stopped[1] = stopped[0];
                        wakeingUp[1] = wakeingUp[0];

                        break;
                    }
            }

            Matrix wordTransform = Matrix.Scaling(2, 2, 2) * Matrix.RotationX(-MathEx.PIf / 5.0f) * Matrix.RotationY(MathEx.PIf - MathEx.PiOver4);
            wordTransform.TranslationValue = new Vector3(-200, 200, 200);

            happyWords = new Model[3];
            fl = FileSystem.Instance.Locate("pop_haha.mesh", GameFileLocs.Model);
            happyWords[0] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
            happyWords[0].CurrentAnimation.Clear();
            happyWords[0].CurrentAnimation.Add(new NoAnimaionPlayer(wordTransform));

            fl = FileSystem.Instance.Locate("pop_ouch.mesh", GameFileLocs.Model);
            happyWords[1] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
            happyWords[1].CurrentAnimation.Clear();
            happyWords[1].CurrentAnimation.Add(new NoAnimaionPlayer(wordTransform));


            fl = FileSystem.Instance.Locate("pop_yeah.mesh", GameFileLocs.Model);
            happyWords[2] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
            happyWords[2].CurrentAnimation.Clear();
            happyWords[2].CurrentAnimation.Add(new NoAnimaionPlayer(wordTransform));

            fl = FileSystem.Instance.Locate("pop_woot.mesh", GameFileLocs.Model);
            ouchWord = new Model(ModelManager.Instance.CreateInstance(rs, fl));
            ouchWord.CurrentAnimation.Clear();
            ouchWord.CurrentAnimation.Add(new NoAnimaionPlayer(wordTransform));


            wordTransform = Matrix.Scaling(1.67f, 1.67f, 1.67f) * Matrix.RotationX(-MathEx.PIf / 5.0f) * Matrix.RotationY(MathEx.PIf - MathEx.PiOver4);
            wordTransform.TranslationValue = new Vector3(-200, 200, 200);

            fl = FileSystem.Instance.Locate("pop_levelup.mesh", GameFileLocs.Model);
            levelUpWord = new Model(ModelManager.Instance.CreateInstance(rs, fl));
            levelUpWord.CurrentAnimation.Clear();
            levelUpWord.CurrentAnimation.Add(new NoAnimaionPlayer(wordTransform));

            smoke = new Smokes(this, rs);
            splashSmoke = new SplashSmokes(this, rs);
            ChangeState(CityState.Sleeping);

            sound = SoundManager.Instance.MakeSoundObjcet("snore", null, CityRadius * 2.5f);
            sound.Position = position;

            const float SoundRadius = 1500;


            popSound = (Normal3DSoundObject)SoundManager.Instance.MakeSoundObjcet("pop", null, SoundRadius);
            popSound.Position = position;

            laughSound = new Normal3DSoundObject[2];
            fearSound = new Normal3DSoundObject[2];
            switch (Type)
            {
                case CityType.Green:
                case CityType.Oil:
                    laughSound[0] = (Normal3DSoundObject)SoundManager.Instance.MakeSoundObjcet("oil_laugh", null, SoundRadius);
                    fearSound[0] = (Normal3DSoundObject)SoundManager.Instance.MakeSoundObjcet("oil_fear", null, SoundRadius);
                    laughSound[0].Position = position;
                    fearSound[0].Position = position;

                    laughSound[1] = (Normal3DSoundObject)SoundManager.Instance.MakeSoundObjcet("green_laugh", null, SoundRadius);
                    laughSound[1].Position = position;
                   
                    break;
                case CityType.Neutral:
                    fearSound[0] = (Normal3DSoundObject)SoundManager.Instance.MakeSoundObjcet("neutral_fear", null, SoundRadius);
                    fearSound[0].Position = position;
                    fearSound[1] = fearSound[0];
                    break;
                case CityType.Education:
                case CityType.Volience:
                    laughSound[0] = (Normal3DSoundObject)SoundManager.Instance.MakeSoundObjcet("volience_laugh", null, SoundRadius);
                    fearSound[0] = (Normal3DSoundObject)SoundManager.Instance.MakeSoundObjcet("volience_fear", null, SoundRadius);
                    laughSound[0].Position = position;
                    fearSound[0].Position = position;
                    break;
                case CityType.Disease:
                case CityType.Health:
                    laughSound[1] = (Normal3DSoundObject)SoundManager.Instance.MakeSoundObjcet("hosp_laugh", null, SoundRadius);
                    fearSound[1] = (Normal3DSoundObject)SoundManager.Instance.MakeSoundObjcet("hosp_fear", null, SoundRadius);
                    laughSound[1].Position = position;
                    fearSound[1].Position = position;
                    break;
            }
        }
Example #35
0
        public override void InitalizeGraphics(RenderSystem rs)
        {

            ForestInfo info;
            info.Latitude = Latitude;
            info.Longitude = Longitude;
            info.Radius = Radius;

            info.Amount = CurrentAmount;

            //info.Plants = TreeModelLibrary.Instance.Get(0);

            model = TreeBatchModelManager.Instance.CreateInstance(rs, info);

            model.Touch();

            Transformation = model.GetWeakResource().Transformation;
            BoundingSphere = model.GetWeakResource().BoundingVolume;

            sound = SoundManager.Instance.MakeSoundObjcet("forest", null, BoundingSphere.Radius);
            sound.Position = BoundingSphere.Center;

            {
                float radLng = MathEx.Degree2Radian(Longitude);
                float radLat = MathEx.Degree2Radian(Latitude);

                float alt = TerrainData.Instance.QueryHeight(radLng, radLat);

                stdPosition = PlanetEarth.GetPosition(radLng, radLat, alt * TerrainMeshManager.PostHeightScale + PlanetEarth.PlanetRadius);

                stdTransform = PlanetEarth.GetOrientation(radLng, radLat);
                stdTransform.TranslationValue = stdPosition;


                selectionSphere.Center = stdPosition;
                selectionSphere.Radius = 200;
            }

            FileLocation fl = FileSystem.Instance.Locate("wooden_board_green.mesh", GameFileLocs.Model);

            board = new Model(ModelManager.Instance.CreateInstance(rs, fl));
            board.CurrentAnimation.Clear();
            board.CurrentAnimation.Add(
                new NoAnimaionPlayer(
                    Matrix.Translation(0, 0, 25) *
                    Matrix.Scaling(2.7f, 2.7f, 2.7f) *
                    Matrix.RotationX(-MathEx.PiOver2) *
                    Matrix.RotationY((-MathEx.PIf * 7.0f) / 8.0f)
                    ));

        }
Example #36
0
        public override void InitalizeGraphics(RenderSystem rs) 
        {

            float radLng = MathEx.Degree2Radian(Longitude);
            float radLat = MathEx.Degree2Radian(Latitude);

            bool isOcean = false;

            float alt = TerrainData.Instance.QueryHeight(radLng, radLat);

            if (alt < 0)
            {
                alt = 0;
                isOcean = true;
            }

            frameIdx = Randomizer.GetRandomInt(FrameCount - 1);

            float scale = Game.ObjectScale * 3.7f;// 2.2f;
            if (isOcean)
            {
                model = new Model[FrameCount];
                for (int i = 0; i < FrameCount; i++)
                {
                    FileLocation fl = FileSystem.Instance.Locate("oilderricksea" + i.ToString("D2") + ".mesh", GameFileLocs.Model);

                    model[i] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                    model[i].CurrentAnimation.Clear();
                    model[i].CurrentAnimation.Add(new NoAnimaionPlayer(
                        Matrix.Scaling(scale, scale, scale) * Matrix.Translation(0, 18, 0) * Matrix.RotationY(-MathEx.PiOver4)));
                }
            }
            else
            {
                model = new Model[FrameCount];
                for (int i = 0; i < FrameCount; i++)
                {
                    FileLocation fl = FileSystem.Instance.Locate("oilderrick" + i.ToString("D2") + ".mesh", GameFileLocs.Model);

                    model[i] = new Model(ModelManager.Instance.CreateInstance(rs, fl));
                    model[i].CurrentAnimation.Clear();
                    model[i].CurrentAnimation.Add(new NoAnimaionPlayer(
                        Matrix.Scaling(scale, scale, scale) * Matrix.RotationY(-MathEx.PiOver4)));
                }

            }



            Position = PlanetEarth.GetPosition(radLng, radLat, PlanetEarth.PlanetRadius + alt * TerrainMeshManager.PostHeightScale);
            BoundingSphere.Center = position;

            BoundingSphere.Radius = 200;
            Orientation = PlanetEarth.GetOrientation(radLng, radLat);

            sound = SoundManager.Instance.MakeSoundObjcet("oil", null, BoundingSphere.Radius * 8.0f / 3.0f);
            sound.Position = position;
          
            
            FileLocation fl2 = FileSystem.Instance.Locate("wooden_board_oil.mesh", GameFileLocs.Model);

            board = new Model(ModelManager.Instance.CreateInstance(rs, fl2));
            board.CurrentAnimation.Clear();
            board.CurrentAnimation.Add(
                new NoAnimaionPlayer(
                    Matrix.Translation(-50, 25, 23) *
                    Matrix.Scaling(2.7f, 2.7f, 2.7f) *
                    Matrix.RotationX(-MathEx.PiOver2) *
                    Matrix.RotationY((-MathEx.PIf * 7.0f) / 8.0f)
                    ));
        }