private SoundInfo LoadSound(XElement soundNode, string basePath)
        {
            SoundInfo sound = new SoundInfo { Name = soundNode.RequireAttribute("name").Value };

            sound.Loop = soundNode.TryAttribute<bool>("loop");

            sound.Volume = soundNode.TryAttribute<float>("volume", 1);

            XAttribute pathattr = soundNode.Attribute("path");
            XAttribute trackAttr = soundNode.Attribute("track");
            if (pathattr != null)
            {
                sound.Type = AudioType.Wav;
                sound.Path = FilePath.FromRelative(pathattr.Value, basePath);
            }
            else if (trackAttr != null)
            {
                sound.Type = AudioType.NSF;

                int track;
                if (!trackAttr.Value.TryParse(out track) || track <= 0) throw new GameXmlException(trackAttr, "Sound track attribute must be an integer greater than zero.");
                sound.NsfTrack = track;

                sound.Priority = soundNode.TryAttribute<byte>("priority", 100);
            }
            else
            {
                sound.Type = AudioType.Unknown;
            }

            return sound;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PlaySoundGameAction" /> class.
 /// </summary>
 /// <param name="parent">The parent task.</param>
 /// <param name="soundInfo">The sound info to play</param>
 /// <param name="volume">The sound volume</param>
 /// <param name="loop">The sound loop is enabled</param>
 public PlaySoundGameAction(IGameAction parent, SoundInfo soundInfo, float volume = 1, bool loop = false)
     : base(parent, "PlaySoundGameAction" + instances++)
 {
     this.SoundInfo = soundInfo;
     this.volume = volume;
     this.loop = loop;
 }
        public static void CheckNewSoundInConfig(XElement element)
        {
            foreach (var child in element.Descendants("Sound"))
            {
                var keyCode = int.Parse(child.Attribute("keyCode").Value);
                var soundUri = new Uri(child.Attribute("path").Value, UriKind.Relative);

                string imageUri = string.Empty;
                if (child.Attribute("img") != null)
                {
                    imageUri = new Uri(child.Attribute("img").Value, UriKind.Relative).OriginalString;
                }
                var name = string.Empty;
                if (child.Attribute("name") != null)
                {
                    name = child.Attribute("name").Value;
                }

                if (!DataBaseService.Current.Db.Table<SoundInfo>().Any(s => s.Id == keyCode))
                {
                    var sound = new SoundInfo(keyCode, name, soundUri.OriginalString, imageUri);
                    DataBaseService.Current.Db.Insert(sound);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PlaySoundGameAction" /> class.
 /// </summary>
 /// <param name="soundInfo">The sound info to play</param>
 /// <param name="scene">The scene.</param>
 /// <param name="volume">The sound volume</param>
 /// <param name="loop">The sound loop is enabled</param>
 public PlaySoundGameAction(SoundInfo soundInfo, Scene scene = null, float volume = 1, bool loop = false)
     : base("PlaySoundGameAction" + instances++, scene)
 {
     this.SoundInfo = soundInfo;
     this.volume = volume;
     this.loop = loop;
 }
 public SoundEffectLoaderScene(AssetInfo assetInfo)
     : base(assetInfo)
 {
     var path = "Content/" + assetInfo.FileName;
     this.sound = new SoundInfo(path);
     this.uiColor = Color.White;
 }
Example #6
0
 public static void PlayerAudio(SoundInfo.SoundTypes type) {
     switch(type) {
         case SoundInfo.SoundTypes.PLAYER_MOVEMENT:
             int playerMovementCount = SoundController.instance.playerMovement.Count;
             if(playerMovementCount > 0) {
                 int randomMove = Random.Range(0, playerMovementCount);
                 AudioSource.PlayClipAtPoint(SoundController.instance.playerMovement[randomMove], Vector3.zero, 0.5f);
             }
             break;
     }
 }
Example #7
0
        public static AudioClip GetAudioType(SoundInfo.SoundTypes type) {
            int count = 0;
            switch(type) {
                case SoundInfo.SoundTypes.BLOCK_MOVEMENT:
                    count = SoundController.instance.blockMovement.Count;
                    if(count > 0) {
                        int random = Random.Range(0, count);
                        return SoundController.instance.blockMovement[random];
                    }
                    break;

                case SoundInfo.SoundTypes.PLAYER_MOVEMENT:
                    count = SoundController.instance.playerMovement.Count;
                    if(count > 0) {
                        int random = Random.Range(0, count);
                        return SoundController.instance.playerMovement[random];
                    }
                    break;

                case SoundInfo.SoundTypes.PLAYER_COLLISION:
                    count = SoundController.instance.playerCollision.Count;
                    if(count > 0) {
                        int random = Random.Range(0, count);
                        return SoundController.instance.playerCollision[random];
                    }
                    break;
					
				case SoundInfo.SoundTypes.PLAYER_STUNNED:
                    count = SoundController.instance.playerStunned.Count;
					if(count > 0){
						int random = Random.Range(0, count);
						return SoundController.instance.playerStunned[random];
					}
					break;

                case SoundInfo.SoundTypes.FIREWORK_EMIT:
                    count = SoundController.instance.fireworkEmit.Count;
                    if(count > 0) {
                        int random = Random.Range(0, count);
                        return SoundController.instance.fireworkEmit[random];
                    }
                    break;

                case SoundInfo.SoundTypes.FIREWORK_EXPLOSION:
                    count = SoundController.instance.fireworkExplosion.Count;
                    if(count > 0) {
                        int random = Random.Range(0, count);
                        return SoundController.instance.fireworkExplosion[random];
                    }
                    break;
            }
            return null;
        }
Example #8
0
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.MyScene);

            //Register bank
            SoundBank bank = new SoundBank(Assets);
            WaveServices.SoundPlayer.RegisterSoundBank(bank);

            //Register sounds
            MenuSound = new SoundInfo(WaveContent.Assets.Menu_wav);
            bank.Add(MenuSound);

            pistolSound = new SoundInfo(WaveContent.Assets.Pistol_wav);
            bank.Add(pistolSound);

            upgradeSound = new SoundInfo(WaveContent.Assets.Upgrade_wav);
            bank.Add(upgradeSound);

            sellSound = new SoundInfo(WaveContent.Assets.Sell_wav);
            bank.Add(sellSound);
        }
 private void cmbNotificationType_SelectedIndexChanged(object sender, EventArgs e)
 {
     //Friends Update
     //New Messages
     currentInfo = (NotificationHandler.NotificationInfoClass)cmbNotificationType.SelectedItem;
     this.chkPlaySound.Checked = (currentInfo.Options & NotificationHandler.Options.Sound) == NotificationHandler.Options.Sound;
     this.cmbSound.Enabled = (currentInfo.Options & NotificationHandler.Options.Sound) == NotificationHandler.Options.Sound;
     this.chkVibrate.Checked = (currentInfo.Options & NotificationHandler.Options.Vibrate) == NotificationHandler.Options.Vibrate;
     this.chkNotification.Checked = (currentInfo.Options & NotificationHandler.Options.Message) == NotificationHandler.Options.Message;
     if (!string.IsNullOrEmpty(currentInfo.Sound))
     {
         SoundInfo s = new SoundInfo();
         s.Path = currentInfo.Sound;
         this.cmbSound.SelectedItem = s;
     }
     else
     {
         this.cmbSound.SelectedIndex = 0;
         SetSoundInfo();
     }
 }
Example #10
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Black;

            //Register bank
            SoundBank bank = new SoundBank(Assets);
            WaveServices.SoundPlayer.RegisterSoundBank(bank);

            //Register sounds
            sound1 = new SoundInfo("Content/Menu.wpk");
            bank.Add(sound1);

            sound2 = new SoundInfo("Content/Pistol.wpk");
            bank.Add(sound2);

            sound3 = new SoundInfo("Content/Upgrade.wpk");
            bank.Add(sound3);

            sound4 = new SoundInfo("Content/Sell.wpk");
            bank.Add(sound4);
        }
Example #11
0
        // Token: 0x0600139E RID: 5022 RVA: 0x00096118 File Offset: 0x00094518
        public void FireEvent(Map map, IntVec3 strikeLoc)
        {
            if (!strikeLoc.IsValid)
            {
                strikeLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(map) && !map.roofGrid.Roofed(sq), map, 1000);
            }
            boltMesh = LightningBoltMeshPool.RandomBoltMesh;
            if (!strikeLoc.Fogged(map))
            {
                //    GenExplosion.DoExplosion(strikeLoc, map, 1.9f, DamageDefOf.Flame, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                Vector3 loc = this.strikeLoc.ToVector3Shifted();
                for (int i = 0; i < 4; i++)
                {
                    MoteMaker.ThrowSmoke(loc, map, 1.5f);
                    MoteMaker.ThrowMicroSparks(loc, map);
                    MoteMaker.ThrowLightningGlow(loc, map, 1.5f);
                }
            }
            SoundInfo info = SoundInfo.InMap(new TargetInfo(this.strikeLoc, map, false), MaintenanceType.None);

            SoundDefOf.Thunder_OnMap.PlayOneShot(info);
        }
Example #12
0
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.MyScene);

            //Register bank
            SoundBank bank = new SoundBank(Assets);

            WaveServices.SoundPlayer.RegisterSoundBank(bank);

            //Register sounds
            MenuSound = new SoundInfo(WaveContent.Assets.Menu_wav);
            bank.Add(MenuSound);

            pistolSound = new SoundInfo(WaveContent.Assets.Pistol_wav);
            bank.Add(pistolSound);

            upgradeSound = new SoundInfo(WaveContent.Assets.Upgrade_wav);
            bank.Add(upgradeSound);

            sellSound = new SoundInfo(WaveContent.Assets.Sell_wav);
            bank.Add(sellSound);
        }
Example #13
0
        public override void CompTick()
        {
            if (Props.secondsBetweenSteps <= 0.0f)
            {
                Log.ErrorOnce("CompLumbering :: CompProperties_Lumbering secondsBetweenSteps needs to be more than 0", 132);
            }
            if (Props.secondsPerStep <= 0.0f)
            {
                Log.ErrorOnce("CompLumbering :: CompProperties_Lumbering secondsPerStep needs to be more than 0", 133);
            }

            if (lumberer != null && Props.secondsPerStep > 0.0f && Find.TickManager.TicksGame > ticksToCycle)
            {
                if (lumberer.pather != null)
                {
                    if (lumberer.pather.MovingNow)
                    {
                        //Log.Message("1");
                        cycled       = !cycled;
                        ticksToCycle = Find.TickManager.TicksGame + GenTicks.SecondsToTicks(Props.secondsPerStep);
                        if (Props.sound != null)
                        {
                            Props.sound.PlayOneShot(SoundInfo.InMap(lumberer));
                        }
                        if (cycled)
                        {
                            //Log.Message("1a");
                            ResolveCycledGraphic();
                        }
                        else
                        {
                            //Log.Message("1b");
                            ResolveBaseGraphic();
                        }
                        lumberer.stances.StaggerFor(GenTicks.SecondsToTicks(Props.secondsBetweenSteps));
                    }
                }
            }
        }
Example #14
0
        /// <summary>
        /// Creates a new sound based with a particular name.
        /// If one already exists, returns the existing ID.
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public int CreateSound(string name)
        {
            // See if this texture has already been recorded
            SoundInfo soundInfo = null;
            int       maxID     = 0;

            foreach (SoundInfo info in mSounds)
            {
                if (info.Name == name)
                {
                    soundInfo = info;
                    break;
                }

                if (info.ID > maxID)
                {
                    maxID = info.ID;
                }
            }

            // If the texture has not been recorded, do so now.
            if (soundInfo == null)
            {
                // Open succeeded, now record the info.
                soundInfo = new SoundInfo();

                soundInfo.ID   = maxID + 1;
                soundInfo.Name = name;

                if (!soundInfo.Load())
                {
                    return(-1);
                }

                mSounds.Add(soundInfo);
            }

            return(soundInfo.ID);
        }
Example #15
0
    static MissileInfo()
    {
        foreach (var row in sheet)
        {
            if (row.id == -1)
            {
                continue;
            }

            row.spritesheetFilename = @"data\global\missiles\" + row.celFile;
            row.material            = row.trans == 0 ? Materials.normal : Materials.softAdditive;
            row.lifeTime            = row.range / 25.0f;
            row.explosionMissile    = Find(row.explosionMissileId);
            row.fps         = row.animSpeed * 1.5f;
            row.travelSound = SoundInfo.Find(row.travelSoundId);
            row.hitSound    = SoundInfo.Find(row.hitSoundId);
            row.progSound   = SoundInfo.Find(row.progSoundId);
            row.progOverlay = OverlayInfo.Find(row.progOverlayId);
            map.Add(row.missile, row);
            idMap.Add(row.id, row);
        }
    }
Example #16
0
    static SoundInfo()
    {
        for (int i = 0; i < sheet.Count; ++i)
        {
            var sound = sheet[i];
            if (sound.sound == null)
            {
                continue;
            }

            GatherVariations(sound, i);
            sound.volume           = sound._volume / 255f;
            sound.fadeInDuration   = sound._fadeIn / 25f;
            sound.fadeOutDuration  = sound._fadeOut / 25f;
            sound.compoundDuration = sound.compound / 25f;
            map.Add(sound.sound, sound);
        }

        itemPickup        = Find("item_pickup");
        itemFlippy        = Find("item_flippy");
        cursorButtonClick = Find("cursor_button_click");
    }
        public override void Notify_PawnKilled()
        {
            base.Pawn.equipment.DestroyAllEquipment(DestroyMode.Vanish);
            base.Pawn.apparel.DestroyAll(DestroyMode.Vanish);
            bool flag = !base.Pawn.Spawned;

            if (!flag)
            {
                bool flag2 = this.Props.mote != null || this.Props.fleck != null;
                if (flag2)
                {
                    Vector3 pos = base.Pawn.DrawPos;
                    for (int i = 0; i < this.Props.moteCount; i++)
                    {
                        Vector2 offset = Rand.InsideUnitCircle * this.Props.moteOffsetRange.RandomInRange * (float)Rand.Sign;
                        Vector3 myPos  = new Vector3(pos.x + offset.x, pos.y, pos.z + offset.y);
                        bool    flag3  = this.Props.mote != null;
                        if (flag3)
                        {
                            MoteMaker.MakeStaticMote(myPos, base.Pawn.Map, this.Props.mote, 1f);
                        }
                        else
                        {
                            FleckMaker.Static(myPos, base.Pawn.Map, this.Props.fleck, 1f);
                        }
                    }
                }
                bool flag4 = this.Props.filth != null;
                if (flag4)
                {
                    FilthMaker.TryMakeFilth(base.Pawn.Position, base.Pawn.Map, this.Props.filth, this.Props.filthCount, FilthSourceFlags.None);
                }
                bool flag5 = this.Props.sound != null;
                if (flag5)
                {
                    this.Props.sound.PlayOneShot(SoundInfo.InMap(base.Pawn, MaintenanceType.None));
                }
            }
        }
Example #18
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Black;

            //Register bank
            SoundBank bank = new SoundBank(Assets);

            WaveServices.SoundPlayer.RegisterSoundBank(bank);

            //Register sounds
            sound1 = new SoundInfo("Content/Menu.wpk");
            bank.Add(sound1);

            sound2 = new SoundInfo("Content/Pistol.wpk");
            bank.Add(sound2);

            sound3 = new SoundInfo("Content/Upgrade.wpk");
            bank.Add(sound3);

            sound4 = new SoundInfo("Content/Sell.wpk");
            bank.Add(sound4);
        }
        private void DoRangedAttack(LocalTargetInfo target)
        {
            bool flag = target.Cell != default(IntVec3);

            if (flag)
            {
                SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None);
                info.pitchFactor  = .7f;
                info.volumeFactor = 2f;
                TorannMagicDefOf.TM_AirWoosh.PlayOneShot(info);

                CellRect cellRect = CellRect.CenteredOn(target.Cell, 3);
                cellRect.ClipInsideMap(this.Pawn.Map);
                IntVec3 destination = cellRect.RandomCell;

                if (launchableThing != null && destination != null)
                {
                    float launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, destination)).ToAngleFlat();
                    for (int m = 0; m < 4; m++)
                    {
                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_ThickDust"), this.Pawn.Position.ToVector3Shifted(), this.Pawn.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(3f, 5f), launchAngle += Rand.Range(-25, 25), Rand.Range(0, 360));
                    }
                    FlyingObject_Spinning flyingObject = (FlyingObject_Spinning)GenSpawn.Spawn(ThingDef.Named("FlyingObject_Spinning"), this.Pawn.Position, this.Pawn.Map);
                    flyingObject.force = 1.4f;
                    flyingObject.Launch(this.Pawn, destination, this.launchableThing.SplitOff(1), Rand.Range(45, 65));
                }
                else if (launchableThing == null && destination != null)
                {
                    float launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, destination)).ToAngleFlat();
                    for (int m = 0; m < 4; m++)
                    {
                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_ThickDust"), this.Pawn.Position.ToVector3Shifted(), this.Pawn.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(3f, 5f), launchAngle += Rand.Range(-25, 25), Rand.Range(0, 360));
                    }
                    FlyingObject_Spinning flyingObject = (FlyingObject_Spinning)GenSpawn.Spawn(ThingDef.Named("FlyingObject_SpinningBone"), this.Pawn.Position, this.Pawn.Map);
                    flyingObject.force = 1.4f;
                    flyingObject.Launch(this.Pawn, destination, null, Rand.Range(120, 150));
                }
            }
        }
        private void ListSounds()
        {
            string[] Sounds = System.IO.Directory.GetFiles("\\Windows", "*.wav");
            List<string> SoundNames = new List<string>();

            foreach (string Sound in Sounds)
            {
                SoundNames.Add(Sound);
            }
            Sounds = System.IO.Directory.GetFiles("\\Windows", "*.wma");
            foreach (string Sound in Sounds)
            {
                SoundNames.Add(Sound);
            }
            SoundNames.Sort();
            foreach (string SoundName in SoundNames)
            {
                SoundInfo SoundI = new SoundInfo();
                SoundI.Path = SoundName;
                cmbSound.Items.Add(SoundI);
            }
        }
 public override void CompTick()
 {
     if (State == HibernatableStateDefOf.Starting && Find.TickManager.TicksGame > endStartupTick)
     {
         State          = HibernatableStateDefOf.Running;
         endStartupTick = 0;
         string str = ((parent.Map.Parent.GetComponent <EscapeShipComp>() == null) ? ((string)"LetterHibernateCompleteStandalone".Translate()) : ((string)"LetterHibernateComplete".Translate()));
         Find.LetterStack.ReceiveLetter("LetterLabelHibernateComplete".Translate(), str, LetterDefOf.PositiveEvent, new GlobalTargetInfo(parent));
     }
     if (State != HibernatableStateDefOf.Hibernating)
     {
         if (sustainer == null || sustainer.Ended)
         {
             sustainer = Props.sustainerActive.TrySpawnSustainer(SoundInfo.InMap(parent));
         }
         sustainer.Maintain();
     }
     else if (sustainer != null && !sustainer.Ended)
     {
         sustainer.End();
     }
 }
Example #22
0
        public override void EjectContents()

        {
            foreach (Thing current in this.innerContainer)
            {
                Pawn pawn = current as Pawn;
                if (pawn != null)
                {
                    if (this.IcookingTicking != IcookingTime)
                    {
                        PawnChanger.ExecuteBadThings(pawn);
                    }
                }
            }
            if (!base.Destroyed)
            {
                SoundDef.Named("CryptosleepCasketEject").PlayOneShot(SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None));
            }
            this.IcookingTicking = 0;
            ChangeColour(this.red);
            base.EjectContents();
        }
Example #23
0
        public static void LoadAll()
        {
            var sw = System.Diagnostics.Stopwatch.StartNew();

            Translation.Load();
            SoundInfo.Load();
            SoundEnvironment.Load();
            ObjectInfo.Load();
            BodyLoc.Load();
            ExpTable.Load();
            LevelType.Load();
            LevelWarpInfo.Load();
            LevelPreset.Load();
            LevelMazeInfo.Load();
            LevelInfo.Load();
            OverlayInfo.Load();
            MissileInfo.Load();
            ItemStat.Load();
            ItemRatio.Load();
            ItemType.Load();
            ItemPropertyInfo.Load();
            ItemSet.Load();
            UniqueItem.Load();
            SetItem.Load();
            TreasureClass.Load();
            MagicAffix.Load();
            CharStatsInfo.Load();
            MonLvl.Load();
            MonPreset.Load();
            MonSound.Load();
            MonStatsExtended.Load();
            MonStat.Load();
            SuperUnique.Load();
            SkillDescription.Load();
            SkillInfo.Load();
            SpawnPreset.Load();
            StateInfo.Load();
            Debug.Log("All txt files loaded in " + sw.ElapsedMilliseconds + " ms");
        }
Example #24
0
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.MyScene);

            //Register bank
            SoundBank bank = new SoundBank(Assets);

            WaveServices.SoundPlayer.RegisterSoundBank(bank);

            //Register sounds
            this.menuSound = new SoundInfo(WaveContent.Assets.Menu_wav);
            bank.Add(menuSound);

            this.pistolSound = new SoundInfo(WaveContent.Assets.Pistol_wav);
            bank.Add(pistolSound);

            this.upgradeSound = new SoundInfo(WaveContent.Assets.Upgrade_wav);
            bank.Add(upgradeSound);

            this.sellSound = new SoundInfo(WaveContent.Assets.Sell_wav);
            bank.Add(sellSound);

            StackPanel controlPanel = new StackPanel()
            {
                VerticalAlignment   = WaveEngine.Framework.UI.VerticalAlignment.Center,
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                Margin      = new WaveEngine.Framework.UI.Thickness(0, 0, 30, 30),
                BorderColor = Color.White,
                IsBorder    = true,
            };

            this.AddButton("Play Menu", this.menuSound, controlPanel);
            this.AddButton("Play Pistol", this.pistolSound, controlPanel);
            this.AddButton("Play Upgrade", this.upgradeSound, controlPanel);
            this.AddButton("Play Sell", this.sellSound, controlPanel);

            EntityManager.Add(controlPanel);
        }
Example #25
0
    static SkillInfo()
    {
        foreach (var row in sheet)
        {
            if (row.id == -1)
            {
                continue;
            }

            row.name        = Translation.Find("skillname" + row.id);
            row.castOverlay = OverlayInfo.Find(row.castOverlayId);
            row.startSound  = SoundInfo.Find(row._stsound);
            if (row._range == "none")
            {
                row.range = Range.NoRestrictions;
            }
            else if (row._range == "h2h")
            {
                row.range = Range.Melee;
            }
            else if (row._range == "rng")
            {
                row.range = Range.Ranged;
            }
            else if (row._range == "both")
            {
                row.range = Range.Both;
            }
            else
            {
                throw new System.Exception("Unknown skill range " + row._range);
            }
            map.Add(row.skill, row);
            idMap.Add(row.id, row);
        }

        Attack = Find("Attack");
    }
        public override void SpawnSetup()
        {
            base.SpawnSetup();

            ToolsForHaulUtility.CartTurret.Add(this);

            if (mountableComp.Driver != null && IsCurrentlyMotorized())
            {
                LongEventHandler.ExecuteWhenFinished(delegate
                {
                    SoundInfo info = SoundInfo.InWorld(this);
                    mountableComp.sustainerAmbient = vehicleComp.compProps.soundAmbient.TrySpawnSustainer(info);
                });
            }

            if (mountableComp.Driver != null)
            {
                mountableComp.Driver.RaceProps.makesFootprints = false;

                if (mountableComp.Driver.RaceProps.Humanlike)
                {
                    mountableComp.driverComp = new CompDriver {
                        vehicle = this
                    };
                    mountableComp.Driver.AllComps?.Add(mountableComp.driverComp);
                    mountableComp.driverComp.parent = mountableComp.Driver;
                }
            }

            //if (allowances == null)
            //{
            //    allowances = new ThingFilter();
            //    allowances.SetFromPreset(StorageSettingsPreset.DefaultStockpile);
            //    allowances.SetFromPreset(StorageSettingsPreset.DumpingStockpile);
            //}

            LongEventHandler.ExecuteWhenFinished(UpdateGraphics);
        }
Example #27
0
 public static bool Cleanup(Sustainer __instance)
 {
     if (__instance.def.subSounds.Count > 0)
     {
         Find.SoundRoot.sustainerManager.DeregisterSustainer(__instance);
         lock (subSustainers(__instance))
         {
             for (int index = 0; index < subSustainers(__instance).Count; ++index)
             {
                 subSustainers(__instance)[index].Cleanup();
             }
         }
     }
     if (__instance.def.sustainStopSound != null)
     {
         lock (worldRootObject(__instance))
         {
             if (worldRootObject(__instance) != null)
             {
                 Map map = __instance.info.Maker.Map;
                 if (map != null)
                 {
                     __instance.def.sustainStopSound.PlayOneShot(SoundInfo.InMap(new TargetInfo(worldRootObject(__instance).transform.position.ToIntVec3(), map, false), MaintenanceType.None));
                 }
             }
             else
             {
                 __instance.def.sustainStopSound.PlayOneShot(SoundInfo.OnCamera(MaintenanceType.None));
             }
         }
         if (worldRootObject(__instance) != null)
         {
             UnityEngine.Object.Destroy(worldRootObject(__instance));
         }
     }
     DebugSoundEventsLog.Notify_SustainerEnded(__instance, __instance.info);
     return(false);
 }
Example #28
0
    private static void LoadArmorInfo()
    {
        foreach (var item in armorSheet)
        {
            if (item._code == null)
            {
                continue;
            }

            item.code           = item._code;
            item.cost           = item._cost;
            item.gambleCost     = item._gambleCost;
            item.flippyFile     = item._flippyFile;
            item.invFile        = item._invFile;
            item.invWidth       = item._invWidth;
            item.invHeight      = item._invHeight;
            item.level          = item._level;
            item.levelReq       = item._levelReq;
            item.armor          = item;
            item.name           = Translation.Find(item.nameStr);
            item.type1Code      = item._type1;
            item.type2Code      = item._type2;
            item.component      = item._component;
            item.alternateGfx   = item._alternateGfx;
            item.dropSound      = SoundInfo.Find(item._dropSound);
            item.dropSoundFrame = item._dropSoundFrame;
            item.useSound       = SoundInfo.Find(item._useSound);
            item.alwaysUnique   = item._alwaysUnique;
            item.normCode       = item._normCode;
            item.uberCode       = item._uberCode;
            item.ultraCode      = item._ultraCode;

            if (!byCode.ContainsKey(item.code))
            {
                byCode.Add(item.code, item);
            }
        }
    }
Example #29
0
        /// <summary>
        /// Called when [record button clicked].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void OnRecordButtonClicked(object sender, EventArgs e)
        {
            if (!WaveServices.Microphone.IsConnected)
            {
                return;
            }

            if (!WaveServices.Microphone.IsRecording)
            {
                this.recordButton.Text                 = STOPTEXT;
                this.progressBar.IsVisible             = true;
                this.progressBar.Value                 = 0;
                WaveServices.Microphone.DataAvailable += this.Microphone_DataAvailable;
                WaveServices.Microphone.Start(RECORDFILE);
            }
            else
            {
                this.recordButton.Text = STARTTEXT;
                WaveServices.Microphone.Stop();
                WaveServices.Microphone.DataAvailable -= this.Microphone_DataAvailable;

                //Register sounds

                if ((this.sound != null) && (this.sound.SoundEffect != null))
                {
                    this.sound.SoundEffect.Unload();
                    WaveServices.Assets.Global.UnloadAsset(RECORDFILE);
                }

                this.sound = new SoundInfo(RECORDFILE);
                var stream = WaveServices.Storage.OpenStorageFile(RECORDFILE, WaveEngine.Common.IO.FileMode.Open);
                this.sound.SoundEffect = WaveServices.Assets.Global.LoadAsset <SoundEffect>(RECORDFILE, stream);
                this.bank.AddWithouthLoad(this.sound);

                this.playButton.IsVisible  = true;
                this.progressBar.IsVisible = false;
            }
        }
        private SoundInfo LoadSound(XElement soundNode, string basePath)
        {
            SoundInfo sound = new SoundInfo {
                Name = soundNode.RequireAttribute("name").Value
            };

            sound.Loop = soundNode.TryAttribute <bool>("loop");

            sound.Volume = soundNode.TryAttribute <float>("volume", 1);

            XAttribute pathattr  = soundNode.Attribute("path");
            XAttribute trackAttr = soundNode.Attribute("track");

            if (pathattr != null)
            {
                sound.Type = AudioType.Wav;
                sound.Path = FilePath.FromRelative(pathattr.Value, basePath);
            }
            else if (trackAttr != null)
            {
                sound.Type = AudioType.NSF;

                int track;
                if (!trackAttr.Value.TryParse(out track) || track <= 0)
                {
                    throw new GameXmlException(trackAttr, "Sound track attribute must be an integer greater than zero.");
                }
                sound.NsfTrack = track;

                sound.Priority = soundNode.TryAttribute <byte>("priority", 100);
            }
            else
            {
                sound.Type = AudioType.Unknown;
            }

            return(sound);
        }
        protected virtual void Impact()
        {
            if (this.def.skyfaller.CausesExplosion)
            {
                GenExplosion.DoExplosion(base.Position, base.Map, this.def.skyfaller.explosionRadius, this.def.skyfaller.explosionDamage, null, GenMath.RoundRandom((float)this.def.skyfaller.explosionDamage.defaultDamage * this.def.skyfaller.explosionDamageFactor), -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
            }
            for (int i = this.innerContainer.Count - 1; i >= 0; i--)
            {
                GenPlace.TryPlaceThing(this.innerContainer[i], base.Position, base.Map, ThingPlaceMode.Near, delegate(Thing thing, int count)
                {
                    PawnUtility.RecoverFromUnwalkablePositionOrKill(thing.Position, thing.Map);
                    if (thing.def.Fillage == FillCategory.Full && this.def.skyfaller.CausesExplosion && thing.Position.InHorDistOf(base.Position, this.def.skyfaller.explosionRadius))
                    {
                        base.Map.terrainGrid.Notify_TerrainDestroyed(thing.Position);
                    }
                }, null);
            }
            this.innerContainer.ClearAndDestroyContents(DestroyMode.Vanish);
            CellRect cellRect = this.OccupiedRect();

            for (int j = 0; j < cellRect.Area * this.def.skyfaller.motesPerCell; j++)
            {
                MoteMaker.ThrowDustPuff(cellRect.RandomVector3, base.Map, 2f);
            }
            if (this.def.skyfaller.MakesShrapnel)
            {
                SkyfallerShrapnelUtility.MakeShrapnel(base.Position, base.Map, this.shrapnelDirection, this.def.skyfaller.shrapnelDistanceFactor, this.def.skyfaller.metalShrapnelCountRange.RandomInRange, this.def.skyfaller.rubbleShrapnelCountRange.RandomInRange, true);
            }
            if (this.def.skyfaller.cameraShake > 0f && base.Map == Find.CurrentMap)
            {
                Find.CameraDriver.shaker.DoShake(this.def.skyfaller.cameraShake);
            }
            if (this.def.skyfaller.impactSound != null)
            {
                this.def.skyfaller.impactSound.PlayOneShot(SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None));
            }
            this.Destroy(DestroyMode.Vanish);
        }
Example #32
0
        public override void EjectContents()
        {
            ThingDef filth_Slime = ThingDefOf.Filth_Slime;

            foreach (Thing item in (IEnumerable <Thing>)innerContainer)
            {
                Pawn pawn = item as Pawn;
                if (pawn != null)
                {
                    PawnComponentsUtility.AddComponentsForSpawn(pawn);
                    pawn.filth.GainFilth(filth_Slime);
                    if (pawn.RaceProps.IsFlesh)
                    {
                        pawn.health.AddHediff(HediffDefOf.CryptosleepSickness);
                    }
                }
            }
            if (!base.Destroyed)
            {
                SoundDefOf.CryptosleepCasket_Eject.PlayOneShot(SoundInfo.InMap(new TargetInfo(base.Position, base.Map)));
            }
            base.EjectContents();
        }
Example #33
0
        public static void FinishedSummoningRitual(Pawn summoner)
        {
            int rand = Rand.RangeInclusive(0, 2);

            switch (rand)
            {
            case 0:
            {
                IntVec3   spawnloc = summoner.Position;
                SoundInfo info     = SoundInfo.InMap(new TargetInfo(spawnloc, summoner.Map), MaintenanceType.None);
                SoundDefOf.Thunder_OnMap.PlayOneShot(info);
                Thing rift = ThingMaker.MakeThing(C_ThingDefOfs.WarpRift);
                summoner.Destroy(DestroyMode.Vanish);
                GenSpawn.Spawn(rift, spawnloc, summoner.Map);
                break;
            }

            case 1:
            {
                break;
            }
            }
        }
        public override void LoadAsset(AssetInfo assetInfo)
        {
            base.LoadAsset(assetInfo);

            this.soundInstance.Stop();
            this.soundInstance = null;
            this.bank.Remove(this.sound);

            var path = "Content/" + assetInfo.FileName;

            if ((this.sound != null) && (this.sound.SoundEffect != null))
            {
                this.sound.SoundEffect.Unload();
                WaveServices.Assets.Global.UnloadAsset(path);
            }

            this.sound = new SoundInfo(path);
            this.bank.Add(this.sound);

            this.UpdateSoundInfoTextBlock();

            this.soundInstance = WaveServices.SoundPlayer.Play(this.sound, 1, false);
        }
 // Token: 0x0600139E RID: 5022 RVA: 0x00096090 File Offset: 0x00094490
 public override void FireEvent()
 {
     base.FireEvent();
     if (!this.strikeLoc.IsValid)
     {
         this.strikeLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(this.map) && !this.map.roofGrid.Roofed(sq), this.map, 1000);
     }
     this.boltMesh = AdeptusLightningBoltMeshMaker.NewBoltMesh(minX, maxX, Z);
     if (!this.strikeLoc.Fogged(this.map))
     {
         GenExplosion.DoExplosion(this.strikeLoc, this.map, 2.9f, DamageDefOf.Smoke, null, 0, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
         Vector3 loc = this.strikeLoc.ToVector3Shifted();
         for (int i = 0; i < 4; i++)
         {
             AdeptusMeshBolt bolt = new AdeptusMeshBolt(strikeLoc, loc, MaterialPool.MatFrom(boltstring, ShaderDatabase.Transparent, -1));
             bolt.CreateBolt();
             FleckMaker.ThrowSmoke(loc, this.map, 1.5f);
             FleckMaker.ThrowMicroSparks(loc, this.map);
             FleckMaker.ThrowLightningGlow(loc, this.map, 1.5f);
         }
     }
     SoundInfo info = SoundInfo.InMap(new TargetInfo(this.strikeLoc, this.map, false), MaintenanceType.None);
 }
        public static bool EnsureWorldAmbientSoundCreated()
        {
            SoundDef  aSpace    = null;
            SoundRoot soundRoot = Find.SoundRoot;

            if (null != soundRoot)
            {
                SustainerManager sManager = soundRoot.sustainerManager;
                if (null != sManager)
                {
                    aSpace = SoundDefOf.Ambient_Space;
                    if (null != aSpace)
                    {
                        if (sManager.SustainerExists(aSpace))
                        {
                            return(false);
                        }
                    }
                }
            }
            aSpace.TrySpawnSustainer(SoundInfo.OnCamera());
            return(false);
        }
Example #37
0
        public override void EjectContents()
        {
            ThingDef filthSlime = ThingDefOf.FilthSlime;

            foreach (Thing current in ((IEnumerable <Thing>) this.innerContainer))
            {
                Pawn pawn = current as Pawn;
                if (pawn != null)
                {
                    PawnComponentsUtility.AddComponentsForSpawn(pawn);
                    pawn.filth.GainFilth(filthSlime);
                    if (pawn.RaceProps.IsFlesh)
                    {
                        pawn.health.AddHediff(HediffDefOf.CryptosleepSickness, null, null);
                    }
                }
            }
            if (!base.Destroyed)
            {
                SoundDef.Named("CryptosleepCasketEject").PlayOneShot(SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None));
            }
            base.EjectContents();
        }
Example #38
0
        // Token: 0x0600139E RID: 5022 RVA: 0x00096118 File Offset: 0x00094518
        public void FireEvent(Map map, IntVec3 strikeLoc)
        {
            if (!strikeLoc.IsValid)
            {
                strikeLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(map) && !map.roofGrid.Roofed(sq), map, 1000);
            }
            Mesh boltMesh = LightningBoltMeshPool.RandomBoltMesh;

            if (!strikeLoc.Fogged(map))
            {
                Vector3 loc = strikeLoc.ToVector3Shifted();
                for (int i = 0; i < 4; i++)
                {
                    MoteMaker.ThrowSmoke(loc, map, 1.5f);
                    MoteMaker.ThrowMicroSparks(loc, map);
                    MoteMaker.ThrowLightningGlow(loc, map, 1.5f);
                }
            }
            SoundInfo info = SoundInfo.InMap(new TargetInfo(strikeLoc, map, false), MaintenanceType.None);

            SoundDefOf.Thunder_OnMap.PlayOneShot(info);
            EventDraw(map, strikeLoc, boltMesh);
        }
Example #39
0
        private void Awake()
        {
            selectSound = SoundInfo.Find("cursor_pass");
            defaultText = headerText.text;
            logo        = CreateLogo();
            foreach (ClassSelectButton classSelector in FindObjectsOfType <ClassSelectButton>())
            {
                classSelector.OnEnter += (CharStatsInfo info) => {
                    headerText.text = "Play " + info.className;
                    AudioManager.instance.Play(selectSound);
                };

                classSelector.OnExit += (CharStatsInfo info) => {
                    headerText.text = defaultText;
                };

                classSelector.OnClick += (CharStatsInfo info) =>
                {
                    WorldBuilder.className = info.className;
                    SceneManager.LoadScene("Game");
                };
            }
        }
Example #40
0
        private void ReadSound(List <string> sounds)
        {
            if (sounds.Count > 0)
            {
                while (temp.Count > 0)
                {
                    try
                    {
                        player.SoundLocation = (soundPath + temp[0]);
                        int iTime = SoundInfo.GetSoundLength(player.SoundLocation.Trim()) - 0;
                        player.Play();
                        Thread.Sleep(iTime);
                    }
                    catch (Exception)
                    {
                    }

                    temp.Remove(temp[0]);
                }
            }
            isFinishRead = true;
            playThread.Abort();
        }
Example #41
0
        public override void FireEvent()
        {
            //SoundDefOf.Thunder_OffMap.PlayOneShotOnCamera(this.map);
            if (!this.strikeLoc.IsValid)
            {
                this.strikeLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(this.map) && !this.map.roofGrid.Roofed(sq), this.map, 1000);
            }
            this.boltMesh = RandomBoltMesh;
            if (!this.strikeLoc.Fogged(this.map))
            {
                GenExplosion.DoExplosion(this.strikeLoc, this.map, (Rand.Range(.8f, 1.2f) * this.averageRadius), this.damageType, instigator, this.damageAmount, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                Vector3 loc = this.strikeLoc.ToVector3Shifted();
                for (int i = 0; i < 4; i++)
                {
                    MoteMaker.ThrowSmoke(loc, this.map, 1.3f);
                    MoteMaker.ThrowMicroSparks(loc, this.map);
                    MoteMaker.ThrowLightningGlow(loc, this.map, 1.2f);
                }
            }
            SoundInfo info = SoundInfo.InMap(new TargetInfo(this.strikeLoc, this.map, false), MaintenanceType.None);

            SoundDefOf.Thunder_OnMap.PlayOneShot(info);
        }
        public override void FireEvent()
        {
            base.FireEvent();
            if (!strikeLoc.IsValid)
            {
                strikeLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(map) && !map.roofGrid.Roofed(sq), map);
            }
            boltMesh = LightningBoltMeshPool.RandomBoltMesh;
            if (!strikeLoc.Fogged(map))
            {
                GenExplosion.DoExplosion(strikeLoc, map, 1.9f, DamageDefOf.Flame, null);
                Vector3 loc = strikeLoc.ToVector3Shifted();
                for (int i = 0; i < 4; i++)
                {
                    MoteMaker.ThrowSmoke(loc, map, 1.5f);
                    MoteMaker.ThrowMicroSparks(loc, map);
                    MoteMaker.ThrowLightningGlow(loc, map, 1.5f);
                }
            }
            SoundInfo info = SoundInfo.InMap(new TargetInfo(strikeLoc, map));

            SoundDefOf.Thunder_OnMap.PlayOneShot(info);
        }
Example #43
0
        protected override void CreateScene()
        {
            var camera2D = new FixedCamera2D("Camera2D") { BackgroundColor = Color.Black };
            EntityManager.Add(camera2D);

            int offsetTop = 50;

            //Create BackGround
            var background = new Entity("Background")
                            .AddComponent(new Sprite("Content/Texture/real-pong.wpk"))
                            .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                            .AddComponent(new Transform2D()
                            {
                                XScale = 1.5f,
                                YScale = 1.45f,
                            });

            //Create UI
            textblockGoal1 = new TextBlock("Goal1")
                            {
                                Margin = new Thickness((WaveServices.Platform.ScreenWidth / 2f) - 100, offsetTop, 0, 0),
                                FontPath = "Content/Font/Calisto MT.wpk",
                                Text = "0",
                                Height = 130,
                            };



            textblockGoal2 = new TextBlock("Goal2")
                            {
                                Margin = new Thickness((WaveServices.Platform.ScreenWidth / 2f) + 50, offsetTop, 0, 0),
                                FontPath = "Content/Font/Calisto MT.wpk",
                                Text = "0",
                                Height = 130,
                            };


            textblockInit = new TextBlock("TextInit")
                            {
                                Margin = new Thickness((WaveServices.Platform.ScreenWidth / 2f) - 50, offsetTop + 150, 0, 0),
                                FontPath = "Content/Font/Calisto MT.wpk",
                                Text = "",
                                Height = 130,
                                IsVisible = false,
                            };


            //Create Borders
            var barTop = new Entity("BarTop")
                .AddComponent(new Sprite("Content/Texture/wall.wpk"))
                            .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                            .AddComponent(new RectangleCollider())
                            .AddComponent(new Transform2D()
                            {
                                XScale = 1.55f,
                                YScale = 2f,                                
                            });

            var barBot = new Entity("BarBot")
                            .AddComponent(new Sprite("Content/Texture/wall.wpk"))
                            .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                            .AddComponent(new RectangleCollider())
                            .AddComponent(new Transform2D()
                            {
                                XScale = 1.55f,
                                YScale = 2f,
                                Y = WaveServices.Platform.ScreenHeight - 25,                                
                            });

            //Create Players
            var player = new Entity("Player")
                           .AddComponent(new Sprite("Content/Texture/player.wpk"))
                           .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                           .AddComponent(new RectangleCollider())
                           .AddComponent(new Transform2D()
                           {
                               Origin = new Vector2(0.5f, 1),
                               X = WaveServices.Platform.ScreenWidth / 50,
                               Y = WaveServices.Platform.ScreenHeight / 2
                           })
                           .AddComponent(new PlayerBehavior());

            var player2 = new Entity("PlayerIA")
                           .AddComponent(new Sprite("Content/Texture/player.wpk"))
                           .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                           .AddComponent(new RectangleCollider())
                           .AddComponent(new Transform2D()
                           {
                               Origin = new Vector2(0.5f, 1),
                               X = WaveServices.Platform.ScreenWidth - 15,
                               Y = WaveServices.Platform.ScreenHeight / 2
                           });

            //Create Ball
            var ball = new Entity("Ball")
                          .AddComponent(new Sprite("Content/Texture/ball.wpk"))
                          .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                          .AddComponent(new RectangleCollider())
                          .AddComponent(new Transform2D()
                          {
                              Origin = new Vector2(0.5f, 1),
                              X = WaveServices.Platform.ScreenWidth / 2,
                              Y = WaveServices.Platform.ScreenHeight / 2
                          })
                          .AddComponent(new BallBehavior(player, barBot, barTop, player2));


            //Trophy components               
            trophy.AddComponent(new Sprite("Content/Texture/trophy.wpk"));
            trophy.AddComponent(new SpriteRenderer(DefaultLayers.Alpha));
            trophy.AddComponent(new Transform2D());
            trophy.IsVisible = false;


            //Add component AI or Second Player controller
            if (WaveServices.ScreenContextManager.CurrentContext.Name == "FromSingleplayer")
                player2.AddComponent(new PlayerAIBehavior(ball));
            else if (WaveServices.ScreenContextManager.CurrentContext.Name == "FromMultiplayer")
                player2.AddComponent(new Player2Behavior());

            //Create Back Button
            var backButtonEntity = new Entity("BackButton")
                           .AddComponent(new Transform2D())
                           .AddComponent(new TextControl()
                           {
                               Text = "Back",
                               HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                               VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Bottom,
                               Foreground = Color.Black,
                           })
                           .AddComponent(new TextControlRenderer())
                           .AddComponent(new RectangleCollider())
                           .AddComponent(new TouchGestures());

            backButtonEntity.FindComponent<TouchGestures>().TouchPressed += new EventHandler<GestureEventArgs>(Back_TouchPressed);

            //Create a sound bank and sound info for game
            SoundBank bank = new SoundBank(Assets);
            WaveServices.SoundPlayer.RegisterSoundBank(bank);

            soundPong = new SoundInfo("Content/Sound/SoundPong.wpk");
            bank.Add(soundPong);

            soundGoal = new SoundInfo("Content/Sound/SoundGol.wpk");
            bank.Add(soundGoal);

            //Add entities
            EntityManager.Add(backButtonEntity);
            EntityManager.Add(textblockInit);
            EntityManager.Add(player);
            EntityManager.Add(player2);
            EntityManager.Add(ball);
            EntityManager.Add(textblockGoal1);
            EntityManager.Add(textblockGoal2);
            EntityManager.Add(barTop);
            EntityManager.Add(barBot);
            EntityManager.Add(trophy);
            EntityManager.Add(background);

            //Add Scene Behavior Post Update
            AddSceneBehavior(new MySceneBehavior(), SceneBehavior.Order.PostUpdate);
        }
Example #44
0
        /// <summary>
        /// Called when [record button clicked].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void OnRecordButtonClicked(object sender, EventArgs e)
        {
            if (!WaveServices.Microphone.IsConnected)
            {
                return;
            }

            if (!WaveServices.Microphone.IsRecording)
            {
                this.recordButton.Text = STOPTEXT;
                this.progressBar.IsVisible = true;
                this.progressBar.Value = 0;
                WaveServices.Microphone.DataAvailable += this.Microphone_DataAvailable;
                WaveServices.Microphone.Start(RECORDFILE);
            }
            else
            {
                this.recordButton.Text = STARTTEXT;
                WaveServices.Microphone.Stop();
                WaveServices.Microphone.DataAvailable -= this.Microphone_DataAvailable;

                //Register sounds

                if ((this.sound != null) && (this.sound.SoundEffect != null))
                {
                    this.sound.SoundEffect.Unload();
                    WaveServices.Assets.Global.UnloadAsset(RECORDFILE);
                }

                this.sound = new SoundInfo(RECORDFILE);
                var stream = WaveServices.Storage.OpenStorageFile(RECORDFILE, WaveEngine.Common.IO.FileMode.Open);
                this.sound.SoundEffect = WaveServices.Assets.Global.LoadAsset<SoundEffect>(RECORDFILE, stream);
                this.bank.AddWithouthLoad(this.sound);

                this.playButton.IsVisible = true;
                this.progressBar.IsVisible = false;
            }
        }
Example #45
0
 public Tower_Chandler(int x, int y, int counter, string sprite)
     : base(x,y,counter,sprite)
 {
     Console.WriteLine("GOT CHANDLER TOWER !");
        sample = new SoundInfo("Content/Towers/Tower_Chandler/whip_chandler.wpk");
        SoundBank = new SoundBank();
        SoundBank.Add(sample);
        WaveServices.SoundPlayer.RegisterSoundBank(SoundBank);
 }
 /// <summary>
 /// Creates a play sound action.
 /// </summary>
 /// <param name="scene">The scene.</param>
 /// <param name="soundInfo">The sound info to play</param>
 /// <param name="volume">The sound volume</param>
 /// <param name="loop">The sound loop is enabled</param>
 /// <returns>The action</returns>
 public static IGameAction CreatePlaySoundGameAction(this Scene scene, SoundInfo soundInfo, float volume = 1f, bool loop = false)
 {
     return new PlaySoundGameAction(soundInfo, scene, volume, loop);
 }
Example #47
0
 private static bool IsSoundFinished(ref SoundInfo aInfo, SoundEffect aEffect, GameTime aTime)
 {
     if(aInfo._iLastPlayTime == 0)
         return true;
     int ifinishedTime = aInfo._iLastPlayTime + (int)aEffect.Duration.TotalMilliseconds + aInfo._iDelay;
     return ifinishedTime < aTime.TotalGameTime.TotalMilliseconds;
 }
Example #48
0
 public void RemoveSound(SoundInfo sound)
 {
     _sounds.Remove(sound);
 }
Example #49
0
 internal void AddPlayedSound(SoundInfo sound)
 {
     sound.PlayedCount++;
     if (!soundDictionary.ContainsKey(sound.Id))
         soundDictionary.Add(sound.Id, sound.PlayedCount);
     else
         soundDictionary[sound.Id] = sound.PlayedCount;
 }
Example #50
0
 internal string AddSound(Model.Contract.AddSoundBody body)
 {
     var sound = new SoundInfo(_lastSoundId, body.Name, body.Uri, body.ImageUri);
     string retour = String.Empty;
     try
     {
         DataBaseService.Current.AddData(sound);
     }
     catch (Exception ex)
     {
         retour = ex.Message;
     }
     return retour;
 }
Example #51
0
        /// <summary>
        /// Loads the sound.
        /// </summary>
        /// <param name="sound">The sound.</param>
        /// <param name="file">The file.</param>
        private void Load(Enum sound, ref SoundInfo[] array)
        {
            int soundIndex = Convert.ToInt32(sound);
            SoundInfo soundInfo = new SoundInfo(this.GetSoundOrMusicPath(sound));

            array[soundIndex] = soundInfo;
            this.soundsBank.Add(array[soundIndex]);
        }
Example #52
0
        public string EffectFromInfo(SoundInfo info)
        {
            if (loadedSounds.ContainsKey(info.Name)) return info.Name;

            ISoundEffect sound;
            if (info.Type == AudioType.Wav)
            {
                sound = new WavEffect(soundSystem, info.Path.Absolute, info.Loop, info.Volume);
            }
            else if (info.Type == AudioType.NSF)
            {
                sound = new NsfEffect(sfx, info.NsfTrack, info.Priority, info.Loop);
            }
            else return info.Name;

            loadedSounds[info.Name] = sound;
            return info.Name;
        }
Example #53
0
 public void AddSound(SoundInfo sound)
 {
     _sounds.Add(sound);
 }
 /// <summary>
 /// And play a sound action.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="soundInfo">The sound info to play</param>
 /// <param name="volume">The sound volume</param>
 /// <param name="loop">The sound loop is enabled</param>
 /// <returns>The action</returns>
 public static IGameAction AndPlaySound(this IGameAction parent, SoundInfo soundInfo, float volume = 1f, bool loop = false)
 {
     return new PlaySoundGameAction(parent, soundInfo, volume, loop);
 }