private void ChoqueObstaculo(float ElapsedTime) { if (choqueObstaculo) { if (timerChoqueObstaculo < tiempoChoqueObstaculoMovimiento) { Random random = new Random(); float rx = random.Next(-3, 3); float ry = random.Next(-3, 3); float rangA = (float)random.NextDouble() * 0.4f - 0.2f; float rangP = (float)random.NextDouble() * 0.4f - 0.2f; position.X += rx; position.Y += ry; coordenadaEsferica.acimutal += rangA; coordenadaEsferica.polar += rangP; } timerChoqueObstaculo += ElapsedTime; if (timerChoqueObstaculo > tiempoChoqueObstaculo) { VariablesGlobales.RestarVida(); choqueObstaculo = false; timerChoqueObstaculo = 0; } } }
private void XwingCollision(PersistentManifold contactManifold, int misilId) { int numContacts = contactManifold.NumContacts; for (int j = 0; j < numContacts && !listaIdMisilesQueColisionaronConXwing.Contains(misilId); j++) { ManifoldPoint pt = contactManifold.GetContactPoint(j); double ptdist = pt.Distance; if (Math.Abs(ptdist) < epsilonContact) { listaIdMisilesQueColisionaronConXwing.Add(misilId); collisionWorld.RemoveCollisionObject(listaMisilesEnemigo[misilId]); listaMisilesEnemigo.Remove(misilId); VariablesGlobales.RestarVida(); } } }
private void LimitarMovimientos() { naveForzadaAVolver = false; if (position.Y > LimiteAltura && coordenadaEsferica.polar < FastMath.PI_HALF) { naveForzadaAVolver = true; DownArrow(VariablesGlobales.elapsedTime); } if (position.X > LimiteLateral && (coordenadaEsferica.acimutal < FastMath.PI_HALF || coordenadaEsferica.acimutal > 3 * FastMath.PI_HALF)) { naveForzadaAVolver = true; RightArrow(VariablesGlobales.elapsedTime); } if (position.X < -LimiteLateral && coordenadaEsferica.acimutal > FastMath.PI_HALF && coordenadaEsferica.acimutal < 3 * FastMath.PI_HALF) { naveForzadaAVolver = true; LeftArrow(VariablesGlobales.elapsedTime); } //Choque con piso trenchrun if (position.Y < -67 && position.X > -35 && position.X < 35 && coordenadaEsferica.polar > FastMath.PI_HALF) { UpArrow(VariablesGlobales.elapsedTime * 4); choqueConPiso = true; } else { if (choqueConPiso) { VariablesGlobales.RestarVida(); choqueConPiso = false; } } //Choque con lateral izq if (position.Y < 5 && position.Y > -60 && position.X > 35 && (coordenadaEsferica.acimutal < FastMath.PI_HALF || coordenadaEsferica.acimutal > 3 * FastMath.PI_HALF)) { RightArrow(VariablesGlobales.elapsedTime * 4); choqueConLateralIzq = true; } else { if (choqueConLateralIzq) { VariablesGlobales.RestarVida(); choqueConLateralIzq = false; } } //Choque con lateral der if (position.Y < 5 && position.Y > -60 && position.X < -35 && coordenadaEsferica.acimutal > FastMath.PI_HALF && coordenadaEsferica.acimutal < 3 * FastMath.PI_HALF) { LeftArrow(VariablesGlobales.elapsedTime * 4); choqueConLateralDer = true; } else { if (choqueConLateralDer) { VariablesGlobales.RestarVida(); choqueConLateralDer = false; } } //Choque con piso alto cerca if (position.Y < 5 && (position.X < -35 && position.X > -110 || position.X > 35 && position.X < 110) && coordenadaEsferica.polar > FastMath.PI_HALF) { UpArrow(VariablesGlobales.elapsedTime * 4); choquePisoAltoCerca = true; } else { if (choquePisoAltoCerca) { VariablesGlobales.RestarVida(); choquePisoAltoCerca = false; } } //Choque con piso alto lejos if (position.Y < -10 && (position.X < -110 || position.X > 110) && coordenadaEsferica.polar > FastMath.PI_HALF) { UpArrow(VariablesGlobales.elapsedTime * 4); choquePisoAltoLejos = true; } else { if (choquePisoAltoLejos) { VariablesGlobales.RestarVida(); choquePisoAltoLejos = false; } } }