// Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;

        if (timer >= 0.6f)
        {
            timer = 0;
            float       random   = Random.Range(-1f, 1f);
            Vector3     position = new Vector3(random, 2f, 0);
            Quaternion  rot      = new Quaternion();
            EnemiesType enemy    = (EnemiesType)Random.Range(0, 3);
            switch (enemy)
            {
            case EnemiesType.NormalEnemy:
                Instantiate(Enemigo1Prefab, position, rot);
                break;

            case EnemiesType.FasterEnemy:
                Instantiate(Enemigo2Prefab, position, rot);
                break;

            case EnemiesType.ShooterEnemy:
                Instantiate(Enemigo3Prefab, position, rot);
                break;
            }
        }
    }
Example #2
0
    void Awake()
    {
        TextAsset   enemyDataText = Resources.Load <TextAsset>("enemies");
        EnemiesType enemyData     = JsonUtility.FromJson <EnemiesType>(enemyDataText.text);

        Enemies.allEnemyTypes   = enemyData.enemies;
        Enemies.allEnemyPrefabs = this._allEnemies;
        Enemies.allBosses       = this._allBosses;
    }
        private void AsteroidBuckShot(int childNumber, EnemiesType type)
        {
            for (int i = 0; i < childNumber; i++)
            {
                var asteroidMed = app.ObjectPooler.SpawnFromPool(PoolObjectsTag.Asteroid);
                var asteroid    = asteroidMed.GetComponent <Asteroid>();
                asteroid.type = type;
                asteroidMed.transform.position = transform.position;

                asteroid.OnObjectSpawn();
            }
        }
Example #4
0
        public void AddEnemyByID(string ID)
        {
            ElementIndex t = ResourcesManager.instance.GetEnemyIndex(ID);

            try{
                EnemiesType        obj = ResourcesManager.instance.enemiesPool [t.first] [t.second];
                List <EnemiesType> l   = new List <EnemiesType> ();
                l.Add(obj);
                boardScript.LayoutObjectAtRandom_Enemy(l, 1, 1);
            }catch {
                return;
            }
        }
Example #5
0
        //OnCantMove is called if Enemy attempts to move into a space occupied by a Player, it overrides the OnCantMove function of MovingObject
        //and takes a generic parameter T which we use to pass in the component we expect to encounter, in this case Player
        protected override void OnCantMove <T> (T component)
        {
            //Declare hitPlayer and set it to equal the encountered component.
            Player hitPlayer = component as Player;

            //Call the LoseFood function of hitPlayer passing it playerDamage, the amount of foodpoints to be subtracted.
            if (!iscopied)
            {
                //type_copy = ResourcesManager.instance.enemyPool [ResourcesManager.instance.GetEnemyPoolIndex (Enemy_ID)];
                ElementIndex v2t = ResourcesManager.instance.GetEnemyIndex(Enemy_ID);
                type_copy = ResourcesManager.instance.enemiesPool [v2t.first] [v2t.second];
                iscopied  = true;
            }
            if (HP > 0)
            {
                //ChangeHP (-hitPlayer.Atk);

                if (type_copy.effect == null)
                {
                    hitPlayer.BeAttacked(playerDamage);                     // 若无技能,则只产生普通攻击影响
                }
                else
                {
                    float ran = Random.Range(0.0f, 1.0f);                      //计算几率
                    if (ran < type_copy.rate)
                    {
                        type_copy.effect.Call(hitPlayer);                          //若随机满足,则产生技能影响
                    }
                    else
                    {
                        hitPlayer.BeAttacked(playerDamage);                         // 若不满足,则产生普通攻击影响
                    }
                }

                //Set the attack trigger of animator to trigger Enemy attack animation.
                animator.SetTrigger("enemyAttack");

                //Call the RandomizeSfx function of SoundManager passing in the two audio clips to choose randomly between.
                SoundManager.instance.RandomizeSfx(attackSound1, attackSound2);
            }
        }
Example #6
0
 /// <summary>
 /// Quick access to any enemy data
 /// </summary>
 /// <param name="type">Enemy type</param>
 /// <returns></returns>
 public Enemies GetEnemyData(EnemiesType type)
 {
     return(enemyDict[type]);
 }
Example #7
0
 public CastleDB(TextAsset castleDBAsset)
 {
     parsedDB = new CastleDBParser(castleDBAsset);
     Enemies  = new EnemiesType();
 }