示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        //Create instance of the different kind of the enemies
        enemyFactory = new EnemyFactory();
        normalEnemy  = enemyFactory.GetEnemy(EnemyType.Normal);
        bossEnemy    = enemyFactory.GetEnemy(EnemyType.Boss);

        GameManager.Instance.GameStart += OnGameStart;
        GameManager.Instance.GameEnd   += OnGameEnd;
    }
    private void Awake()
    {
        enemies.Add(enemyFactory.GetEnemy(EnemyTypes.flying));
        enemies.Add(enemyFactory.GetEnemy(EnemyTypes.walking));
        enemies.Add(enemyFactory.GetEnemy(EnemyTypes.swimming));

        foreach (IEnemy enemy in enemies)
        {
            enemy.Move();
            enemy.Attack();
            enemy.TakeDamage();
        }
    }
示例#3
0
    void Start()
    {
        enemyList.Add(enemyFactory.GetEnemy(EnemyType.FLYING_ENEMY));
        enemyList.Add(enemyFactory.GetEnemy(EnemyType.SWIMING_ENEMY));
        enemyList.Add(enemyFactory.GetEnemy(EnemyType.WALKING_ENEMY));

        for (int i = 0; i < enemyList.Count; i++)
        {
            enemyList[i].Attact();
            enemyList[i].Move();
            enemyList[i].TakeDamage();
        }
    }
示例#4
0
    private void RandomSpawn()
    {
        if (this.rateOfEnemySpawn <= 0f)
        {
            return;
        }

        float durationBetweenTwoEnemySpawn = 1f / this.rateOfEnemySpawn;

        if (Time.time < this.lastEnemySpawnTime + durationBetweenTwoEnemySpawn)
        {
            // The bullet gun is in cooldown, it can't fire.
            return;
        }

        // Spawn an enemy.
        string prefabPath = "Prefabs/Enemy_01";

        if (Random.value < 0.2f)
        {
            prefabPath = "Prefabs/Enemy_02";
        }

        float randomY = Random.Range(-4f, 4f);

        EnemyFactory.GetEnemy(new Vector3(10f, randomY), Quaternion.Euler(0f, 0f, 0f), prefabPath);
        this.lastEnemySpawnTime = Time.time;

        // Up the difficulty.
        this.rateOfEnemySpawn += this.rateOfEnemySpawn > this.maximumRateOfEnemySpawn ? 0f : this.rateOfEnemySpawnIncreaseStep;
    }
示例#5
0
        public ArenaBattle()
        {
            _player = Player.GetInstance();
            IEnemyFactory enemyFactory = new EnemyFactory();

            _enemy = enemyFactory.GetEnemy();
        }
示例#6
0
    public void GetAnEnemy()
    {
        Debug.Log("Model Get Enemy");
        GameObject tempobj = enemyFac.GetEnemy();

        tempobj.GetComponent <Enemy>().FindMother(enemyFac);
    }
示例#7
0
    //add enemy to scene
    public Enemy AddEnemy()
    {
        if (enemiesToSpawn.Count == 0)
        {
            return(null);
        }
        float   height = GameManager.topBottomLimits.y;
        int     width  = 2100;
        Vector2 pos    = new Vector2();
        int     enemyIndex;

        //always out of screen as we dont want hero to collide on spawn
        pos.x      = ((2 * Random.Range(0, 2)) - 1) * (450 + Random.Range(0, width));
        pos.y      = ((2 * Random.Range(0, 2)) - 1) * Random.Range(0, height);
        enemyIndex = Random.Range(0, enemiesToSpawn.Count);

        Enemy enemy = enemyFactory.GetEnemy(enemiesToSpawn[enemyIndex], pos);

        craftsInScene.Add(enemy.displayObject, enemy);
        string intString = enemiesToSpawn[enemyIndex].Substring(6);

        enemy.paint = GameManager.colorPallette[int.Parse(intString) - 1];
        //Debug.Log("Launch "+enemiesToSpawn[enemyIndex]);

        enemiesToSpawn.RemoveAt(enemyIndex);
        return(enemy);
    }
示例#8
0
    public void SpawnEnemies(EnemyType EnemyToSpawn)
    {
        //HAVE FACTORY MANUFACTURE THEM!!!

        Enemies mEnemy = mFactory.GetEnemy(EnemyToSpawn);

        mEnemy.Fight();
    }
示例#9
0
        private IEnemy GetEnemy()
        {
            var enemy = _factory.GetEnemy();

            enemy.SetPosition(_transform.position);
            enemy.SetRotation(_transform.rotation);
            return(enemy);
        }
示例#10
0
 public void SpawnCommonEnemy(float enemySpawnSpeed)//生成敌人
 {
     spawnSpeed += spawnSpeed * Time.deltaTime;
     while (spawnSpeed >= enemySpawnSpeed)
     {
         spawnSpeed -= enemySpawnSpeed;
         Enemy enemy = enemyFactory.GetEnemy();
         enemies.Add(enemy);
         SearchAndGo(enemy);
     }
 }
        public void Update(float deltaTime)
        {
            timer -= deltaTime;
            if (timer <= 0f)
            {
                enemyManager.Spawn(EnemyFactory.GetEnemy($"Enemy{random.Next(1, 5)}"));
                timer = maxTimer;
                //tot++;
            }

            if (!Enabled)
            {
                Moldels.Enemy.ExtraDepth = 0;
            }
        }
示例#12
0
        private void SpawnSomething()
        {
            TimeSpan nao          = _time.GetCurrent();
            bool     isFirstSpawn = _lastSpawn == TimeSpan.MinValue;
            // Spawn enemy if no enemy was spawned yet or if the time since last spawn is long enough.
            bool shouldSpawnEnemy = (_lastSpawn + _settings.SpawnFrequency <= nao) || isFirstSpawn;

            if (_monstersLeftToSpawn.Count > 0 && shouldSpawnEnemy)
            {
                EnemyTypeEnum enemyType = _monstersLeftToSpawn.Dequeue();
                EnemyBase     enemy     = _enemyFactory.GetEnemy(enemyType);
                enemy.Init();
                enemy.SetLocation(_settings.SpawnPoint);
                enemy.Waypoints     = _settings.Waypoints;
                enemy.OnDeathAction = OnEnemyDeath;
                CurrentMonsters.Add(enemy);
                _lastSpawn = nao;
            }
        }
示例#13
0
    public void Execute()
    {
        if (!this.IsLevelStarted)
        {
            return;
        }

        float timePassedSinceBeginning = Time.time - this.currentLevelStartDate;

        if (this.description == null)
        {
            return;
        }

        if (this.description.Enemies == null)
        {
            return;
        }

        for (int index = 0; index < this.description.Enemies.Length; index++)
        {
            EnemyDescription enemyDescription = this.description.Enemies[index];
            if (this.isEnemySpawned[index] == EnemyState.Spawned)
            {
                continue;
            }

            if (timePassedSinceBeginning < enemyDescription.SpawnDate)
            {
                continue;
            }

            // Spawn !
            EnemyFactory.GetEnemy(enemyDescription.SpawnPosition, Quaternion.Euler(0f, 0f, 0f), enemyDescription.PrefabPath);
            this.isEnemySpawned[index] = EnemyState.Spawned;
        }
    }
示例#14
0
        public void TestMethod1()
        {
            Enemy testEnemy = EnemyFactory.GetEnemy(EnemyFactory.EnemyType.SwordEnemyHorizontal, 100, 100);

            Assert.IsTrue(testEnemy.EnemyWeapon is Rifle);
        }
示例#15
0
 public Battle(Player player, EnemyFactory enemyFactory)
 {
     this.player = player;
     this.enemy  = enemyFactory.GetEnemy();
     menu        = new BattleMenu(player, enemy);
 }