public void Update(float deltaTime) { if (!waveStarted) { if (spawnedSkeletons.Exists(x => ((x as IHuman) != null && (x as IHuman).IsLive))) { return; } waveWaitDown += deltaTime; if (waveWaitDown >= WAVE_WAIT) { WaveNumber++; waveStarted = true; waveWaitDown = 0f; } } else { waveDown += deltaTime; if (waveDown >= WaveDuration) { waveStarted = false; waveDown = 0f; } else { spawnDown += deltaTime; if (spawnDown >= SpawnInterval) { System.Random rnd = new System.Random(); int r = rnd.Next(0, 3); Vector3K position = new Vector3K(-15f, 15f, 0f); switch (r) { case 1: position = new Vector3K(15f, 15f, 0f); break; case 2: position = new Vector3K(15f, -15f, 0f); break; case 3: position = new Vector3K(-15f, -15f, 0f); break; } SkeletonObject skeleton = new SkeletonObject(position, new Vector3K(0f, 0f, 0f), new Vector3K(2f, 2f, 2f), new Vector3K(0f, 0f, 0f)); SkeletonObjectController skeletonController = ObjectFactory.GetObject(skeleton) as SkeletonObjectController; MissionController.AddDynamicObject(skeletonController); spawnedSkeletons.Add(skeletonController); spawnDown = 0f; } } } }
public void Update(float deltaTime) { time += deltaTime; if (Math.Abs(time - lastTimeSpawn) >= SpawnInterval) { Random rnd = new Random(); float x = rnd.Next(-50, 50); float y = rnd.Next(-50, 50); float z = rnd.Next(-50, 50); SkeletonObject skeleton = new SkeletonObject(new Vector3K(x, y, z), new Vector3K(0f, 0f, 0f), new Vector3K(2f, 2f, 2f), new Vector3K(0f, 0f, 0f)); MissionController.AddDynamicObject(ObjectFactory.GetObject(skeleton)); lastTimeSpawn = time; } }