コード例 #1
0
        /// <summary>
        ///     Crear Collider a partir de BoundingBox.
        ///     Crea el BoundingSphere del Collider.
        /// </summary>
        /// <param name="mesh">BoundingBox</param>
        /// <returns>Collider creado</returns>
        public static BoundingBoxCollider fromBoundingBox(TgcBoundingAxisAlignBox aabb)
        {
            var collider = new BoundingBoxCollider();

            collider.Aabb           = aabb;
            collider.BoundingSphere = TgcBoundingSphere.computeFromPoints(aabb.computeCorners()).toClass();
            return(collider);
        }
コード例 #2
0
        public bool hasDirectSightWith(Checkpoint aCheckPoint)
        {
            TgcRay rayCast = new TgcRay();

            rayCast.Origin    = this.Position;
            rayCast.Direction = aCheckPoint.Position - this.Position;
            float distance = Vector3.Length(aCheckPoint.Position - this.Position);
            BoundingBoxCollider boundingBox = new BoundingBoxCollider();

            CollisionManager.getClosestBoundingBox(rayCast, out boundingBox, null);
            return(boundingBox == null || (Vector3.Length(CollisionManager.getClosesPointBetween(rayCast, boundingBox) - rayCast.Origin) > distance));
        }
コード例 #3
0
        private void getColisionContraObjetoCarga()
        {
            BoundingBoxCollider re = new BoundingBoxCollider();

            foreach (BoundingBoxCollider recarga in objetosRecarga)
            {
                if ((boundPersonaje.Center - recarga.BoundingSphere.Center).Length() < (boundPersonaje.Radius.Length() + recarga.BoundingSphere.Radius))
                {
                    re = recarga;
                    if (recarga.nombre == luz.descripcion())
                    {
                        luz.tiempoAcumulado = 0;
                        luz.setMaximaEnergia();
                    }
                    else
                    {
                        switch (recarga.nombre)
                        {
                        case "Vela":
                            luz = new Vela();
                            break;

                        case "Linterna":
                            luz = new Linterna();
                            break;

                        case "Farol":
                            luz = new Farol();
                            break;
                        }
                    }
                    meshEscenario.Remove(recarga.mesh);
                }
            }
            objetosRecarga.Remove(re);
        }
コード例 #4
0
        public override void Init()
        {
            //Para la creacion de checkpoints, borrar en el futuro
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator = ".";

            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

            Clipboard.Clear();
            this.inicializarCamara();
            //Seteo el personaje
            seteoDePersonaje();
            //Seteo del monsturo
            seteoDelMonstruo();
            //Seteo el escenario
            escenario = new TgcSceneLoader().loadSceneFromFile(MediaDir + "Mapa\\mapaProjectMarble-TgcScene.xml");

            //initPuertaGiratoria();
            //Almacenar volumenes de colision del escenario
            objetosColisionables.Clear();
            CollisionManager.obstaculos = new List <BoundingBoxCollider>();
            foreach (var mesh in escenario.Meshes)
            {
                if (mesh.Name.Contains("Recarga"))
                {
                    BoundingBoxCollider recarga = BoundingBoxCollider.fromBoundingBox(mesh.BoundingBox);
                    string[]            nombre  = Regex.Split(mesh.Name, "-");
                    recarga.nombre = nombre[1];
                    recarga.mesh   = mesh;
                    objetosRecarga.Add(recarga);
                }
                else
                {
                    if (mesh.Name.Contains("Puerta"))
                    {
                        mesh.AutoTransformEnable = true;
                        BoundingBoxCollider puerta = BoundingBoxCollider.fromBoundingBox(mesh.BoundingBox);
                        puertas.Add(puerta);
                    }
                    if (mesh.Name.Contains("Placard") || mesh.Name.Contains("Locker"))
                    {
                        armarios.Add(BoundingBoxCollider.fromBoundingBox(mesh.BoundingBox));
                    }
                    BoundingBoxCollider obj = BoundingBoxCollider.fromBoundingBox(mesh.BoundingBox);
                    obj.nombre = mesh.Name;
                    objetosColisionables.Add(obj);
                    CollisionManager.obstaculos.Add(BoundingBoxCollider.fromBoundingBox(mesh.BoundingBox));
                }
                meshEscenario.Add(mesh);
            }
            CheckpointHelper.BuildCheckpoints();
            DestinoMonstruo = CheckpointHelper.checkpoints[0];

            //Crear manejador de colisiones
            collisionManager                    = new ElipsoidCollisionManager();
            collisionManager.SlideFactor        = 2;
            collisionManager.GravityEnabled     = false;
            colisionadorMonstruo                = new ElipsoidCollisionManager();
            colisionadorMonstruo.SlideFactor    = 2;
            colisionadorMonstruo.GravityEnabled = false;
            drawer2D = new Drawer2D();
            this.incializarMenu();
            inicializarPantallaNegra();
            mp3Player = new TgcMp3Player();
            inicializarBarra();
            iniciliazarAlarma();
            incializarVisionNoctura();
            luz = new Linterna();
        }