Пример #1
0
        public void TestMethod1()
        {
            string[] gameObjects = new string[] { "Asteroid1", "Asteroid2", "Asteroid3", "Alien1", "Alien2", "Boss1" };

            var script = new GameSpawnEngine <string>();

            script.Waves.Add(new TestWave1(0, 180, new string[] { gameObjects[0], gameObjects[1], gameObjects[2] }));
            script.Waves.Add(new TestWave2(90, 180, new string[] { gameObjects[3] }));
            script.Waves.Add(new TestWave2(90, 120, new string[] { gameObjects[4] }));
            script.Waves.Add(new TestWave3Boss(180, 0, new string[] { gameObjects[5] }));

            script.Initialize(800, 600);

            float gameTime = 0f;

            while (gameTime < 5 * 60)
            {
                var deltaTime = (float)1 / 60;

                var spawns = script.Update(deltaTime);

                foreach (var spawn in spawns)
                {
                    Debug.WriteLine(spawn);
                }

                //Increame by 1 60th/sec
                gameTime += deltaTime;
            }
            Console.ReadKey();
        }
Пример #2
0
    public virtual void Update()
    {
        var spawns = _spawner.Update(Time.deltaTime);

        foreach (var spawn in spawns)
        {
            var obj        = Instantiate(spawn.GameObject) as Transform;
            var gameObject = obj.gameObject;
            var position   = mainCamera.ScreenToWorldPoint(new Vector3(spawn.X, spawn.Y, spawn.Z));
            position.z = 0f;
            gameObject.transform.position = position;
            gameObject.transform.rotation = new Quaternion(spawn.RX, spawn.RY, spawn.RZ, 0f);

            //Let the object call back to this controller to notify of destruction
            var gameObjectNotifier = gameObject.AddComponent(typeof(GameObjectNotifier)) as GameObjectNotifier;
            gameObjectNotifier.levelController = this;

            _activeObjects.Add(gameObject);
        }
    }