예제 #1
0
        private void AddStudent()
        {
            /*Randomly select a student to add*/
            int random = new Random().Next();
            Student student = new Student(studentTextureArray[random%4],
                map.Waypoints.Peek(), 30+10*waveNumber, 2+waveNumber, 0.75f+0.2f*waveNumber, random%4);

            student.SetWaypoints(map.Waypoints);

            students.Add(student);

            spawnTimer = 0;
            studentsSpawned++;
        }
예제 #2
0
        public virtual void GetClosestStudent(List<Student> students)
        {
            /*Get the closest student and set it to be the target*/
            target = null;
            float smallestRange = radius;

            foreach (Student student in students)
            {
                if (Vector2.Distance(center, student.Center) < smallestRange)
                {
                    smallestRange = Vector2.Distance(center, student.Center);
                    target = student;
                }
            }
        }
예제 #3
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            paperTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;

            /*Set the refresh speed of the paper images*/ 
            if (target != null )
            {
                FaceTarget();

                if (!IsInRange(target.Center) || target.IsDead)
                {
                    target = null;
                    paperTimer = 0;
                }
                RefreshSpeed = 4;
            }
            else
            {
                RefreshSpeed = 0;
            }
        }