/// <summary> /// Gera duas respostas falsas para serem apresentadas juntamente da correta /// </summary> private void CreateAnswers() { chanceToSpawnCorrectAnswer = 0.1; correctAnswerSpawned = false; correctAnswer = null; this.answers = new Answer[3]; for (int i = 0; i < 3; i++) { if (PublicRandom.NextDouble() > chanceToSpawnCorrectAnswer || correctAnswerSpawned) { this.answers[i] = AnswerFactory.CreateAnswer((Renderer3D)Renderer, CollidableObjects, question, currentAnswerIndex, false, answers); } else { correctAnswerSpawned = true; this.answers[i] = AnswerFactory.CreateAnswer((Renderer3D)Renderer, CollidableObjects, question, currentAnswerIndex, true, answers); correctAnswer = this.answers[i]; } } //se o jogador não recebeu 1 ponto de graça, então somamos 1 ao valor da questão atual if (!pityPoint) { currentAnswerValue += 1; } pityPoint = false; }
private Texture2D GetRandomPropTexture(out float baseScale, double max = 1.0) { baseScale = 0; Texture2D tex; switch (GetRandomPropType(max)) { case PropType.CACTUS: tex = cactus[PublicRandom.Next(cactus.Length)]; baseScale = (float)PublicRandom.NextDouble(0.5); break; case PropType.GRASS: tex = grass[PublicRandom.Next(grass.Length)]; baseScale = (float)PublicRandom.NextDouble(0.1, 0.4); break; case PropType.ROCK: tex = rock[PublicRandom.Next(rock.Length)]; baseScale = (float)PublicRandom.NextDouble(0.1, 0.75); break; case PropType.TREE: tex = tree[PublicRandom.Next(tree.Length)]; baseScale = (float)PublicRandom.NextDouble(0.5) + PublicRandom.Next(1, 3) + PublicRandom.Next(2); break; default: tex = null; break; } return(tex); }
public Answer(Renderer3D renderer, IEnumerable <CollidableGameObject> collidableObjects, string text) : base(renderer, collidableObjects) { this.text = text; //"gravidade" VariableMovementComponent vmc = new VariableMovementComponent(this, 30, Vector3.Down / 1000 * (float)PublicRandom.NextDouble(0.01f), Vector3.Down / 100); vmc.LowerVelocityThreshold = Vector3.Down / 4; addComponent(vmc); }
/// <summary> /// Altera o texto de uma resposta. /// </summary> /// <param name="a">A resposta que terá seu texto alterado.</param> private void ChangeAnswer(Answer a) { string text; double bonusLottery = PublicRandom.NextDouble(); if (correctAnswerSpawned || (PublicRandom.NextDouble() > chanceToSpawnCorrectAnswer && fakeSpawnCount < maxFakeSpawnCount || (bonusLottery > bonusChance && !bonusSpawned))) //alterar a resposta para alguma outra incorreta { if (!bonusSpawned && bonusLottery <= bonusChance && !correctAnswerSpawned && bonusCount < 3) { text = "+1"; a.IsBonus = true; bonusSpawned = true; bonusCount++; } else { text = IncorrectAnswer(); a.IsBonus = false; bonusSpawned = false; } //se a resposta sendo alterada for a correta, avisar o sistema para que uma nova resposta correta possa ser gerada futuramente if (correctAnswer != null && a.Equals(correctAnswer)) { correctAnswerSpawned = false; correctAnswer = null; } chanceToSpawnCorrectAnswer *= 3; //triplica a chance de "spawnar" a resposta correta na próxima vez fakeSpawnCount++; } else //alterar a resposta para a resposta correta { a.IsBonus = false; bonusSpawned = false; text = CorrectAnswer(); chanceToSpawnCorrectAnswer = 0.1; fakeSpawnCount = 0; bonusCount = 0; correctAnswerSpawned = true; this.correctAnswer = a; } a.Text = text; }
private PropType GetRandomPropType(double max = 1.0) { double rdn = PublicRandom.NextDouble(0, max); PropType type = PropType.NONE; if (rdn < propsWeight[0]) { type = PropType.TREE; } else if (rdn < propsWeight[1]) { type = PropType.CACTUS; } else if (rdn < propsWeight[2]) { type = PropType.GRASS; } else if (rdn < propsWeight[3]) { type = PropType.ROCK; } return(type); }
/// <summary> /// Move uma resposta no eixo Z por um valor aleatório entre 3 e 5. /// </summary> /// <param name="a">A resposta a ser movida.</param> public void MoveAnswer(Answer a) { float newZ = player.Position.Z + PublicRandom.Next(4, 7); bool usableZ = false; int tries = 0; do { newZ += (float)PublicRandom.NextDouble(0.25); foreach (Answer answer in answers) { usableZ = (answer.Position.Z >= newZ + minAnswerDistance || answer.Position.Z <= newZ - minAnswerDistance); if (!usableZ) { break; } } tries++; } while (!usableZ && tries < 50); a.Position = new Vector3(a.Position.X, PublicRandom.Next(3, 5), newZ); a.Visible = false; ChangeAnswer(a); }
private void KickBall() { Vector3 kickDeviation = Vector3.Zero; if (!makeGoal) { kickDeviation.Y = (float)PublicRandom.NextDouble(0, 0.2); if (PublicRandom.NextDouble() > 0.5) { kickDeviation.Y *= -1; } kickDeviation.Z = -(float)PublicRandom.NextDouble(0.15, 0.25); kickDeviation.X = -(float)PublicRandom.NextDouble(0, 0.1); if (PublicRandom.NextDouble() > 0.5) { kickDeviation.X *= -1; } } ball.Position = ball.Position * (Vector3.UnitX + Vector3.UnitZ); ball.Kick2(new Vector3(0, 0.4f, 0.3f) + kickDeviation, new Vector3(-kickDeviation.X / 1000, -0.05f, -0.0005f), Vector3.Zero); }