本文整理汇总了C#中Microsoft.Xna.Framework.Audio.SoundBank.PlayCue方法的典型用法代码示例。如果您正苦于以下问题:C# SoundBank.PlayCue方法的具体用法?C# SoundBank.PlayCue怎么用?C# SoundBank.PlayCue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Audio.SoundBank
的用法示例。
在下文中一共展示了SoundBank.PlayCue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: bolt
protected int timeTillNextRBolt = 4000; // Electricity bolt ( right )
#endregion Fields
#region Constructors
public FinalBoss(Texture2D textureImage, Texture2D pulseCannonTex, Texture2D boltCannonTex, Texture2D defendersPlatformTex, Texture2D defenderTex, Texture2D pulseTex, Texture2D boltTex, Player player, Rectangle window, ExplosionManager explosionManager, SoundBank soundBank)
: base(textureImage, new Point(1, 1), new Vector2(window.Width / 2f, window.Height + 400), Vector2.Zero, window, explosionManager, soundBank)
{
this.pulseCannonTex = pulseCannonTex;
this.boltCannonTex = boltCannonTex;
this.defendersPlatformTex = defendersPlatformTex;
this.defenderTex = defenderTex;
this.pulseTex = pulseTex;
this.boltTex = boltTex;
this.player = player;
this.explosionDamage = 200f;
this.explosionRadius = 300f;
this.scoreOnDeath = 3000;
this.health = 14000;
this.materialDensity = 10f;
this.rotation = (float)Math.PI;
boltR = new Bolt(boltTex, new Point(1, 4), position - new Vector2(230 + 105 + 10, 15), 60, false, window, explosionManager);
boltL = new Bolt(boltTex, new Point(1, 4), position + new Vector2(230 + 105 + 10, -15), 60, true, window, explosionManager);
this.side = Side.Aliens;
soundBank.PlayCue("FinalBossFlyBy");
}
示例2: LoadContent
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// Load the XACT data
audioEngine = new AudioEngine(@"Content\Audio\GameAudio.xgs");
waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb");
soundBank = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb");
// Start the soundtrack audio
trackCue = soundBank.GetCue("track");
trackCue.Play();
// Play the start sound
soundBank.PlayCue("start");
}
示例3: Update
//.........这里部分代码省略.........
if (Photons[i].IsTethered)
{
if (!ship.BoundSphere.Intersects(new BoundingSphere(new Vector3(Photons[i].Position, 0), (Photons[i].Texture.Width / 2))))
{
Vector2 distance = ship.Position - Photons[i].Position;
Photons[i].Velocity += Vector2.Normalize(distance) * 20;
}
}
else
{
Photons[i].Position -= new Vector2(0, 0.07f);
}
Photons[i].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, f_Friction);
}
else if (Photons[i].ParticleState == Particle.PState.Spawning)
{
if (Photons[i].Scale > 1)
{
Photons[i].Scale = 1.0f;
Photons[i].ParticleState = Particle.PState.Alive;
}
else
{
Photons[i].Scale += 0.02f;
}
}
else if (Photons[i].SpawnTimer == loadedLevel.levelData.i_PhotonSpawnRate)
{
Photons[i] = new Particle(loadedLevel.levelBounds);
Photons[i].LoadTex(t_Photon);
Photons[i].ParticleState = Particle.PState.Spawning;
Photons[i].Spawn(offset, loadedLevel.levelBounds, true);
Photons[i].SpawnTimer = 0;
soundBank.PlayCue("photonPop");
}
}
for (int i = 0; i < Chlor.Length; i++)
{
if (Chlor[i].ParticleState == Particle.PState.Fusing)
{
if (Chlor[i].i_Fusing > 50)
{
Chlor[i].ParticleState = Particle.PState.Dead;
Chlor[i].i_Fusing = 0;
}
else
{
Chlor[i].i_Fusing++;
}
}
else if (Chlor[i].ParticleState == Particle.PState.Colliding)
{
Chlor[i].Velocity = new Vector2((((Chlor[i].FusionPosition.X - Chlor[i].Position.X) / Vector2.Distance(Chlor[i].Position, Chlor[i].FusionPosition)) * 10), (((Chlor[i].FusionPosition.Y - Chlor[i].Position.Y) / Vector2.Distance(Chlor[i].Position, Chlor[i].FusionPosition)) * 10));
Chlor[i].updatePosition((float)gameTime.ElapsedGameTime.TotalSeconds, f_Friction);
if (Chlor[i].Position.X < (Chlor[i].FusionPosition.X + 1) && Chlor[i].Position.X > (Chlor[i].FusionPosition.X - 1) && Chlor[i].Position.Y < (Chlor[i].FusionPosition.Y + 1) && Chlor[i].Position.Y > (Chlor[i].FusionPosition.Y - 1))
{
Chlor[i].ParticleState = Particle.PState.Fusing;
}
}
else if (Chlor[i].ParticleState == Particle.PState.Alive)
{
if (Chlor[i].IsTethered)
{
if (!ship.BoundSphere.Intersects(new BoundingSphere(new Vector3(Chlor[i].Position, 0), (Chlor[i].Texture.Width / 2))))
示例4: Update
public void Update(GameTime gameTime, ref PositionManager[,,] positionManager, int floor, int playerdex, ref int skada, SoundBank soundBank, Cue attackHit, Cue attackMiss, int level, ref Character player1)
{
if (resetAttack == false)
{
moved2 += 1;
if (moved2 > 1 && moved2 < 16)
{ Frame = 0; }
else if (moved2 > 16 && moved2 < 32)
{ Frame = 1; }
else if (moved2 > 32 && moved2 < 48)
{ Frame = 2; }
else if (moved2 > 48 && moved2 < 64)
{ Frame = 3; }
if (moved2 == 64)
{ moved2 = 0; Frame = 0; resetAttack = true; attackMissed = true; attackDidDmg = true; } //olika variabler ändras så att man nu kan genomföra en ny rörelse
}
//attack animation
if (attackAnimationDone == true)
{
movedattack += 4;
if (movedattack > 1 && movedattack < 16)
{ attackFrame = 0; }
else if (movedattack > 16 && movedattack < 32)
{ attackFrame = 1; }
else if (movedattack > 32 && movedattack < 48)
{ attackFrame = 2; }
else if (movedattack > 48 && movedattack < 64)
{ attackFrame = 3; }
if (movedattack == 64) // när man rört sig 64 pixlar så stannar gubben
{ movedattack = 0; attackFrame = 0; attackAnimationDone = false; } //olika variabler ändras så att man nu kan genomföra en ny rörelse
}
CheckActive(); //Kör metoden för att kolla när fienden skall aktiveras
//Detta ai fungerar så att fienden kollar var spelaren befinner sig i rutnätet. Först kollar den vart den är på X-leden, sedan rör den sig mot fienden tills den är
//under den på y-leden. Efter det rör sig fienden mot spelaren på y. Om fienden befinner sig bredvid spelaren kommer den att försöka utföra en attack.
//Skulle en vägg komma ivägen om fienden exempelvis gick in i en vägg på x-leden kommer den i detta läge undersöka om fienden befinner sig längre upp eller ner
//på y och sedan röra sig mot spelaren på de viset. Samma sak om den går in i en vägg på y-leden, men då kommer den gå åt något håll på x-leden.
if (allowMove) //Om den frå röras startar ai
{
if (ActiveMove) // Fienden är aktiv och går mot spelaren samt attackerar om den kan.
{ // Enemy går mot spelaren om den är tillräckligt när för att attackera så gör den det istället.
//if ()//ska kolla om det är kortast till spelaren från Enemy på x kordinaten eller om avståndet är lika.
//{
if (PlayerPos.X > xCoord) // kollar om spelaren är till höger om enemy.
{
if (xCoord + 1 == PlayerPos.X && yCoord == PlayerPos.Y) //kollar om spelaren är på rutan till höger om enemy.
{
if (resetAttack == true)
{
skada = EnemyAttackCalc(playerdex);
if (skada != 0)
{ soundBank.PlayCue("AttackSound"); }
else if (skada == 0)
{ soundBank.PlayCue("AttackMiss"); }
player1.TotalHp = player1.TotalHp - skada;
}
}
// kod för att gå till höger.
else if (positionManager[yCoord, xCoord + 1, floor].type != "wall" &&
positionManager[yCoord, xCoord + 1, floor].type != "enemy" &&
positionManager[yCoord, xCoord + 1, floor].type != "upstairs" &&
positionManager[yCoord, xCoord + 1, floor].type != "downstairs" &&
positionManager[yCoord, xCoord + 1, floor].type != "chest" &&
positionManager[yCoord, xCoord + 1, floor].type != "door")
{
moveEnemyrRight = true;
allowMove = false;
positionManager[yCoord, xCoord + 1, floor] = positionManager[yCoord, xCoord, floor]; //Sätter rutan man rörde sig mot till player
positionManager[yCoord, xCoord, floor] = new PositionManager { type = "empty", floor = true }; //Sätter sin förra position i 2d-arrayen till "null"
xCoord++;
}
//Alternativ när fienden går in i en vägg
else if (positionManager[yCoord, xCoord + 1, floor].type == "wall" ||
positionManager[yCoord, xCoord + 1, floor].type == "enemy" ||
positionManager[yCoord, xCoord + 1, floor].type == "upstairs" ||
positionManager[yCoord, xCoord + 1, floor].type == "downstairs" ||
positionManager[yCoord, xCoord + 1, floor].type == "chest" ||
positionManager[yCoord, xCoord + 1, floor].type != "door")
{
if (PlayerPos.Y < yCoord) // Kollar om spelaren är ovanför enemy.
{
if (yCoord - 1 == PlayerPos.Y && xCoord == PlayerPos.X) //kollar om spelaren är på rutan ovnaför enemy.
{
if (resetAttack == true)
{
skada = EnemyAttackCalc(playerdex);
if (skada != 0)
{ soundBank.PlayCue("AttackSound"); }
else if (skada == 0)
{ soundBank.PlayCue("AttackMiss"); }
player1.TotalHp = player1.TotalHp - skada;
//.........这里部分代码省略.........
示例5: Draw
public void Draw(GraphicsDeviceManager graphics, Matrix Projection, Vector3 position_joueur, Vector3 position_ia, float scale_ia, Vector3 cible, SoundBank BanqueSon, bool resolution, bool[,] carte_resolution)
{
//On déssine les pièges
// Si c'est des piques
if (type == 0)
{
double distance_joueur_trappe = Math.Sqrt(Math.Pow(position_joueur.X - position.X, 2) + Math.Pow(position_joueur.Z - position.Z, 2));
double distance_ia_trappe = Math.Sqrt(Math.Pow(position_ia.X * scale_ia - position.X, 2) + Math.Pow(position_ia.Z * scale_ia - position.Z, 2));
if (distance_joueur_trappe >= trappe_declenchement || distance_ia_trappe <= 3)
{
if(!afficher_trappe)
BanqueSon.PlayCue("trappe_ferme");
afficher_trappe = true;
}
else if (afficher_trappe)
{
BanqueSon.PlayCue("trappe");
afficher_trappe = false;
}
// Les piques
Matrix[] transforms = new Matrix[piques.Bones.Count];
piques.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in piques.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.Projection = Projection;
effect.View = Matrix.CreateLookAt(position_joueur, cible, Vector3.Up);
effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(new Vector3(position.X, position.Y - 2.5f, position.Z));
}
mesh.Draw();
}
if (afficher_trappe)
{
if (rotation_trappe < 90)
{
rotation_trappe += 10f;
translation_trappe.X -= 0.135f;
translation_trappe.Y += 0.14f;
}
}
else
{
if (rotation_trappe > 0)
{
rotation_trappe -= 10f;
translation_trappe.X += 0.135f;
translation_trappe.Y -= 0.14f;
}
}
/*
translation_trappe.X = (float)Math.Cos(MathHelper.ToRadians(rotation_trappe));
translation_trappe.Y = (float)Math.Sin(MathHelper.ToRadians(rotation_trappe)) - 1;
*/
// Les trappes
Matrix[] transforms2 = new Matrix[trappe.Bones.Count];
trappe.CopyAbsoluteBoneTransformsTo(transforms2);
foreach (ModelMesh mesh in trappe.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
if(resolution && carte_resolution[position_case.X, position_case.Y])
effect.DiffuseColor = new Vector3(255, 255, 0);
else
effect.DiffuseColor = new Vector3(255, 255, 255);
effect.Projection = Projection;
effect.View = Matrix.CreateLookAt(position_joueur, cible, Vector3.Up);
effect.World = Matrix.CreateRotationY(0)
* Matrix.CreateRotationX(MathHelper.ToRadians(rotation_trappe))
* Matrix.CreateRotationZ(0)
* Matrix.CreateTranslation(new Vector3(position.X, position.Y + translation_trappe.Y, position.Z + translation_trappe.X));
}
mesh.Draw();
}
}
else
{
// Les lasers
Matrix[] transforms = new Matrix[laser.Bones.Count];
laser.CopyAbsoluteBoneTransformsTo(transforms);
graphics.GraphicsDevice.RenderState.AlphaBlendEnable = true;
graphics.GraphicsDevice.RenderState.AlphaTestEnable = false;
graphics.GraphicsDevice.RenderState.ReferenceAlpha = 75;
foreach (ModelMesh mesh in laser.Meshes)
{
foreach (BasicEffect effet_laser in mesh.Effects)
{
effet_laser.AmbientLightColor = new Vector3(0.2f, 1, 0);
//.........这里部分代码省略.........
示例6: Collision_Patrouilleur_Heros
public static bool Collision_Patrouilleur_Heros(List<Patrouilleur> _patrouilleurs, Heros heros1, Heros heros2, SoundBank soundBank)
{
for (int b = 0; b < _patrouilleurs.Count; b++)
{
if (_patrouilleurs[b].Rectangle.Intersects(heros1.Rectangle))
{
ServiceHelper.Get<IGamePadService>().Vibration(50);
soundBank.PlayCue("CriMortHero");
return true;
}
}
if (heros2 != null)
{
for (int b = 0; b < _patrouilleurs.Count; b++)
{
if (_patrouilleurs[b].Rectangle.Intersects(heros2.Rectangle))
{
ServiceHelper.Get<IGamePadService>().Vibration(50);
soundBank.PlayCue("CriMortHero");
return true;
}
}
}
return false;
}
示例7: Initialize
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
audioEngine = new AudioEngine("Content\\GameAudio.xgs");
waveBank = new WaveBank(audioEngine, "Content\\Wave Bank.xwb");
soundBank = new SoundBank(audioEngine, "Content\\Sound Bank.xsb");
soundBank.PlayCue("GameAudio");
}
示例8: GameContent
/// <summary>
/// Load GameContents
/// </summary>
public GameContent(GameComponent screenManager)
{
content = screenManager.Game.Content;
Viewport viewport = screenManager.Game.GraphicsDevice.Viewport;
//viewportSize = new Vector2(800, 600);
blank = content.Load<Texture2D>("Graphics/blank");
gradient = content.Load<Texture2D>("Graphics/gradient");
menuBackground = content.Load<Texture2D>("Graphics/menuBackground2");
background = content.Load<Texture2D>("Graphics/background");
for (int i = 0; i < walk.Length; i++)
{
walk[i] = content.Load<Texture2D>("Graphics/" + (Shape)i + "Walk");
idle[i] = content.Load<Texture2D>("Graphics/" + (Shape)i + "Idle");
die[i] = content.Load<Texture2D>("Graphics/" + (Shape)i + "Die");
}
mouseOver = content.Load<Texture2D>("Graphics/mouseOver");
mouseOverOrigin = new Vector2(mouseOver.Width, mouseOver.Height) / 2;
for (int i = 0; i < castle.Length; i++)
castle[i] = content.Load<Texture2D>("Graphics/" + (Shape)i + "Castle");
castleOrigin = new Vector2(castle[0].Width / 2, castle[0].Height);
pathArrow = content.Load<Texture2D>("Graphics/pathArrow");
pathCross = content.Load<Texture2D>("Graphics/pathCross");
healthBar = content.Load<Texture2D>("Graphics/healthBar");
for (int i = 0; i < MaxRank; i++)
{
weapon[i] = content.Load<Texture2D>("Graphics/" + (Rank)i + "Weapon");
//armyOverlay[i] = content.Load<Texture2D>("Graphics/" + ((Rank)(i)).ToString() + "Overlay");
bullet[i] = content.Load<Texture2D>("Graphics/" + (Rank)i + "Bullet");
}
for (int i = 0; i < tutorial.Length; i++)
tutorial[i] = content.Load<Texture2D>("Graphics/tutotrial" + i);
levelUp = content.Load<Texture2D>("Graphics/levelUp");
retry = content.Load<Texture2D>("Graphics/retry");
debugFont = content.Load<SpriteFont>("Fonts/debugFont");
gameFont = content.Load<SpriteFont>("Fonts/bicho_plumon50");
audioEngine = new AudioEngine("Content/Audio/Audio.xgs");
soundBank = new SoundBank(audioEngine, "Content/Audio/Sound Bank.xsb");
waveBank = new WaveBank(audioEngine, "Content/Audio/Wave Bank.xwb");
soundBank.PlayCue("Marching by Pill");
//Thread.Sleep(1000);
// once the load has finished, we use ResetElapsedTime to tell the game's
// timing mechanism that we have just finished a very long frame, and that
// it should not try to catch up.
screenManager.Game.ResetElapsedTime();
}
示例9: LoadContent
public override void LoadContent()
{
Rectangle viewport = ScreenManager.Game.Window.ClientBounds;
//loads the new spritebatch
spriteBatch = new SpriteBatch(ScreenManager.GraphicsDevice);
if (content == null)
content = new ContentManager(ScreenManager.Game.Services, "Content");
//loads the video array
videos = new Video[videoCount];
safeBounds = new Rectangle(
(int)(viewport.Width * SafeAreaPortion),
(int)(viewport.Height * SafeAreaPortion),
(int)(viewport.Width * (1 - 2 * SafeAreaPortion)),
(int)(viewport.Height * (1 - 2 * SafeAreaPortion)));
//loads all arrays
sensitivityDisplays = new OtherObject[4];
leftBunkers = new OtherObject[4];
rightBunkers = new OtherObject[4];
playerTriggerSensitivitys = new float[4];
sourceRectangleSen = new Rectangle[4];
//loads a screenmanager font
font = ScreenManager.Font;
//loads the starting up sensitivity source rectangle (the first image on the sprite sheet)
for (int i = 0; i < 4; i++)
{
sourceRectangleSen[i] = new Rectangle(0, 0, 250, 100);
}
//loads the starting up left bunker source rectangle from the sprite sheet
//loads the starting up right bunker source rectangle from the sprite sheet
sourceRectangleLeft = new Rectangle(658, 3, 90, 75);
sourceRectangleRight = new Rectangle(488, 3, 90, 75);
#region LoadXboxControllerTextures
center = content.Load<Texture2D>("Xboxbutton\\xbox controller-center");
textureLength = center.Width;
//the .left component of the picture for the xbox guide button
left = (ScreenManager.GraphicsDevice.Viewport.Width / 2) - (textureLength / 2);
//the .top component of the picture for the xbox guide button
top = (ScreenManager.GraphicsDevice.Viewport.Height / 2) - (textureLength / 2) - 10;
p1NotJoined = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP1-notjoined");
p1Ready = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP1-ready to play");
p1JoinedNotReady = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP1-joinedbutnotready");
p2NotJoined = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP2-notjoined");
p2Ready = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP2-ready to play");
p2JoinedNotReady = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP2-joinedbutnotready");
p3NotJoined = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP3-notjoined");
p3Ready = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP3-ready to play");
p3JoinedNotReady = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP3-joinedbutnotready");
p4NotJoined = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP4-notjoined");
p4Ready = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP4-ready to play");
p4JoinedNotReady = content.Load<Texture2D>("Xboxbutton\\xboxcontrollerP4-joinedbutnotready");
#endregion
#region Load Misc.
//videos loaded into game
videos[0] = content.Load<Video>("Video\\54321");
player = new VideoPlayer();
//audio engine in game
audioEngine = new AudioEngine("Content\\Audio\\JAMAudio.xgs");
waveBank = new WaveBank(audioEngine, "Content\\Audio\\Wave Bank.xwb");
soundBank = new SoundBank(audioEngine, "Content\\Audio\\Sound Bank.xsb");
//loads the character textures
Sayid = content.Load<Texture2D>("Sprites\\Players\\Sayid\\Images\\Sayid");
Sir_Edward = content.Load<Texture2D>("Sprites\\Players\\Sir_Edward\\Images\\Sir_Edward");
Wilhelm = content.Load<Texture2D>("Sprites\\Players\\Wilhelm\\Images\\Wilhelm");
Juan = content.Load<Texture2D>("Sprites\\Players\\Juan\\Images\\Juan");
//loads the sprite sheets for the sensitivity display, the left bunker, and the right bunker
for (int i = 0; i < 4; i++)
{
sensitivityDisplays[i] = new OtherObject(content.Load<Texture2D>("Sprites\\Misc\\Sensitivity_Sprite_Sheet"));
leftBunkers[i] = new OtherObject(content.Load<Texture2D>("Sprites\\Misc\\xboxControllerSpriteSheet"));
rightBunkers[i] = new OtherObject(content.Load<Texture2D>("Sprites\\Misc\\xboxControllerSpriteSheet"));
}
#endregion
#region StartUp KnickKnacks
//sleep for a little so the game can load
Thread.Sleep(1000);
//resets so xbox doesnt try to catch up with lost time in thread
ScreenManager.Game.ResetElapsedTime();
//make sure to set up the new menu entries upon loading
SetMenuEntryText();
//locked and loaded, ready to start up game
soundBank.PlayCue("loadreload2");
#endregion
}
示例10: Collision_Armes_Ennemis
public static void Collision_Armes_Ennemis(Heros heros1, Heros heros2, List<Garde> _gardes, List<Patrouilleur> _Patrouilleurs, List<Patrouilleur_a_cheval> _PatrouilleursAChevaux, List<Boss> _Boss, List<Shuriken> listeShuriken, MoteurParticule particule, SoundBank soundBank, ref List<EnnemiMort> morts, ContentManager content)
{
if (_gardes.Count != 0)
{
for (int i = 0; i < _gardes.Count; i++)
{
if (_gardes[i].Rectangle.Intersects(particule.Rectangle_Hadoken_heros1(heros1)) ||
_gardes[i].Rectangle.Intersects(particule.Rectangle_Ball_heros1(heros1)) ||
heros1.AttaqueAuSabre(_gardes[i].X, _gardes[i].Y))
{
soundBank.PlayCue("cri");
morts.Add(new EnnemiMort(new Vector2(28 * _gardes[i].X, 28 * _gardes[i].Y), content, EnnemiMort.TypeEnnemiMort.garde));
if (_gardes[i].Alerte)
GameplayScreen.Alerte = false;
_gardes.RemoveAt(i);
break;
}
if (heros2 != null)
{
if (_gardes[i].Rectangle.Intersects(particule.Rectangle_Hadoken_heros2(heros2)) ||
_gardes[i].Rectangle.Intersects(particule.Rectangle_Ball_heros2(heros2)) ||
heros2.AttaqueAuSabre(_gardes[i].X, _gardes[i].Y))
{
soundBank.PlayCue("cri");
morts.Add(new EnnemiMort(new Vector2(28 * _gardes[i].X, 28 * _gardes[i].Y), content, EnnemiMort.TypeEnnemiMort.garde));
if (_gardes[i].Alerte)
GameplayScreen.Alerte = false;
_gardes.RemoveAt(i);
break;
}
}
for (int j = 0; j < listeShuriken.Count; j++)
if (_gardes[i].Rectangle.Intersects(listeShuriken[j].Rectangle))
{
soundBank.PlayCue("cri");
ServiceHelper.Get<IGamePadService>().Vibration(20);
morts.Add(new EnnemiMort(new Vector2(28 * _gardes[i].X, 28 * _gardes[i].Y), content, EnnemiMort.TypeEnnemiMort.garde));
if (_gardes[i].Alerte)
GameplayScreen.Alerte = false;
_gardes.RemoveAt(i);
listeShuriken.RemoveAt(j);
break;
}
}
}
if (_Patrouilleurs.Count != 0)
{
for (int i = 0; i < _Patrouilleurs.Count; i++)
{
if (_Patrouilleurs[i].Rectangle.Intersects(particule.Rectangle_Hadoken_heros1(heros1)) ||
_Patrouilleurs[i].Rectangle.Intersects(particule.Rectangle_Ball_heros1(heros1)) ||
heros1.AttaqueAuSabre(_Patrouilleurs[i].X, _Patrouilleurs[i].Y))
{
soundBank.PlayCue("Bruitage patrouilleur");
morts.Add(new EnnemiMort(new Vector2(28 * _Patrouilleurs[i].X, 28 * _Patrouilleurs[i].Y), content, EnnemiMort.TypeEnnemiMort.patrouilleur));
if (_Patrouilleurs[i].Alerte)
GameplayScreen.Alerte = false;
_Patrouilleurs.RemoveAt(i);
break;
}
if (heros2 != null)
{
if (_Patrouilleurs[i].Rectangle.Intersects(particule.Rectangle_Hadoken_heros2(heros2)) ||
_Patrouilleurs[i].Rectangle.Intersects(particule.Rectangle_Ball_heros2(heros2)) ||
heros2.AttaqueAuSabre(_Patrouilleurs[i].X, _Patrouilleurs[i].Y))
{
soundBank.PlayCue("Bruitage patrouilleur");
morts.Add(new EnnemiMort(new Vector2(28 * _Patrouilleurs[i].X, 28 * _Patrouilleurs[i].Y), content, EnnemiMort.TypeEnnemiMort.patrouilleur));
if (_Patrouilleurs[i].Alerte)
GameplayScreen.Alerte = false;
_Patrouilleurs.RemoveAt(i);
break;
}
}
for (int j = 0; j < listeShuriken.Count; j++)
if (_Patrouilleurs[i].Rectangle.Intersects(listeShuriken[j].Rectangle))
{
soundBank.PlayCue("Bruitage patrouilleur");
morts.Add(new EnnemiMort(new Vector2(28 * _Patrouilleurs[i].X, 28 * _Patrouilleurs[i].Y), content, EnnemiMort.TypeEnnemiMort.patrouilleur));
if (_Patrouilleurs[i].Alerte)
GameplayScreen.Alerte = false;
_Patrouilleurs.RemoveAt(i);
listeShuriken.RemoveAt(j);
break;
}
}
}
if (_PatrouilleursAChevaux.Count != 0)
{
for (int i = 0; i < _PatrouilleursAChevaux.Count; i++)
{
if ((_PatrouilleursAChevaux[i].Rectangle.Intersects(particule.Rectangle_Hadoken_heros1(heros1)) ||
_PatrouilleursAChevaux[i].Rectangle.Intersects(particule.Rectangle_Ball_heros1(heros1))) ||
heros1.AttaqueAuSabre(_PatrouilleursAChevaux[i].X, _PatrouilleursAChevaux[i].Y))
{
soundBank.PlayCue("Bruitage cheval");
morts.Add(new EnnemiMort(new Vector2(28 * _PatrouilleursAChevaux[i].X, 28 * _PatrouilleursAChevaux[i].Y), content, EnnemiMort.TypeEnnemiMort.patrouilleurACheval));
if (_PatrouilleursAChevaux[i].Alerte)
//.........这里部分代码省略.........
示例11: Initialize
/// <summary>
/// Allows the game component to perform any initialization it needs to before starting
/// to run. This is where it can query for any required services and load content.
/// </summary>
public override void Initialize() {
// We don't want XNA calling this method each time we resume from the menu,
// unfortunately, it'll call it whatever we try. So the only thing
// we can do is check if it has been called already and return. Yes, it's ugly.
if (mSpriteBatch != null) {
GhostSoundsManager.ResumeLoops();
return;
}
// Otherwise, this is the first time this component is Initialized, so proceed.
GhostSoundsManager.Init(Game);
Grid.Reset();
Constants.Level = 1;
mSpriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));
mGraphicsDeviceManager = (GraphicsDeviceManager)Game.Services.GetService(typeof(GraphicsDeviceManager));
mSoundBank = (SoundBank)Game.Services.GetService(typeof(SoundBank));
mScoreFont = Game.Content.Load<SpriteFont>("Score");
mScoreEventFont = Game.Content.Load<SpriteFont>("ScoreEvent");
mXLife = Game.Content.Load<Texture2D>("sprites/ExtraLife");
mPPill = Game.Content.Load<Texture2D>("sprites/PowerPill");
mCrump = Game.Content.Load<Texture2D>("sprites/Crump");
mBoard = Game.Content.Load<Texture2D>("sprites/Board");
mBoardFlash = Game.Content.Load<Texture2D>("sprites/BoardFlash");
mBonusEaten = new Dictionary<string, int>();
mBonus = new Dictionary<string, Texture2D>(9);
mBonus.Add("Apple", Game.Content.Load<Texture2D>("bonus/Apple"));
mBonus.Add("Banana", Game.Content.Load<Texture2D>("bonus/Banana"));
mBonus.Add("Bell", Game.Content.Load<Texture2D>("bonus/Bell"));
mBonus.Add("Cherry", Game.Content.Load<Texture2D>("bonus/Cherry"));
mBonus.Add("Key", Game.Content.Load<Texture2D>("bonus/Key"));
mBonus.Add("Orange", Game.Content.Load<Texture2D>("bonus/Orange"));
mBonus.Add("Pear", Game.Content.Load<Texture2D>("bonus/Pear"));
mBonus.Add("Pretzel", Game.Content.Load<Texture2D>("bonus/Pretzel"));
mBonus.Add("Strawberry", Game.Content.Load<Texture2D>("bonus/Strawberry"));
mScoreEvents = new List<ScoreEvent>(5);
mBonusPresent = false;
mBonusSpawned = 0;
mEatenGhosts = 0;
Score = 0;
mXLives = 2;
mPaChomp = true;
mPLayerDied = false;
mPlayer = new Player(Game);
mGhosts = new List<Ghost> {
new Ghost(Game, mPlayer, EGhostType.Blinky),
new Ghost(Game, mPlayer, EGhostType.Clyde),
new Ghost(Game, mPlayer, EGhostType.Inky),
new Ghost(Game, mPlayer, EGhostType.Pinky)
};
mGhosts[2].SetBlinky(mGhosts[0]); // Oh, dirty hack. Inky needs this for his AI.
mSoundBank.PlayCue("Intro");
LockTimer = TimeSpan.FromMilliseconds(4500);
base.Initialize();
}
示例12: update
public void update(GameTime gametime, SoundBank soundbank)
{
angle += ANGLE;
elapsed += (float)gametime.ElapsedGameTime.TotalSeconds;
randlapsed += (float)gametime.ElapsedGameTime.TotalSeconds;
if (!nyanSongIsPlaying && ismoving)
{
NyanSong = soundbank.GetCue("Nyan Cat");
NyanSong.Play();
nyanSongIsPlaying = true;
}
// handle animation
if (!isDead)
{
if (elapsed > .25f && texture == nyan1)
{
texture = nyan2;
Collidable.LoadTexture(texture);
}
else if (elapsed > .5f && texture == nyan2)
{
texture = nyan1;
Collidable.LoadTexture(texture);
elapsed = 0;
}
}
else
{
texture = nyanDead;
elapsed = 0;
}
// end animation handling
// if angle is greater than pi * 2, reset to zero. 2PI == 0 DUHH NOOOB
if (angle >= Math.PI * 2)
{
angle = 0;
}
if (!isDead) // if nyancat is dead, dont bother handling his random appearance. he can't appear if HES DEAD
{
handleWhenonScreen();
position.Y += (float)Math.Sin(angle) * 3;
}
else // handles when falling after shot.
{
NyanSong.Stop(AudioStopOptions.AsAuthored);
if (deadlapsed < 2.0f)
{
deadlapsed += (float)gametime.ElapsedGameTime.TotalSeconds;
}
if (!meowHasPlayed)
{
soundbank.PlayCue("meow");
meowHasPlayed = true;
}
ismoving = false;
if (position.Y < SCREEN_HEIGHT - (texture.Height))
{
position.Y += 30f;
}
else
{
position.Y = SCREEN_HEIGHT - texture.Height;
if (!thudHasPlayed)
{
soundbank.PlayCue("thud");
thudHasPlayed = true;
}
}
}
Collidable.Position = this.position; // sets bounding box to same position as where nyancat is being drawn.
}
示例13: LoadContent
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
backgroundTexture = Content.Load<Texture2D>(@"Images\background");
scoreFont = Content.Load<SpriteFont>(@"fonts\Score");
audioEngine = new AudioEngine(@"Content\Audio\GameAudio.xgs");
waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb");
soundBank = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb");
// Start the soundtrack audio
trackCue = soundBank.GetCue("track");
trackCue.Play();
// Play the start sound
soundBank.PlayCue("start");
}
示例14: LoadContent
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
/*** LOAD ASSETS ***/
Properties.parallax_1 = Content.Load<Texture2D>("mock/gui/screens/parallax_1");
Properties.parallax_2 = Content.Load<Texture2D>("mock/gui/screens/parallax_2");
Properties.parallax_3 = Content.Load<Texture2D>("mock/gui/screens/parallax_3");
Properties.TexturaParticula = Content.Load<Texture2D>("mock/gui/particula");
Properties.TexturaNave = Content.Load<Texture2D>("mock/gui/nave");
Properties.TexturaAtractor1 = Content.Load<Texture2D>("mock/gui/Atractors");
Properties.TexturaAtractor2 = Content.Load<Texture2D>("mock/gui/Atractors1");
Properties.TexturaAtractor3 = Content.Load<Texture2D>("mock/gui/Atractors2");
Properties.TexturaAtractor4 = Content.Load<Texture2D>("mock/gui/Atractors4");
Properties.TexturaPlaneta = Content.Load<Texture2D>("mock/gui/planeta");
Properties.TexturaObjetivo = Content.Load<Texture2D>("mock/gui/objetivo");
Properties.texturaBotonHome = Content.Load<Texture2D>("mock/gui/botones/botonHome");
Properties.texturaBotonReload = Content.Load<Texture2D>("mock/gui/botones/botonReload");
Properties.texturaBotonCerrar = Content.Load<Texture2D>("mock/gui/botones/botonCerrar");
Properties.texturaBotonAyuda = Content.Load<Texture2D>("mock/gui/botones/botonAyuda");
Properties.texturaUIBarras = Content.Load<Texture2D>("mock/gui/barras");
Properties.texturaUIFill1 = Content.Load<Texture2D>("mock/gui/barrasLaserRelleno");
Properties.texturaUIFill2 = Content.Load<Texture2D>("mock/gui/barrasRellenoObjetivo");
screenSplashTexture = Content.Load<Texture2D>("mock/gui/screens/Splash");
screenHelpTexture = Content.Load<Texture2D>("mock/gui/screens/Instrucciones");
screenMenuTexture = Content.Load<Texture2D>("mock/gui/screens/Menu");
screenCreditsTexture = Content.Load<Texture2D>("mock/gui/screens/Credits");
screenGameTexture = Content.Load<Texture2D>("mock/gui/screens/GameScreen");
screenPauseTexture = Content.Load<Texture2D>("mock/gui/screens/Pause");
guiSelectorTexture = Content.Load<Texture2D>("mock/gui/Selector");
guiRectangeTexture = Content.Load<Texture2D>("mock/gui/rect");
mouseTexture = Content.Load<Texture2D>("mock/gui/cursor");
// TODO: use this.Content to load your game content here
screenMenu = new Menu(screenMenuTexture, guiRectangeTexture, this);
screenCreditos = new Creditos(screenCreditsTexture, guiRectangeTexture, this);
screenInstrucciones = new Instrucciones(screenHelpTexture, guiRectangeTexture, this);
//screenMenu.addButton(Properties.SCREEN_WITH/2 - 120, 130, 200, 35);
//screenMenu.addButton(Properties.SCREEN_WITH/2 - 120, 180, 200, 35);
/*** init juego ***/
juego = new Juego(screenGameTexture, guiRectangeTexture, this);
mouse = new MouseDP(mouseTexture, Vector2.Zero);
posMouse = new Vector2(Properties.SCREEN_WITH/2, Properties.SCREEN_HEIGHT/2);
/*** LOAD AUDIO ***/
audioEngine = new AudioEngine("Content/Audio/audio.xgs");
waveBank = new WaveBank(audioEngine, "Content/Audio/waves.xwb");
soundBank = new SoundBank(audioEngine, "Content/Audio/sounds.xsb");
soundBank.PlayCue("Tema");
/****************
* soundBank.PlayCue("Tema");
* los nombres que tenemos son Bridge, Tema, Verso
* ***************/
}
示例15: Initialize
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
//// use a fixed frame rate of 30 frames per second
//IsFixedTimeStep = true;
//TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 33);
// run at full speed
IsFixedTimeStep = false;
// set screen size
InitScreen();
// initialize our sound objects
m_audio = new AudioEngine(@"Content\example.xgs");
m_wave = new WaveBank(m_audio, @"Content\example.xwb");
m_sound = new SoundBank(m_audio, @"Content\example.xsb");
// get a reference to our two sound categories
m_catMusic = m_audio.GetCategory("Music");
m_catDefault = m_audio.GetCategory("Default");
// get a reference to Zoe's story
m_story = m_sound.GetCue("zoe");
// start playing our background music
m_sound.PlayCue("ensalada");
base.Initialize();
}