Exemple #1
0
        protected override void OnStartRunning()
        {
            base.OnStartRunning();
            setup = EnemySpawner.Instance;

            mainRandom = new Random((uint)System.DateTime.Now.Millisecond);

            enemyPrefab = EntityManager.CreateArchetype(
                typeof(EnemyTag),
                typeof(Translation),
                typeof(Rotation),
                typeof(LocalToWorld)
                );
        }
Exemple #2
0
        void Awake()
        {
            if (Instance != null && Instance != this)
            {
                Destroy(gameObject);
            }
            else
            {
                Instance = this;
            }


            player       = FindObjectOfType <PlayerManager>().transform;
            enemySpawner = FindObjectOfType <EnemySpawner>();
        }
Exemple #3
0
        protected override void OnStartRunning()
        {
            base.OnStartRunning();
            setup = EnemySpawner.Instance;

            enemyTypePrefab = EntityManager.CreateArchetype(
                typeof(Translation),
                typeof(Rotation),
                typeof(LocalToWorld),
                typeof(LocalToParent),
                typeof(Parent)
                );

            mainRandom     = new Random(1);
            EnemyEnumCount = (int)Enum.GetValues(typeof(EnemyEnum)).Cast <EnemyEnum>().Max() + 1;
        }
        IEnumerator HandleSpawnEnemy()
        {
            while (true)
            {
                yield return(new WaitForSeconds(enemySpawnDelay + UnityEngine.Random.value * 0.5F));

                float        random        = UnityEngine.Random.value;
                EnemySpawner chosenSpawner = spawners[0];
                foreach (var spawner in spawners)
                {
                    if (random <= spawner.spawnThreshold)
                    {
                        chosenSpawner = spawner;
                        break;
                    }
                }
                chosenSpawner.Spawn();
            }
        }
Exemple #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Random     rnd   = new Random();
            GameObject world = scene.World;

            {
                var noise = new[]
                {
                    Properties.Resources.space_noise_1,
                    Properties.Resources.space_noise_2,
                    Properties.Resources.space_noise_3
                };

                world.AddChild(new SpaceNoise(noise[0], 3 * 1.5f, 1.00f, false, false));
                world.AddChild(new SpaceNoise(noise[0], 3 * 2.5f, 2.00f, true, true));
                world.AddChild(new SpaceNoise(noise[1], 3 * 3.5f, 1.50f, false, true));
                world.AddChild(new SpaceNoise(noise[2], 3 * 5.5f, 2.00f, true, false));
            }

            world.AddChild(new StarSpawner());

            EnemySpawner[] spawners = new EnemySpawner[]
            {
                new EnemySpawner(0, 500, new FuncBehavior(x => Math.Sin(x * 10) * 0.9, 175)),
                new EnemySpawner(11, 500, new FollowPlayerBehavior(200)),
                new EnemySpawner(29, 500, new FuncBehavior(x => - 0.9 * (2 / Math.PI) * Math.Asin(Math.Sin(Math.PI * x * 3)), 250)),
                new EnemySpawner(20, 500, new FlockingBehavior(200)),
                new EnemySpawner(42, 500, new FuncBehavior(x => (Math.Sin(x * 10) + Math.Sin(x * 5)) * 0.5, 275)),
                new EnemySpawner(63, 500, new FuncBehavior(x => Math.Atan(x * 10 - 5) * -0.5, 200)),
                new EnemySpawner(54, 500, new FuncBehavior(x => (Math.Sin((x + 1) * 10 + 15) - Math.Sin((x + 1) * 15)) * 0.2 - 0.4, 300)),
            };
            world.AddChildren(spawners);
            world.AddChild(new EnemySpawnerDirector(spawners));

            PlayerShip player = new PlayerShip(33);

            player.CenterY = world.CenterY;
            player.Left    = world.Left + 100;
            world.AddChild(player);
        }