Example #1
0
 public void Play(Sound sound)
 {
     if (AudioIsEnabled)
     {
         sound.SoundEffect.Play(standardVolume, 0.0f, 0.0f);
     }
 }
Example #2
0
        public void Play(Sound sound, float fadeTime = 0f)
        {
            StopAllCoroutines();
            CachedAudioSource.Stop();

            CurrentSound = sound;
            Volume = fadeTime == 0f ? VolumeFromSettings : 0f;

            CachedAudioSource.clip = sound.audioClip;
            CachedAudioSource.loop = sound.loop;
            CachedAudioSource.pitch = Random.Range(sound.minPitch, sound.maxPitch);
            CachedAudioSource.spatialBlend = sound.spatialBlend;
            CachedAudioSource.volume = sound.volume;
            CachedAudioSource.loop = sound.loop;

            CachedAudioSource.Play();

            //TODO dont relly on this
            CachedAudioSource.spatialBlend = 0;

            if (fadeTime > 0f) SetVolumeTo(VolumeFromSettings, fadeTime);

            isPlaying = true;
            PlayEvent(this);
        }
Example #3
0
        public Pause(TimeGuardianGame game, LevelBase level)
        {
            _level = level;
            _game = game;

            x = -500;

            Sprite background = new Sprite(UtilStrings.SpritesPause + "background_pause.png");
            background.SetOrigin(0,background.height/2);
            background.y = game.height/2;

            Sprite header = new Sprite(UtilStrings.SpritesPause + "header_pause.png");
            header.SetOrigin(header.width/2, header.height/2);
            header.SetXY(background.width/2, 200);

            _buttons = new[]
            {
            new Button(UtilStrings.SpritesPause + "button_resume.png", 2, background.width/2, 350, "Resume"),
            new Button(UtilStrings.SpritesPause + "button_restart.png", 2, background.width/2, 450, _level.GetLevelName()),
            new Button(UtilStrings.SpritesPause + "button_exit.png", 2, background.width/2, 550, "MainMenu")
            };

            AddChild(background);
            AddChild(header);
            foreach (Button button in _buttons)
            {
                AddChild(button);
            }

            _selectedSound = new Sound(UtilStrings.SoundsMenu + "sound_selected.wav");
            _openSound = new Sound(UtilStrings.SoundsMenu + "sound_pause.wav");
        }
Example #4
0
    /// <summary>
    /// 指定されたエフェクト音を再生します
    /// ループするかどうかも一応指定できます
    /// </summary>
    /// <param name="effect"></param>
    public static void PlayEffect(Sound.Effect effect, bool loop = false)
    {
        if (manager == null) return;

        AudioClip clip = Sound.GetEffect(effect);
        if (clip == null) return;

        bool result = false;

        for(var i = 0;i < effectSources.Count;i++)
        {
            if (effectSources[i].isPlaying) continue;
            else
            {
                effectSources[i].clip = clip;
                effectSources[i].loop = loop;
                effectSources[i].Play();
                result = true;
                break;
            }
        }

        if(!result)
        {
            var source = manager.gameObject.AddComponent<AudioSource>();
            effectSources.Add(source);
            source.clip = clip;
            source.loop = loop;
            source.Play();
        }
    }
Example #5
0
 //UPDATE & DRAW
 public void Update(List<Player> liste_joueurs, List<IA> liste_ias, List<Projectile> liste_projectiles, Sound sons)
 {
     foreach (IA ia in liste_ias)
     {
         if (reffroidissement == 0 && munition > 0)
         {
             if (ia.IATexture.Contains((int)centre().X, (int)ia.IATexture.Y))
             {
                 if (ia.IATexture.Y < turretTexture.Y)
                     liste_projectiles.Add(new Projectile(Ressources.Projectile, (int)centre().X - 5, (int)centre().Y - 5, 10, Direction.Up, 50));
                 else
                     liste_projectiles.Add(new Projectile(Ressources.Projectile, (int)centre().X - 5, (int)centre().Y - 5, 10, Direction.Down, 50));
                 reffroidissement = 10;
                 munition--;
                 sons.PlaySentryShoot();
             }
             else if (ia.IATexture.Contains((int)ia.IATexture.X, (int)centre().Y))
             {
                 if (ia.IATexture.X < turretTexture.X)
                     liste_projectiles.Add(new Projectile(Ressources.Projectile, (int)centre().X - 5, (int)centre().Y - 5, 10, Direction.Left, 50));
                 else
                     liste_projectiles.Add(new Projectile(Ressources.Projectile, (int)centre().X - 5, (int)centre().Y - 5, 10, Direction.Right, 50));
                 reffroidissement = 10;
                 munition--;
                 sons.PlaySentryShoot();
             }
         }
     }
     if (reffroidissement > 0)
     {
         reffroidissement--;
     }
 }
Example #6
0
 private static Sound LoadSound(System.IO.UnmanagedMemoryStream memoryStream)
 {
     Sound sound = new Sound();
     sound.player = new System.Media.SoundPlayer() { Stream = memoryStream };
     sound.player.Load();
     return sound;
 }
Example #7
0
        public static void InitSound()
        {
            stage1 = new Bgm("/Application/resourses/stage1.mp3");
            stage1boss = new Bgm("/Application/resourses/stage1boss.mp3");
            title = new Bgm("/Application/resourses/title.mp3");
            gameover = new Bgm("/Application/resourses/gameover.mp3");

            bgmPlayer = stage1.CreatePlayer();

            sound = new Sound("/Application/resourses/shot.wav");
            shot = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/hidan.wav");
            hidan = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/siren.wav");
            siren = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/stageClear.wav");
            stageClear = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/system1.wav");
            ok = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/system2.wav");
            cancel = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/damage.wav");
            tekihidan = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/skillSE1.wav");
            skill1 = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/skillSE2.wav");
            skill2 = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/stageClear.wav");
            stageClear = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/tick.wav");
            ticktuck = sound.CreatePlayer();
        }
 public SoundRecord(Sound.Type soundType, float effectiveSoundLevel, Vector3 location)
 {
     this.soundType = soundType;
     this.effectiveSoundLevel = effectiveSoundLevel;
     this.location = location;
     this.timeHeard = Time.time;
 }
 /// <summary>
 /// Plays a sound by name.
 /// </summary>
 /// <param name="soundName">The sound to play</param>
 public void PlaySound(Sound sound, bool isSoundOff, bool isPauseMusicZune)
 {
     if (isSoundOff || !isPauseMusicZune)
         return;
     // If the sound exists, start it
     sound.Play();
 }
Example #10
0
        private void InitializeButtonEvents()
        {
            DialogShowButton.ButtonAction += (sender, e) =>
            {
                CustomDialog dialog = new CustomDialog();
                dialog.Show();
            };

            PopupListShowButton.ButtonAction += (sender, e) =>
            {
                Sound se = new Sound("/Application/assets/GAME_SE_01.wav");
                sp = se.CreatePlayer();
                sp.Play();
            };

            bgmButton.ButtonAction += (sender, e) =>
            {
                if (!bgm_play)
                {
                    bp.Play();
                    bgmButton.Text = "BGMStop";
                }
                else
                {
                    bp.Pause();
                    bgmButton.Text = "BGMPlay";
                }
                bgm_play = !bgm_play;
            };
        }
Example #11
0
        public SuperXbloxGame()
        {
            Content.RootDirectory = "Content";
            graphics = new GraphicsDeviceManager(this);
            graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);

            mSound = new Sound(this);
            particleManager = new ParticleManager(this);
            screenManager = new ScreenManager(this);
            reticule = new Reticule(this);
            reticule2 = new Reticule(this);

            Components.Add(mSound);//0
            Components.Add(screenManager);//1
            Components.Add(particleManager);//2
            //Components.Add(reticule); //3
            //Components.Add(reticule2); //4

            //Storage.LoadSettings();
            //Components.Add(smokePlume);

            //BEGIN Xbox Live Test
            Components.Add(new GamerServicesComponent(this));//5
            //END Xbox Live TEST
        }
 public void initSoundConfig(ContentManager content, String soundConfigFile, String musicConfigFile)
 {
     soundPrototypes = new Dictionary<String, Sound>();
     songPrototypes = new Dictionary<String, Song>();
     XDocument soundDoc = XDocument.Load(soundConfigFile);
     List<XElement> sounds = soundDoc.Element("Sounds").Elements("Sound").ToList();
     XDocument musicDoc = XDocument.Load(musicConfigFile);
     List<XElement> songs = musicDoc.Element("Songs").Elements("Song").ToList();
     String soundClass;
  
     SoundEffect effect;
     String songName;
     String songPath;
     Song actualSong;
     foreach (XElement sound in sounds)
     {
         soundClass = sound.Attribute("className").Value;
         effect = content.Load<SoundEffect>(sound.Attribute("filePath").Value);
         soundPrototypes[soundClass] = new Sound(effect);
     }
     foreach (XElement song in songs)
     {
         songName = song.Attribute("name").Value;
         songPath = song.Attribute("filePath").Value;
         actualSong = content.Load<Song>("StainedGlassAndSpookySkeletons");
         //actualSong = content.Load<Song>(song.Attribute("filepath").Value);
         songPrototypes[songName] = actualSong;
     }
 }
Example #13
0
 private void btnPlay_Click(object sender, EventArgs e)
 {
     if (channel != null && channel.IsPlaying)
         return;
     sound = fmod.CreateSound(MP3_PATH);
     channel = fmod.PlaySound(sound);
 }
Example #14
0
	void Start () {
		enabled = true;
        //find the camera object and obtain its script
        cameraObject = GameObject.Find("Main Camera");
		CameraScript = cameraObject.GetComponent<CameraFollow>();
		//initialize the object in control to be the head at first
		inControl = GameObject.Find("Player");
		ClosestLimb = FindClosestLimb();
		//collect all the objects with tags "leg" and "arm" in 
		//data structures
		Legs = GameObject.FindGameObjectsWithTag("leg");
		Arms = GameObject.FindGameObjectsWithTag("arm");
		//merge the two arrays into one

		player = GameObject.FindGameObjectWithTag("Player");
        sounds = player.GetComponent<Sound>();
        for (int i = 0; i < Legs.Length; i++) 
		{
			Limbs.Add(Legs[i]);
		}

		for (int i = 0; i < Arms.Length; i++) 
		{
			Limbs.Add(Arms[i]);
		}
	}
Example #15
0
    public void Kill(bool gainExperience, bool playSound = true)
	{   
        stunTimer = 0;
		int rand = (int)UnityEngine.Random.Range(1, 40);
        if(playSound){
            if (rand == 36) {
                Sound sound = new Sound (transform.root.gameObject.GetComponent<AudioSource> (), "SFX/" + "WilhelmScream", 1f);
            } else {
                Sound sound = new Sound (transform.root.gameObject.GetComponent<AudioSource> (), "SFX/" + "Kill", 1f);
            }
        }
		
        if(gainExperience){
            PlayerManager.instance.AddExperience();
            GameObject soul = GameObject.Instantiate(SoulPrefab);
            soul.transform.position = transform.position;
        }

        Tile tile = enemyManager.GetTileOfEnemy(this);
        if(tile != null){
            tile.enemy = null;
        }

        StopAllCoroutines();
        LeanTween.cancel(gameObject);


        FallApart();
    }
Example #16
0
        public static string GetResourceName(Sound sound)
        {
            if (sound == Sound.IncomingMessage)
                return "VDesktope.Content.Sounds.incoming-message.mp3";

            return "";
        }
Example #17
0
    private float _volumeRatio = 1; // sound volume ratio

    #endregion Fields

    #region Constructors

    /**
     * INIT soundTrack, hook up controls
     *  @param soundObject: Sound
     *  @param gameObject: GameObject
     * 	@param onCompleteHandler: Delegate
     **/
    public SoundTrack(Sound soundObject, GameObject gameObject, Delegate onCompleteHandler=null)
    {
        _soundObj = soundObject;
        _channel = gameObject.AddComponent("AudioSource") as AudioSource;
        _channel.clip = _soundObj.clip;
        _complete = onCompleteHandler;
    }
Example #18
0
 /// <summary>
 /// Add new empty sound to list of cached sounds
 /// </summary>
 public void Add()
 {
     Sound newSound = new Sound();
     newSound.type = soundType;
     newSound.show = true;
     sounds.Add(newSound);
 }
Example #19
0
    /// <summary>
    /// Add sound to list of cached sounds
    /// </summary>
    /// <param name="sound"></param>
    public void Add (Sound sound)
	{
        if (!sounds.Contains(sound))
        {
            sound.type = soundType;
            sounds.Add(sound);
        }
	}
 /// <summary>
 /// Plays the specified sound.
 /// </summary>
 /// <param name="sound">The sound to play.</param>
 public void Play(Sound sound)
 {
     if (Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         this.player.Current = this.indexDictionary[sound];
         this.player.Play();
     }
 }
Example #21
0
 public Sound GetSound(string name)
 {
     if (!assets.ContainsKey(name))
     {
         assets[name] = new Sound(content.Load<SoundEffect>("Content/" + name));
     }
     return assets[name] as Sound;
 }
Example #22
0
 /// Creates a new sound, registers it, and gives it the properties specified
 public Sound NewSound(string soundName, bool loop=false, bool interrupts=false, Action<Sound> callback=null) {
     Sound sound = new Sound(soundName);
     RegisterSound(sound);
     sound.loop = loop;
     sound.interrupts = interrupts;
     sound.callback = callback;
     return sound;
 }
Example #23
0
		static void Main() {
			Timers timers = new Timers();
			Screen screen = new Screen();
			Keyboard keyboard = new Keyboard();
			Sound sound = new Sound();
			Chip8Emulator chip8 = new Chip8Emulator(timers, screen, keyboard, sound);
			Application.Run(new MainForm(chip8));
		}
Example #24
0
 /**
   <summary>Creates a new action within the given document context.</summary>
 */
 public PlaySound(
     Document context,
     Sound sound
     )
     : base(context, PdfName.Sound)
 {
     Sound = sound;
 }
Example #25
0
	public void playBGMusic( AudioClip audioClip, float volume, bool loop )
	{
		if( _bgSound == null )
			_bgSound = new Sound( this );

		_bgSound.loop = loop;
		StartCoroutine( _bgSound.playAudioClip( audioClip, AudioRolloffMode.Linear, volume, Vector3.zero ) );
	}
Example #26
0
        public static void Read(string path, Sound sound)
        {
            if (!File.Exists(path))
                return;

            File.SetAttributes(path, FileAttributes.Normal);

            try
            {
                Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read);
                Mp3Stream mp3 = new Mp3Stream(stream);

                if (!mp3.HasTags)
                {
                    stream.Close();
                    ComputeFromFileName(path, sound);
                    return;
                }

                //mp3.GetAudioStream().
                var tags = mp3.GetAllTags();

                foreach (var tag in tags)
                    if (tag != null)
                    {
                        if (string.IsNullOrWhiteSpace(tag.Artists.Value) && string.IsNullOrWhiteSpace(tag.Title.Value))
                        {
                            ComputeFromFileName(path, sound);
                        }
                        else
                        {
                          byte[] input = null;

                          if (!string.IsNullOrWhiteSpace(tag.Title.Value))
                          {
                              input = tag.Title.Encode();
                              sound.title = ConvertEncoding(tag.Artists.Value, input, Id3TextEncoding.Iso8859_1);
                          }

                          if (!string.IsNullOrWhiteSpace(tag.Artists))
                          {
                              input = tag.Artists.Encode();
                              sound.artist = ConvertEncoding(tag.Artists.Value, input, Id3TextEncoding.Iso8859_1);
                          }
                        }

                        GetPicture(tag);
                        //int.TryParse(tag.BeatsPerMinute.Value, out modelView.duration);
                        break;
                    }
                stream.Close();

            }//try
            catch (Exception)
            {
                ComputeFromFileName(path, sound);
            }
        }
Example #27
0
    private void BallHit()
	{
		Sound sound = new Sound (transform.root.gameObject.GetComponent<AudioSource> (), "SFX/" + "Fire");
        Camera.main.transform.parent.GetComponent<CameraShaker>().Shake(0.20f, 0.25f);

        fireBlast_partcileSys.Play();
           Destroy(fireball);
        StartCoroutine(KillSelf());
    }
Example #28
0
 public PositionedSound(Cue cue, String cueName, string soundBankFile)
     : base()
 {
     mSound = new Sound(cue, cueName, soundBankFile);
     Variables = mSound.Variables;
     mSound.OnCueRetrieved += new Sound.OnCueRetrievedHandler(UpdateAudio);
     
     mEmitter = new AudioEmitter();
 }
Example #29
0
        public EnemyAiController(ActorModel actorModel, float attackRange, float velocity, Sound soundManager) {
            this._actorModel = actorModel;
            _attackRange = attackRange;
            _velocity = velocity;
			this.soundManager = soundManager;

            PickAiType();
            ResetDecisionTimer();
        }
Example #30
0
        /// <summary>
        /// Sets the screen up (UI components, multimedia content, etc.)
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            lovelySound = ResourceManager.CreateSound("lovelySound");
            Button btn = new Button("Pretty button. Touch me to play!");
            btn.Released += btn_Released;
            AddComponent(btn, 10, 300);
        }
        void InitPlayerWidgets()
        {
            var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs());

            Widget diplomacy = null;

            diplomacy = Game.LoadWidget(world, "DIPLOMACY", playerWidgets, new WidgetArgs
            {
                { "onExit", () => diplomacy.Visible = false }
            });
            var diplomacyButton = playerWidgets.Get <ButtonWidget>("INGAME_DIPLOMACY_BUTTON");

            diplomacyButton.OnClick = () => diplomacy.Visible ^= true;
            int validPlayers = 0;

            validPlayers = world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant).Count();
            diplomacyButton.IsVisible = () => validPlayers > 0;

            Widget cheats = null;

            cheats = Game.LoadWidget(world, "CHEATS_PANEL", playerWidgets, new WidgetArgs
            {
                { "onExit", () => cheats.Visible = false }
            });
            var cheatsButton = playerWidgets.Get <ButtonWidget>("CHEATS_BUTTON");

            cheatsButton.OnClick   = () => cheats.Visible ^= true;
            cheatsButton.IsVisible = () => world.LobbyInfo.GlobalSettings.AllowCheats;

            var iop = world.WorldActor.TraitsImplementing <IObjectivesPanel>().FirstOrDefault();

            if (iop != null && iop.ObjectivesPanel != null)
            {
                var objectivesButton = playerWidgets.Get <ButtonWidget>("OBJECTIVES_BUTTON");
                var objectivesWidget = Game.LoadWidget(world, iop.ObjectivesPanel, playerWidgets, new WidgetArgs());
                objectivesButton.Visible  = true;
                objectivesButton.OnClick += () => objectivesWidget.Visible ^= true;
            }

            bool          radarActive = false;
            RadarBinState binState    = RadarBinState.Closed;
            var           radarBin    = playerWidgets.Get <SlidingContainerWidget>("INGAME_RADAR_BIN");

            radarBin.IsOpen     = () => radarActive || binState > RadarBinState.BinAnimating;
            radarBin.AfterOpen  = () => binState = RadarBinState.RadarAnimating;
            radarBin.AfterClose = () => binState = RadarBinState.Closed;

            var radarMap = radarBin.Get <RadarWidget>("RADAR_MINIMAP");

            radarMap.IsEnabled  = () => radarActive && binState >= RadarBinState.RadarAnimating;
            radarMap.AfterOpen  = () => binState = RadarBinState.Open;
            radarMap.AfterClose = () => binState = RadarBinState.BinAnimating;

            radarBin.Get <ImageWidget>("RADAR_BIN_BG").GetImageCollection = () => "chrome-" + world.LocalPlayer.Country.Race;

            var powerManager = world.LocalPlayer.PlayerActor.Trait <PowerManager>();
            var powerBar     = radarBin.Get <ResourceBarWidget>("POWERBAR");

            powerBar.IndicatorCollection = "power-" + world.LocalPlayer.Country.Race;
            powerBar.GetProvided         = () => powerManager.PowerProvided;
            powerBar.GetUsed             = () => powerManager.PowerDrained;
            powerBar.TooltipFormat       = "Power Usage: {0}/{1}";
            powerBar.GetBarColor         = () =>
            {
                if (powerManager.PowerState == PowerState.Critical)
                {
                    return(Color.Red);
                }
                if (powerManager.PowerState == PowerState.Low)
                {
                    return(Color.Orange);
                }
                return(Color.LimeGreen);
            };

            var cachedRadarActive = false;
            var sidebarTicker     = playerWidgets.Get <LogicTickerWidget>("SIDEBAR_TICKER");

            sidebarTicker.OnTick = () =>
            {
                // Update radar bin
                radarActive = world.ActorsWithTrait <ProvidesRadar>()
                              .Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);

                if (radarActive != cachedRadarActive)
                {
                    Sound.PlayNotification(world.Map.Rules, null, "Sounds", (radarActive ? "RadarUp" : "RadarDown"), null);
                }
                cachedRadarActive = radarActive;

                // Switch to observer mode after win/loss
                if (world.LocalPlayer.WinState != WinState.Undefined)
                {
                    Game.RunAfterTick(() =>
                    {
                        playerRoot.RemoveChildren();
                        InitObserverWidgets();
                    });
                }
            };
        }
 private void AddSoundComponent(Sound sound)
 {
     sound.source        = gameObject.AddComponent <AudioSource> ();
     sound.source.clip   = sound.clip;
     sound.source.volume = sound.volume;
 }
Example #33
0
        public void pitPresentTest()
        {
            Sound test5 = new Sound();

            test5.pitPresent();
        }
Example #34
0
        public bool OnCommand(Character chr, string args)
        {
            try
            {
                //if (chr.cmdWeight > 3)
                //{
                //    chr.WriteToDisplay("Command weight limit exceeded. Shoot command not processed.");
                //    return true;
                //}

                if (args == null || args == "")
                {
                    chr.WriteToDisplay("Shoot what?");
                    return(true);
                }

                // weapon in right hand is returning and not a bow
                if (chr.RightHand != null && chr.RightHand.returning && chr.RightHand.skillType != Globals.eSkillType.Bow)
                {
                    return(CommandTasker.ParseCommand(chr, "throw", chr.RightHand.name + " at " + args));
                }
                else if (chr.LeftHand != null && chr.LeftHand.returning && chr.LeftHand.skillType != Globals.eSkillType.Bow) // weapon in left hand is returning and not a bow
                {
                    return(CommandTasker.ParseCommand(chr, "throw", chr.LeftHand.name + " at " + args));
                }

                // determine what weapon is being shot
                Item weapon = null;

                // bow in right hand is nocked or autofire (returning)
                if (chr.RightHand != null && chr.RightHand.RequiresOneFreeHandToShoot() && (chr.RightHand.IsNocked || chr.RightHand.returning))
                {
                    if (chr.GetFirstFreeHand() != (int)Globals.eWearOrientation.Left)
                    {
                        chr.WriteToDisplay("Your left hand must be empty to shoot " + chr.RightHand.shortDesc + ".");
                        return(true);
                    }

                    weapon = chr.RightHand; goto ShootBowOrSling;
                }// else if bow in left hand is nocked (check for returning bow (autofire is done above)
                else if (chr.LeftHand != null && chr.LeftHand.RequiresOneFreeHandToShoot() && (chr.LeftHand.IsNocked || chr.LeftHand.returning))
                {
                    if (chr.GetFirstFreeHand() != (int)Globals.eWearOrientation.Right)
                    {
                        chr.WriteToDisplay("Your right hand must be empty to shoot " + chr.LeftHand.shortDesc + ".");
                        return(true);
                    }

                    weapon = chr.LeftHand; goto ShootBowOrSling;
                }

                foreach (Item item in chr.wearing)
                {
                    if (item.baseType == Globals.eItemBaseType.Bow)
                    {
                        weapon = item;
                        break;
                    }
                }

                if (weapon != null && (weapon.baseType == Globals.eItemBaseType.Bow || weapon.baseType == Globals.eItemBaseType.Sling))
                {
                    goto ShootBowOrSling;
                }

                // one hand is empty, check belt for throwable weapon

                if (weapon == null)
                {
                    int firstFreeHand = chr.GetFirstFreeHand();

                    if (firstFreeHand != (int)Globals.eWearOrientation.None)
                    {
                        #region One hand is not empty, check belt for throwable weapon.
                        foreach (Item beltItem in new System.Collections.Generic.List <Item>(chr.beltList))
                        {
                            foreach (string thrownFromBelt in Item.ThrowFromBelt)
                            {
                                if (beltItem.name == thrownFromBelt)
                                {
                                    string notifyMessage = "";

                                    switch (firstFreeHand)
                                    {
                                    case 1:
                                        if (chr.LeftHand != null && (chr.LeftHand.skillType == Globals.eSkillType.Bow || chr.LeftHand.baseType == Globals.eItemBaseType.Sling) && !chr.LeftHand.IsNocked)
                                        {
                                            notifyMessage = "Your " + chr.LeftHand.name + " is not nocked. ";
                                        }
                                        break;

                                    case 2:
                                        if (chr.RightHand != null && (chr.RightHand.skillType == Globals.eSkillType.Bow || chr.RightHand.baseType == Globals.eItemBaseType.Sling) && !chr.RightHand.IsNocked)
                                        {
                                            notifyMessage = "Your " + chr.RightHand.name + " is not nocked. ";
                                        }
                                        break;

                                    default:
                                        break;
                                    }
                                    chr.WriteToDisplay(notifyMessage + "You throw " + beltItem.shortDesc + " from your belt.");
                                    return(CommandTasker.ParseCommand(chr, "throw", beltItem.name + " at " + args));
                                }
                            }
                        }
                        #endregion
                    }
                }

                // last resort, use any item in the left then right hand that is not a shooting weapon such as a bow or sling
                if (chr.LeftHand != null && !chr.LeftHand.RequiresOneFreeHandToShoot())
                {
                    return(CommandTasker.ParseCommand(chr, "throw", chr.LeftHand.name + " at " + args));
                }
                else if (chr.RightHand != null && chr.RightHand.RequiresOneFreeHandToShoot())
                {
                    return(CommandTasker.ParseCommand(chr, "throw", chr.RightHand.name + " at " + args));
                }

                if (weapon == null)
                {
                    chr.WriteToDisplay("You do not have a weapon ready to shoot.");
                    return(true);
                }

ShootBowOrSling:

                if (weapon == null)
                {
                    chr.WriteToDisplay("You do not have a weapon ready to shoot.");
                    return(true);
                }

                if (weapon.skillType == Globals.eSkillType.Bow || weapon.baseType == Globals.eItemBaseType.Sling)
                {
                    string nocking = weapon.baseType == Globals.eItemBaseType.Sling ? "loading" : "nocking";
                    string nocked  = weapon.baseType == Globals.eItemBaseType.Sling ? "loaded" : "nocked";

                    if (!weapon.returning && chr.CommandsProcessed.Contains(CommandTasker.CommandType.Nock))
                    {
                        chr.WriteToDisplay("You are still " + nocking + " your " + weapon.name + ".");
                        return(true);
                    }

                    if (!weapon.IsNocked && !weapon.returning)
                    {
                        chr.WriteToDisplay("The " + weapon.name + " is not " + nocked + ".");
                        return(true);
                    }

                    // wrist xbow is a hands item
                    if (chr.GetFirstFreeHand() == (int)Globals.eWearOrientation.None && weapon != null && weapon.wearLocation != Globals.eWearLocation.Hands)
                    {
                        chr.WriteToDisplay("You must have one empty hand to shoot a " + Utils.FormatEnumString(weapon.baseType.ToString()).ToLower() + ".");
                        return(true);
                    }
                }

                #region Check if weapon is attuned
                if (chr.IsPC && weapon.IsAttunedToOther(chr))
                {
                    chr.CurrentCell.Add(weapon);
                    chr.WriteToDisplay("The " + weapon.name + " leaps from your hand!");

                    if (weapon == chr.RightHand)
                    {
                        chr.UnequipRightHand(weapon);
                    }
                    else
                    {
                        chr.UnequipLeftHand(weapon);
                    }
                    return(true);
                }
                #endregion

                #region Check alignment of weapon
                if (!weapon.AlignmentCheck(chr))
                {
                    if (!weapon.name.ToLower().Contains("crossweapon") && !weapon.longDesc.ToLower().Contains("crossweapon"))
                    {
                        weapon.IsNocked = false;
                    }
                    chr.CurrentCell.Add(weapon);
                    chr.WriteToDisplay("The " + weapon.name + " singes your hand and falls to the ground!");
                    if (weapon == chr.RightHand)
                    {
                        chr.UnequipRightHand(weapon);
                    }
                    else
                    {
                        chr.UnequipLeftHand(weapon);
                    }
                    Combat.DoDamage(chr, chr, Rules.RollD(1, 4), false);
                    return(true);
                }
                #endregion

                string[] sArgs = args.Split(" ".ToCharArray());

                Character target;

                if (sArgs.Length == 2 && char.IsNumber(sArgs[0].ToCharArray()[0]))
                {
                    target = GameSystems.Targeting.TargetAquisition.FindTargetInView(chr, sArgs[1], Convert.ToInt32(sArgs[0]));
                }
                else
                {
                    target = GameSystems.Targeting.TargetAquisition.FindTargetInView(chr, sArgs[0], false, chr.IsImmortal);
                }

                if (target == null)
                {
                    chr.WriteToDisplay(GameSystems.Text.TextManager.NullTargetMessage(args));
                    return(true);
                }

                chr.CommandType = CommandTasker.CommandType.Shoot;

                Combat.DoCombat(chr, target, weapon);

                // Possible double attack if returning weapon.
                if (weapon != null && weapon.returning)
                {
                    Combat.CheckDoubleAttack(chr, target, weapon);
                }

                if (chr.LeftHand != null && chr.LeftHand.returning)
                {
                    Combat.CheckDualWield(chr, target, chr.LeftHand);
                }

                // Implemented check for "returning" bows (crossbows) which are auto-nock.
                if (weapon != null)
                {
                    if (weapon == chr.RightHand && !chr.RightHand.returning)
                    {
                        chr.RightHand.IsNocked = false;
                    }
                    else if (weapon == chr.LeftHand && !chr.LeftHand.returning)
                    {
                        chr.LeftHand.IsNocked = false;
                    }
                    else if (weapon.wearLocation == Globals.eWearLocation.Hands && !weapon.returning)
                    {
                        weapon.IsNocked = false;
                    }
                    else if (weapon.returning) // auto-nocking sound
                    {
                        if (weapon.name == "crossbow" || weapon.longDesc.ToLower().Contains("crossbow"))
                        {
                            chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.NockCrossbow));
                        }
                        else if (weapon.name.Contains("bow")) // should there be auto-nocking bows that don't have a mechanism?
                        {
                            chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.NockBow));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Utils.LogException(e);
                return(false);
            }

            return(true);
        }
 public SoundHolder(Sound sound, string soundName)
 {
     this.sound     = sound;
     this.soundName = soundName;
 }
Example #36
0
        public void ResolveOrder(Actor self, Order order)
        {
            if (order.OrderString == "PlaceBuilding" || order.OrderString == "LineBuild")
            {
                self.World.AddFrameEndTask(w =>
                {
                    var prevItems = GetNumBuildables(self.Owner);

                    if (order.TargetActor.IsDead())
                    {
                        return;
                    }

                    var unit  = self.World.Map.Rules.Actors[order.TargetString];
                    var queue = order.TargetActor.TraitsImplementing <ProductionQueue>()
                                .FirstOrDefault(q => q.CanBuild(unit) && q.CurrentItem() != null && q.CurrentItem().Item == order.TargetString && q.CurrentItem().RemainingTime == 0);

                    if (queue == null)
                    {
                        return;
                    }


                    var buildingInfo = unit.Traits.Get <BuildingInfo>();

                    if (order.OrderString == "LineBuild")
                    {
                        var playSounds = true;
                        foreach (var t in BuildingUtils.GetLineBuildCells(w, order.TargetLocation, order.TargetString, buildingInfo))
                        {
                            var building = w.CreateActor(order.TargetString, new TypeDictionary
                            {
                                new LocationInit(t),
                                new OwnerInit(order.Player),
                                new RaceInit(queue.Race)
                            });

                            if (playSounds)
                            {
                                foreach (var s in buildingInfo.BuildSounds)
                                {
                                    Sound.PlayToPlayer(order.Player, s, building.CenterPosition);
                                }
                            }

                            playSounds = false;
                        }
                    }
                    else
                    {
                        if (!self.World.CanPlaceBuilding(order.TargetString, buildingInfo, order.TargetLocation, null) ||
                            !buildingInfo.IsCloseEnoughToBase(self.World, order.Player, order.TargetString, order.TargetLocation))
                        {
                            return;
                        }

                        var building = w.CreateActor(order.TargetString, new TypeDictionary
                        {
                            new LocationInit(order.TargetLocation),
                            new OwnerInit(order.Player),
                            new RaceInit(queue.Race),
                        });

                        foreach (var s in buildingInfo.BuildSounds)
                        {
                            Sound.PlayToPlayer(order.Player, s, building.CenterPosition);
                        }
                    }

                    PlayBuildAnim(self, unit);

                    queue.FinishProduction();

                    if (buildingInfo.RequiresBaseProvider)
                    {
                        // May be null if the build anywhere cheat is active
                        // BuildingInfo.IsCloseEnoughToBase has already verified that this is a valid build location
                        var producer = buildingInfo.FindBaseProvider(w, self.Owner, order.TargetLocation);
                        if (producer != null)
                        {
                            producer.Trait <BaseProvider>().BeginCooldown();
                        }
                    }

                    if (GetNumBuildables(self.Owner) > prevItems)
                    {
                        w.Add(new DelayedAction(10,
                                                () => Sound.PlayNotification(self.World.Map.Rules, order.Player, "Speech", "NewOptions", order.Player.Country.Race)));
                    }
                });
            }
        }
Example #37
0
        public void correctTest()
        {
            Sound test10 = new Sound();

            test10.correct();
        }
Example #38
0
        public void footstepsTest()
        {
            Sound test3 = new Sound();

            test3.footsteps();
        }
Example #39
0
        public void doorOpenedTest()
        {
            Sound test2 = new Sound();

            test2.doorOpened();
        }
Example #40
0
File: Player.cs Project: Dimmae/ACE
 public void HandleActionApplySoundEffect(Sound sound)
 {
     PlaySound(sound, Guid);
 }
Example #41
0
File: Player.cs Project: Dimmae/ACE
 /// <summary>
 /// Emits a sound at location sourceId and volume
 /// The client will perform sound attenuation / volume adjustment
 /// based on the listener distance from the origin of sourceId
 /// </summary>
 public void PlaySound(Sound sound, ObjectGuid sourceId, float volume = 1.0f)
 {
     Session.Network.EnqueueSend(new GameMessageSound(sourceId, sound, volume));
 }
Example #42
0
        static void PlayMusic()
        {
            var track = Rules.InstalledMusic.Random(Game.CosmeticRandom);

            Sound.PlayMusicThen(track.Value, PlayMusic);
        }
Example #43
0
    public GameOver()
    {
        //fonts
        fonts.AddFontFile("Gingerbread_House.ttf");
        fonts.AddFontFile("hazel_grace.ttf");
        font       = new Font(fonts.Families[0], 30);
        numberFont = new Font(fonts.Families[1], 50);

        _win1Sound = new Sound("winner.wav", false, false);
        _win2Sound = new Sound("Queen_laugh.wav", false, false);
        _press     = new Sound("menu.wav");

        _winner     = 0;
        _soundCheck = 0;

        //---------------------------------------------------------
        //                 Display players
        //----------------------------------------------------------

        if (Menu.playerID == 1 && _soundCheck == 0)  // If green player wins
        {
            _winner = 1;
            _win1Sound.Play();
            _soundCheck = 1;
        }
        else if (Menu.playerID == 2 && _soundCheck == 0) // If red player wins
        {
            _winner = 2;
            _win2Sound.Play();
            _soundCheck = 1;
        }

        //Player green big sprite
        _player1 = new Sprite("fluff_wins.png");
        AddChild(_player1);
        //_player1.SetScaleXY(1f, 0.95714285714f);
        _player1.visible = false;

        //Player red big sprite
        _player2 = new Sprite("queen_wins.png");
        AddChild(_player2);
        _player2.SetScaleXY(1f, 0.95714285714f);
        _player2.visible = false;

        //-------------------------------------------------
        //                    Buttons
        //-------------------------------------------------
        if (Menu.currentLevel != Menu.finalLevel)
        {
            _nextLevelButton = new Button();
            AddChild(_nextLevelButton);
            _nextLevelButton.SetScaleXY(0.5f, 0.60f);
            _nextLevelButton.x = (game.width / 2) - 480;
            _nextLevelButton.y = 253;
            _nextLevelButton.SetOrigin(_nextLevelButton.width / 2f, _nextLevelButton.height / 2f);
        }

        _restartButton = new Button();
        AddChild(_restartButton);
        _restartButton.SetScaleXY(0.5f, 0.60f);
        _restartButton.x = (game.width / 2) - 240;
        _restartButton.y = 253;
        _restartButton.SetOrigin(_restartButton.width / 2f, _restartButton.height / 2f);

        _menuButton = new Button();
        AddChild(_menuButton);
        _menuButton.SetScaleXY(0.5f, 0.60f);
        _menuButton.x = (game.width / 2);
        _menuButton.y = 253;
        _menuButton.SetOrigin(_menuButton.width / 2f, _menuButton.height / 2f);

        _exitButton = new Button();
        AddChild(_exitButton);
        _exitButton.SetScaleXY(0.5f, 0.60f);
        _exitButton.x = (game.width / 2) + 240;
        _exitButton.y = 253;
        _exitButton.SetOrigin(_exitButton.width / 2f, _exitButton.height / 2f);

        //TEXT
        _text = new Canvas(1280, 1005, false);
        AddChild(_text);

        if (Menu.currentLevel != Menu.finalLevel)
        {
            _text.graphics.DrawString("Next Level", font, Brushes.White, 131, 243);
        }
        _text.graphics.DrawString("Restart", font, Brushes.White, 390, 243);
        _text.graphics.DrawString("Menu", font, Brushes.White, 640, 243);
        _text.graphics.DrawString("Quit", font, Brushes.White, 882, 243);
    }
Example #44
0
        public void batsPresentTest()
        {
            Sound test4 = new Sound();

            test4.batsPresent();
        }
Example #45
0
    public Sound findSound(string name)
    {
        Sound s = Array.Find(sounds, sound => sound.name == name);

        return(s);
    }
    public void Play(string name)
    {
        Sound s = Array.Find(sounds, sound => sound.name == name);

        s.source.Play();
    }
Example #47
0
 private static void WriteRule(string rule)
 {
     Sound.Play(Properties.Resources.cink);
     Console.WriteLine("\n" + rule);
     System.Threading.Thread.Sleep(DelayBetweenRules);
 }
    public void Play(string name)
    {
        Sound s = Array.Find(narrativeQuestions, sound => sound.name == name);

        s.source.Play();
    }
Example #49
0
File: Player.cs Project: Dimmae/ACE
        /// <summary>
        /// Method used to perform the animation, sound, and vital update on consumption of food or potions
        /// </summary>
        /// <param name="consumableName">Name of the consumable</param>
        /// <param name="sound">Either Sound.Eat1 or Sound.Drink1</param>
        /// <param name="buffType">ConsumableBuffType.Spell,ConsumableBuffType.Health,ConsumableBuffType.Stamina,ConsumableBuffType.Mana</param>
        /// <param name="boostAmount">Amount the Vital is boosted by; can be null, if buffType = ConsumableBuffType.Spell</param>
        /// <param name="spellDID">Id of the spell cast by the consumable; can be null, if buffType != ConsumableBuffType.Spell</param>
        public void ApplyConsumable(string consumableName, Sound sound, ConsumableBuffType buffType, uint?boostAmount, uint?spellDID)
        {
            MotionCommand motionCommand;

            if (sound == Sound.Eat1)
            {
                motionCommand = MotionCommand.Eat;
            }
            else
            {
                motionCommand = MotionCommand.Drink;
            }

            // start the eat/drink motion
            var motion = new Motion(MotionStance.NonCombat, motionCommand);

            EnqueueBroadcastMotion(motion);

            var motionTable = DatManager.PortalDat.ReadFromDat <MotionTable>(MotionTableId);
            var animTime    = motionTable.GetAnimationLength(CurrentMotionState.Stance, motionCommand, MotionCommand.Ready);

            var actionChain = new ActionChain();

            actionChain.AddDelaySeconds(animTime);

            actionChain.AddAction(this, () =>
            {
                GameMessageSystemChat buffMessage;

                if (buffType == ConsumableBuffType.Spell)
                {
                    bool result = false;

                    uint spellId = spellDID ?? 0;

                    if (spellId != 0)
                    {
                        result = CreateSingleSpell(spellId);
                    }

                    if (result)
                    {
                        var spell   = new Server.Entity.Spell(spellId);
                        buffMessage = new GameMessageSystemChat($"{consumableName} applies {spell.Name} on you.", ChatMessageType.Craft);
                    }
                    else
                    {
                        buffMessage = new GameMessageSystemChat($"Consuming {consumableName} attempted to apply a spell not yet fully implemented.", ChatMessageType.System);
                    }
                }
                else
                {
                    CreatureVital creatureVital;
                    string vitalName;

                    // Null check for safety
                    if (boostAmount == null)
                    {
                        boostAmount = 0;
                    }

                    switch (buffType)
                    {
                    case ConsumableBuffType.Health:
                        creatureVital = Health;
                        vitalName     = "Health";
                        break;

                    case ConsumableBuffType.Mana:
                        creatureVital = Mana;
                        vitalName     = "Mana";
                        break;

                    default:
                        creatureVital = Stamina;
                        vitalName     = "Stamina";
                        break;
                    }

                    var vitalChange = UpdateVitalDelta(creatureVital, (uint)boostAmount);

                    buffMessage = new GameMessageSystemChat($"You regain {vitalChange} {vitalName}.", ChatMessageType.Craft);
                }

                var soundEvent = new GameMessageSound(Guid, sound, 1.0f);
                EnqueueBroadcast(soundEvent);

                Session.Network.EnqueueSend(buffMessage);

                // return to original stance
                var returnStance = new Motion(CurrentMotionState.Stance);
                EnqueueBroadcastMotion(returnStance);
            });

            actionChain.EnqueueChain();
        }
Example #50
0
        public static void DoImpact(WPos pos, WarheadInfo warhead, WeaponInfo weapon, Actor firedBy, float firepowerModifier)
        {
            var world      = firedBy.World;
            var targetTile = pos.ToCPos();

            if (!world.Map.IsInMap(targetTile))
            {
                return;
            }

            var isWater       = pos.Z == 0 && world.GetTerrainInfo(targetTile).IsWater;
            var explosionType = isWater ? warhead.WaterExplosion : warhead.Explosion;

            if (explosionType != null)
            {
                world.AddFrameEndTask(w => w.Add(new Explosion(w, pos, explosionType)));
            }

            Sound.Play(GetImpactSound(warhead, isWater), pos);

            var smudgeLayers = world.WorldActor.TraitsImplementing <SmudgeLayer>().ToDictionary(x => x.Info.Type);

            if (warhead.Size[0] > 0)
            {
                var resLayer = world.WorldActor.Trait <ResourceLayer>();
                var allCells = world.FindTilesInCircle(targetTile, warhead.Size[0]).ToList();

                // `smudgeCells` might want to just be an outer shell of the cells:
                IEnumerable <CPos> smudgeCells = allCells;
                if (warhead.Size.Length == 2)
                {
                    smudgeCells = smudgeCells.Except(world.FindTilesInCircle(targetTile, warhead.Size[1]));
                }

                // Draw the smudges:
                foreach (var sc in smudgeCells)
                {
                    var smudgeType = world.GetTerrainInfo(sc).AcceptsSmudgeType.FirstOrDefault(t => warhead.SmudgeType.Contains(t));
                    if (smudgeType == null)
                    {
                        continue;
                    }

                    SmudgeLayer smudgeLayer;
                    if (!smudgeLayers.TryGetValue(smudgeType, out smudgeLayer))
                    {
                        throw new NotImplementedException("Unknown smudge type `{0}`".F(smudgeType));
                    }

                    smudgeLayer.AddSmudge(sc);
                    if (warhead.Ore)
                    {
                        resLayer.Destroy(sc);
                    }
                }

                // Destroy all resources in range, not just the outer shell:
                foreach (var cell in allCells)
                {
                    if (warhead.Ore)
                    {
                        resLayer.Destroy(cell);
                    }
                }
            }
            else
            {
                var smudgeType = world.GetTerrainInfo(targetTile).AcceptsSmudgeType.FirstOrDefault(t => warhead.SmudgeType.Contains(t));
                if (smudgeType != null)
                {
                    SmudgeLayer smudgeLayer;
                    if (!smudgeLayers.TryGetValue(smudgeType, out smudgeLayer))
                    {
                        throw new NotImplementedException("Unknown smudge type `{0}`".F(smudgeType));
                    }

                    smudgeLayer.AddSmudge(targetTile);
                }
            }

            if (warhead.Ore)
            {
                world.WorldActor.Trait <ResourceLayer>().Destroy(targetTile);
            }

            switch (warhead.DamageModel)
            {
            case DamageModel.Normal:
            {
                var maxSpread = warhead.Spread * (float)Math.Log(Math.Abs(warhead.Damage), 2);
                var range     = new WRange((int)maxSpread * 1024 / Game.CellSize);
                var hitActors = world.FindActorsInCircle(pos, range);

                foreach (var victim in hitActors)
                {
                    var damage = (int)GetDamageToInflict(pos, victim, warhead, weapon, firepowerModifier);
                    victim.InflictDamage(firedBy, damage, warhead);
                }
            } break;

            case DamageModel.PerCell:
            {
                foreach (var t in world.FindTilesInCircle(targetTile, warhead.Size[0]))
                {
                    foreach (var unit in world.FindActorsInBox(t, t))
                    {
                        unit.InflictDamage(firedBy,
                                           (int)(warhead.Damage * warhead.EffectivenessAgainst(unit.Info)), warhead);
                    }
                }
            } break;
            }
        }
Example #51
0
        public void buttonPressedTest()
        {
            Sound test1 = new Sound();

            test1.buttonPressed();
        }
Example #52
0
 public static void PlaySound(this AudioSource source, Sound sound)
 {
     source.SetUpWithSound(sound);
     source.Play();
 }
Example #53
0
        public static void DoImpact(WPos pos, WarheadInfo warhead, WeaponInfo weapon, Actor firedBy, float firepowerModifier)
        {
            var world      = firedBy.World;
            var targetTile = world.Map.CellContaining(pos);

            if (!world.Map.Contains(targetTile))
            {
                return;
            }

            var isWater              = pos.Z <= 0 && world.Map.GetTerrainInfo(targetTile).IsWater;
            var explosionType        = isWater ? warhead.WaterExplosion : warhead.Explosion;
            var explosionTypePalette = isWater ? warhead.WaterExplosionPalette : warhead.ExplosionPalette;

            if (explosionType != null)
            {
                world.AddFrameEndTask(w => w.Add(new Explosion(w, pos, explosionType, explosionTypePalette)));
            }

            Sound.Play(GetImpactSound(warhead, isWater), pos);

            var smudgeLayers = world.WorldActor.TraitsImplementing <SmudgeLayer>().ToDictionary(x => x.Info.Type);
            var resLayer     = warhead.DestroyResources || !string.IsNullOrEmpty(warhead.AddsResourceType) ? world.WorldActor.Trait <ResourceLayer>() : null;

            if (warhead.Size[0] > 0)
            {
                var allCells = world.Map.FindTilesInCircle(targetTile, warhead.Size[0]).ToList();

                // `smudgeCells` might want to just be an outer shell of the cells:
                IEnumerable <CPos> smudgeCells = allCells;
                if (warhead.Size.Length == 2)
                {
                    smudgeCells = smudgeCells.Except(world.Map.FindTilesInCircle(targetTile, warhead.Size[1]));
                }

                // Draw the smudges:
                foreach (var sc in smudgeCells)
                {
                    var smudgeType = world.Map.GetTerrainInfo(sc).AcceptsSmudgeType.FirstOrDefault(t => warhead.SmudgeType.Contains(t));
                    if (smudgeType == null)
                    {
                        continue;
                    }

                    SmudgeLayer smudgeLayer;
                    if (!smudgeLayers.TryGetValue(smudgeType, out smudgeLayer))
                    {
                        throw new NotImplementedException("Unknown smudge type `{0}`".F(smudgeType));
                    }

                    smudgeLayer.AddSmudge(sc);
                    if (warhead.DestroyResources)
                    {
                        resLayer.Destroy(sc);
                    }
                }

                // Destroy all resources in range, not just the outer shell:
                if (warhead.DestroyResources)
                {
                    foreach (var cell in allCells)
                    {
                        resLayer.Destroy(cell);
                    }
                }

                // Splatter resources:
                if (!string.IsNullOrEmpty(warhead.AddsResourceType))
                {
                    var resourceType = world.WorldActor.TraitsImplementing <ResourceType>()
                                       .FirstOrDefault(t => t.Info.Name == warhead.AddsResourceType);

                    if (resourceType == null)
                    {
                        Log.Write("debug", "Warhead defines an invalid resource type '{0}'".F(warhead.AddsResourceType));
                    }
                    else
                    {
                        foreach (var cell in allCells)
                        {
                            if (!resLayer.CanSpawnResourceAt(resourceType, cell))
                            {
                                continue;
                            }

                            var splash = world.SharedRandom.Next(1, resourceType.Info.MaxDensity - resLayer.GetResourceDensity(cell));
                            resLayer.AddResource(resourceType, cell, splash);
                        }
                    }
                }
            }
            else
            {
                var smudgeType = world.Map.GetTerrainInfo(targetTile).AcceptsSmudgeType.FirstOrDefault(t => warhead.SmudgeType.Contains(t));
                if (smudgeType != null)
                {
                    SmudgeLayer smudgeLayer;
                    if (!smudgeLayers.TryGetValue(smudgeType, out smudgeLayer))
                    {
                        throw new NotImplementedException("Unknown smudge type `{0}`".F(smudgeType));
                    }

                    smudgeLayer.AddSmudge(targetTile);
                }
            }

            if (warhead.DestroyResources)
            {
                world.WorldActor.Trait <ResourceLayer>().Destroy(targetTile);
            }

            switch (warhead.DamageModel)
            {
            case DamageModel.Normal:
            {
                var maxSpread = new WRange((int)(warhead.Spread.Range * (float)Math.Log(Math.Abs(warhead.Damage), 2)));
                var hitActors = world.FindActorsInCircle(pos, maxSpread);

                foreach (var victim in hitActors)
                {
                    var damage = (int)GetDamageToInflict(pos, victim, warhead, weapon, firepowerModifier, true);
                    victim.InflictDamage(firedBy, damage, warhead);
                }
            }
            break;

            case DamageModel.PerCell:
            {
                foreach (var t in world.Map.FindTilesInCircle(targetTile, warhead.Size[0]))
                {
                    foreach (var unit in world.ActorMap.GetUnitsAt(t))
                    {
                        var damage = (int)GetDamageToInflict(pos, unit, warhead, weapon, firepowerModifier, false);
                        unit.InflictDamage(firedBy, damage, warhead);
                    }
                }
            }
            break;

            case DamageModel.HealthPercentage:
            {
                var range     = new WRange(warhead.Size[0] * 1024);
                var hitActors = world.FindActorsInCircle(pos, range);

                foreach (var victim in hitActors)
                {
                    var damage = GetDamageToInflict(pos, victim, warhead, weapon, firepowerModifier, false);
                    if (damage != 0)                                     // will be 0 if the target doesn't have HealthInfo
                    {
                        var healthInfo = victim.Info.Traits.Get <HealthInfo>();
                        damage = (float)(damage / 100 * healthInfo.HP);
                    }

                    victim.InflictDamage(firedBy, (int)damage, warhead);
                }
            }
            break;
            }
        }
Example #54
0
        public void shootArrowTest()
        {
            Sound test9 = new Sound();

            test9.shootArrow();
        }
Example #55
0
 // Start is called before the first frame update
 // Update is called once per frame
 void Update()
 {
     cat   = FindObjectOfType <Cat>();
     sound = FindObjectOfType <Sound>();
 }
Example #56
0
        public void gameLosingTest()
        {
            Sound test8 = new Sound();

            test8.gameLosing();
        }
Example #57
0
        public void gameWinningTest()
        {
            Sound test7 = new Sound();

            test7.gameWinning();
        }
Example #58
0
        public void wumpusPresentTest()
        {
            Sound test6 = new Sound();

            test6.wumpusPresent();
        }
    public void Stop(string name)
    {
        Sound s = Array.Find(sounds, sound => sound.name == name);

        s.source.Stop();
    }
Example #60
0
        public void incorrectTest()
        {
            Sound test11 = new Sound();

            test11.incorrect();
        }