private Life SelectTheNearest(List <Life> lifes)
        {
            GlobalConcepts g = GlobalConcepts.GetInstance();

            lifes.Sort((l1, l2) => g.DistanceBetweenTwoPoints(this.AI.GetPosition(), l1.GetPosition()).CompareTo(g.DistanceBetweenTwoPoints(this.AI.GetPosition(), l2.GetPosition())));
            return(lifes.First());
        }
        private TypeOfPortal SelectTheNearest(List <TypeOfPortal> portals)
        {
            GlobalConcepts g = GlobalConcepts.GetInstance();

            portals.Sort((p1, p2) => g.DistanceBetweenTwoPoints(this.AI.GetPosition(), p1.GetPosition()).CompareTo(g.DistanceBetweenTwoPoints(this.AI.GetPosition(), p2.GetPosition())));
            return(portals.First());
        }
        virtual public Quadrant GetCuadrante(TGCVector3 testPoint)
        {
            GlobalConcepts global = GlobalConcepts.GetInstance();

            if (global.IsInFrontOf(testPoint, AI.planoCostado) && TgcCollisionUtils.testPlaneAABB(AI.directionPlane, Scene.GetInstance().auto.mesh.BoundingBox))
            {
                return(new QuadranInFrontOf(this.AI.GetEstado()));
            }
            if (global.IsInFrontOf(testPoint, AI.planoCostado) && global.IsInFrontOf(testPoint, AI.directionPlane))
            {
                return(new QuadrantTopRight(this.AI.GetEstado()));
            }
            if (global.IsInFrontOf(testPoint, AI.planoCostado) && !global.IsInFrontOf(testPoint, AI.directionPlane))
            {
                return(new QuadrantTopLeft(this.AI.GetEstado()));
            }
            if (!global.IsInFrontOf(testPoint, AI.planoCostado) && !global.IsInFrontOf(testPoint, AI.directionPlane))
            {
                return(new QuadrantBottomLeft(this.AI.GetEstado()));
            }
            if (!global.IsInFrontOf(testPoint, AI.planoCostado) && global.IsInFrontOf(testPoint, AI.directionPlane))
            {
                return(new QuadrantBottomRight(this.AI.GetEstado()));
            }
            throw new Exception("No se encuentra en ningun cuadrante");
        }
Пример #4
0
        public override void Update()
        {
            if (gameModel.Input.keyDown(Key.RightArrow) && keyDownTime == 0f)
            {
                NextCar();
                keyDownTime = 0.3f;
            }

            if (gameModel.Input.keyDown(Key.LeftArrow) && keyDownTime == 0f)
            {
                PreviousCar();
                keyDownTime = 0.3f;
            }

            if (gameModel.Input.keyDown(Key.Return))
            {
                selectedCar.ResetRotation();
                this.init.stop();
                selectedCar.SoundsManager.GetSound("Motor").play(true);
                gameModel.SetState(new Playing(gameModel, selectedCar));
            }

            UpdateKeyDownTime();
            selectedCar.Rotate(GlobalConcepts.GetInstance().GetElapsedTime() * 2 / 4);
        }
        private Weapon SelectTheNearest(List <Weapon> weapons)
        {
            GlobalConcepts g = GlobalConcepts.GetInstance();

            weapons.Sort((w1, w2) => g.DistanceBetweenTwoPoints(this.AI.GetPosition(), w1.GetPosition()).CompareTo(g.DistanceBetweenTwoPoints(this.AI.GetPosition(), w2.GetPosition())));
            return(weapons.First());
        }
        public SoundsManagerLegacy(String minVelWAV, String maxVelWAV, String acceleratingWAV, String desacceleratingWAV, TGCVector3 position)
        {
            var bufferDescription = new BufferDescription();

            bufferDescription.ControlFrequency = true;
            this.minVelSound             = new Tgc3dSound(minVelWAV, position, GlobalConcepts.GetInstance().GetDispositivoDeAudio());
            this.maxVelSound             = new Tgc3dSound(maxVelWAV, position, GlobalConcepts.GetInstance().GetDispositivoDeAudio());
            this.acceleratingVelSound    = new Tgc3dSound(acceleratingWAV, position, GlobalConcepts.GetInstance().GetDispositivoDeAudio(), bufferDescription);
            this.desacceleratingVelSound = new Tgc3dSound(desacceleratingWAV, position, GlobalConcepts.GetInstance().GetDispositivoDeAudio(), bufferDescription);
            this.desacceleratingVelSound.SoundBuffer.SetCurrentPosition(LAST_BUFFER_POSITION);
            this.PlayMinVel();
        }
Пример #7
0
        public Van(TGCVector3 posicionInicial, SoundsManager soundsManager) : base(posicionInicial, soundsManager)
        {
            string reverseLightsPath, frontLightsPath, breakLightsPath;

            this.CreateMesh(GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Camioneta\\Camioneta-TgcScene.xml", posicionInicial);
            reverseLightsPath = GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Camioneta\\LucesMarchaAtras\\Luces-TgcScene.xml";
            frontLightsPath   = GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Camioneta\\LucesDelanteras\\Luces-TgcScene.xml";
            breakLightsPath   = GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Camioneta\\LucesFrenado\\Luces-TgcScene.xml";
            this.CreateLights(reverseLightsPath, breakLightsPath, frontLightsPath);
            this.CreateWheels();
            this.CreateSounds(soundsManager);
        }
Пример #8
0
        public Hummer(TGCVector3 posicionInicial, SoundsManager soundsManager) : base(posicionInicial, soundsManager)
        {
            this.escaladoInicial = new TGCVector3(0.01f, 0.01f, 0.01f);
            this.CreateMesh(GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Hummer\\Hummer-TgcScene.xml", posicionInicial);
            string reverseLightsPath, frontLightsPath, breakLightsPath;

            reverseLightsPath = GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Hummer\\LucesMarchaAtras\\Luces-TgcScene.xml";
            frontLightsPath   = GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Hummer\\LucesDelanteras\\Luces-TgcScene.xml";
            breakLightsPath   = GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Hummer\\LucesFrenado\\Luces-TgcScene.xml";
            this.CreateLights(reverseLightsPath, breakLightsPath, frontLightsPath);
            this.CreateWheels();
            this.CreateSounds(soundsManager);
        }
Пример #9
0
        private void CreateWheels()
        {
            TgcSceneLoader loader                = new TgcSceneLoader();
            TgcMesh        ruedaIzquierda        = loader.loadSceneFromFile(GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Camioneta\\Rueda\\Rueda-TgcScene.xml").Meshes[0];
            TgcMesh        ruedaDerecha          = ruedaIzquierda.clone("ruedaDerecha");
            TgcMesh        ruedaTraseraIzquierda = ruedaIzquierda.clone("ruedaTraseraIzquierda");
            TgcMesh        ruedaTraseraDerecha   = ruedaIzquierda.clone("ruedaTraseraDerecha");

            delanteraIzquierda = new Wheel(ruedaIzquierda, new TGCVector3(35f, 15f, 63f));
            delanteraDerecha   = new Wheel(ruedaDerecha, new TGCVector3(-35f, 15f, 63f));
            ruedas.Add(new Wheel(ruedaTraseraIzquierda, new TGCVector3(38f, 18f, -61f)));
            ruedas.Add(new Wheel(ruedaTraseraDerecha, new TGCVector3(-34f, 18f, -61f)));
        }
Пример #10
0
        private void CreateWheels()
        {
            TgcSceneLoader loader                = new TgcSceneLoader();
            TgcMesh        ruedaIzquierda        = loader.loadSceneFromFile(GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Camioneta\\Rueda\\Rueda-TgcScene.xml").Meshes[0];
            TgcMesh        ruedaDerecha          = ruedaIzquierda.clone("ruedaDerecha");
            TgcMesh        ruedaTraseraIzquierda = ruedaIzquierda.clone("ruedaTraseraIzquierda");
            TgcMesh        ruedaTraseraDerecha   = ruedaIzquierda.clone("ruedaTraseraDerecha");
            var            wheelScale            = TGCVector3.One * 0.48f;

            delanteraIzquierda = new Wheel(ruedaIzquierda, new TGCVector3(23.5f, 7.6f, 30f), wheelScale);
            delanteraDerecha   = new Wheel(ruedaDerecha, new TGCVector3(-23.5f, 7.6f, 30f), wheelScale);
            ruedas.Add(new Wheel(ruedaTraseraIzquierda, new TGCVector3(23f, 7.2f, -33f), wheelScale));
            ruedas.Add(new Wheel(ruedaTraseraDerecha, new TGCVector3(-23f, 7.2f, -33f), wheelScale));
        }
Пример #11
0
        public Light(string path)
        {
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene       scene  = loader.loadSceneFromFile(path);

            meshes = scene.Meshes;
            foreach (TgcMesh mesh in meshes)
            {
                mesh.AutoTransform = false;
                mesh.Effect        = TgcShaders.loadEffect(GlobalConcepts.GetInstance().GetShadersDir() + "Faros.fx");
                mesh.Technique     = "Normal";
            }
            this.matrix = TGCMatrix.Identity;
        }
Пример #12
0
        public ArtificialIntelligence(TGCVector3 posicionInicial, SoundsManager soundsManager) : base(posicionInicial, soundsManager)
        {
            this.CreateMesh(GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Camioneta\\Camioneta-TgcScene.xml", posicionInicial);
            string reverseLightsPath, frontLightsPath, breakLightsPath;

            reverseLightsPath = GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Camioneta\\LucesMarchaAtras\\Luces-TgcScene.xml";
            frontLightsPath   = GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Camioneta\\LucesDelanteras\\Luces-TgcScene.xml";
            breakLightsPath   = GlobalConcepts.GetInstance().GetMediaDir() + "meshCreator\\meshes\\Vehiculos\\Camioneta\\LucesFrenado\\Luces-TgcScene.xml";
            this.CreateLights(reverseLightsPath, breakLightsPath, frontLightsPath);
            this.CreateWheels();
            radarSphere.setValues(this.GetPosition(), 75f);
            radarSphere.setRenderColor(Color.DarkViolet);
            this.aiState = new SearchWeapons(this);
            this.CreateSounds(soundsManager);
            this.velocidadMaximaDeAvance = 40f;
            velocidadRotacion            = 2f;
        }
Пример #13
0
        public void AddSound(TGCVector3 position, float minDistance, int volume, string sound, string apodo, bool isSoundWithFrecuency)
        {
            if (this.sounds.Exists(s => sound.Equals(apodo)))
            {
                throw new Exception("Ya existe un sonido con ese nombre");
            }
            BufferDescription bufferDescription = new BufferDescription();

            bufferDescription.ControlVolume = true;
            if (isSoundWithFrecuency)
            {
                bufferDescription.ControlFrequency = true;
            }
            Tgc3dSound newSound = new Tgc3dSound(GlobalConcepts.GetInstance().GetMediaDir() + "Sound\\" + sound, position, GlobalConcepts.GetInstance().GetDispositivoDeAudio(), bufferDescription);

            newSound.SoundBuffer.Volume = volume;
            newSound.MinDistance        = minDistance;
            if (isSoundWithFrecuency)
            {
                this.initialFreq        = newSound.SoundBuffer.Frequency;
                this.soundWithFrecuency = newSound;
            }
            this.sounds.Add(new Sound(newSound, apodo));
        }
Пример #14
0
        private void UpdateKeyDownTime()
        {
            var nextTime = keyDownTime - GlobalConcepts.GetInstance().GetElapsedTime();

            keyDownTime = FastMath.Max(0f, nextTime);
        }