Example #1
0
        private void SetupAudio()
        {
            // Setup OpenAL Listener
            listenerPosition  = eyePos;
            listenerDirection = targetPos;
            listenerUp        = Vector3.UnitY;

            ding1 = new ComponentAudio("Audio/ding1.wav", false);
            Vector3 emitterPosition = eyePos;

            ding1.SetPosition(emitterPosition);

            ding2 = new ComponentAudio("Audio/ding2.wav", false);
            ding2.SetPosition(emitterPosition);
        }
Example #2
0
 private void Playback(ComponentAudio AudioComponent, Vector3 position)
 {
     AudioComponent.SetPosition(position);
 }
Example #3
0
 private void Motion(ComponentAudio audio, ComponentPosition pos)
 {
     audio.SetPosition(pos.Position);
 }
Example #4
0
        private void CheckZCollision(List <Entity> entities, float dir)
        {
            foreach (Entity entity in entities)
            {
                Vector3 entityPos = entity.GetPosition();
                if (entity.Name.Contains("wall") && collisionOn)
                {
                    float zCollide = (eyePos.Z + dir) - entityPos.Z;
                    float xCollide = eyePos.X - entityPos.X;
                    if (zCollide < 1.5 && zCollide > -1.5 && xCollide < 1.5 && xCollide > -1.5)
                    {
                        wallCollide = true;
                        break;
                    }
                }
                if (entity.Name.Contains("pellet"))
                {
                    float zCollide = eyePos.Z - entityPos.Z;
                    float xCollide = eyePos.X - entityPos.X;
                    if (zCollide < 1.0 && zCollide > -1.0 && xCollide < 1.0 && xCollide > -1.0)
                    {
                        entity.ChangePosition(new Vector3(0, -10, 0));
                        Vector3 emitterPosition = eyePos;
                        ding2.SetPosition(emitterPosition);
                        ding2.Start();
                        pelletsCollected += 1;
                        score            += 100;
                        break;
                    }
                }

                if (entity.Name.Contains("ghost"))
                {
                    float zCollide = (eyePos.Z + dir) - entityPos.Z;
                    float xCollide = eyePos.X - entityPos.X;
                    if (zCollide < 1.5 && zCollide > -1.5 && xCollide < 1.5 && xCollide > -1.5)
                    {
                        if (ghostKill)
                        {
                            ComponentAudio killGhost = entity.GetAudio(0);
                            killGhost.Start();
                            switch (entity.Name)
                            {
                            case "ghostA":
                                entity.ChangePosition(ghostASpawn);
                                entity.ChangeVelocity(new Vector3(0, 0, 0));
                                aDead = true;
                                break;

                            case "ghostB":
                                entity.ChangePosition(ghostBSpawn);
                                entity.ChangeVelocity(new Vector3(0, 0, 0));
                                bDead = true;
                                break;

                            case "ghostC":
                                entity.ChangePosition(ghostCSpawn);
                                entity.ChangeVelocity(new Vector3(0, 0, 0));
                                cDead = true;
                                break;
                            }
                            score += 500;
                            break;
                        }
                        else
                        {
                            ComponentAudio loseLife = entity.GetAudio(1);
                            loseLife.Start();
                            eyePos     = spawnPoint;
                            targetPos  = new Vector3(eyePos.X, eyePos.Y, eyePos.Z - 2);
                            lifeTotal -= 1;

                            break;
                        }
                    }
                }

                if (entity.Name.Contains("pUp"))
                {
                    float zCollide = eyePos.Z - entityPos.Z;
                    float xCollide = eyePos.X - entityPos.X;
                    if (zCollide < 1.0 && zCollide > -1.0 && xCollide < 1.0 && xCollide > -1.0)
                    {
                        entity.ChangePosition(new Vector3(0, -10, 0));
                        Vector3 emitterPosition = eyePos;
                        ding1.SetPosition(emitterPosition);
                        ding1.Start();
                        ComponentAudio buzz = entity.GetAudio(0);
                        buzz.Stop();
                        ghostKill = true;
                        timer     = 7.0f;
                        score    += 250;
                        break;
                    }
                }
            }
        }
Example #5
0
 public void Position(ComponentPosition positionComponent, ComponentAudio audioComponent)
 {
     audioComponent.SetPosition(positionComponent.Position);
 }