public bool hitEnemy(Student s) { //if x is target if ((centerPosition.x > (s.centerPosition.x - (s.width / 2))) && (centerPosition.x < (s.centerPosition.x + (s.width / 2)))) { //if y is target if ((centerPosition.y > (s.centerPosition.y - (s.height / 2))) && (centerPosition.y < (s.centerPosition.y + (s.height / 2)))) { return true; } } return false; }
public void genStudent() { if (sClass < stages[level].classes) { if (generatedStudents < stages[level].studentsPerClas) { if (nextStudentSpown <= timer) { formPlay.tbVave.Text = vave + "/" + stages[level].classes; Random r = new Random(); int ofset = r.Next(1, 39); Student student = new Student(new Point(stages[level].startPosition.x, stages[level].startPosition.y + ofset), 20, 20, stages[level].studentSpeed, 2, stages[level].studentHealth,(int)( stages[level].studentHealth*0.4), "12"); students.Add(student);// here is the problem nextStudentSpown = timer + 30; generatedStudents++; } } else { generatedStudents = 0; nextStudentSpown = timer + 400; sClass++; stages[level].studentsPerClas = (int)(stages[level].studentsPerClas * 1.5); stages[level].studentHealth = (int)(stages[level].studentHealth * 1.2); vave++; } } else { if (students.Count == 0) { formPlay.timer.Stop(); victory(); } } }