Пример #1
0
 protected virtual void Spawn()
 {
     for (int i = 0; i < spawnAmount; i++)
     {
         Vector2 randomPosition = transform.position + new Vector3(Random.Range(-spawnAmount / 5, spawnAmount / 5), Random.Range(-spawnAmount / 5, spawnAmount / 5));
         objectPooler.SpawnFromPool("SwarmQueenMinion", randomPosition, Quaternion.identity);
     }
 }
Пример #2
0
 private void SpawnEnemy()
 {
     if (Spawning)
     {
         EnemiesAlive++;
         Vector2 spawnPosition = GenerateSpawnPosition();
         string  enemy         = enemyNames[Random.Range(0, enemyNames.Count)];
         RObjectPooler.SpawnFromPool(enemy, spawnPosition, Quaternion.identity);
     }
 }
Пример #3
0
        protected virtual void OnTriggerEnter2D(Collider2D collider)
        {
            BaseEntity entity = collider.GetComponent <BaseEntity>();

            if (entity != null && !entity.isDead)
            {
                //gameManager.StartCoroutine(gameManager.Sleep(0.001f));
                entity.KilledByIndex = WeaponIndex;
                entity.OnTakeDamage?.Invoke(Modules["Damage"].GetStatValue());
                objectPooler.SpawnFromPool(OnHitEffectName, transform.position, Quaternion.identity);
                gameObject.SetActive(false);
            }
        }
Пример #4
0
        public override void Fire(ObjectPooler objectPooler, Transform player)
        {
            float spread = RWeaponData.Modules["ProjectileSpread"].GetStatValue();
            float count  = (int)RWeaponData.Modules["ProjectileCount"].GetStatValue();

            float angleIncrease;

            //Make sure there are no divisions by 0 in case of single projectile
            if (count == 1)
            {
                angleIncrease = 0;
                spread        = 0;
            }
            else
            {
                angleIncrease = spread / (count - 1);
            }

            for (int i = 0; i < count; i++)
            {
                //Calculate new rotation
                float newRotation = (player.eulerAngles.z - angleIncrease * i) + (spread / 2);

                //Spawn Projectile with extra rotation based on projectile count
                GameObject projectileObject = objectPooler.SpawnFromPool(ProjectileName, player.position + (player.up / 3),
                                                                         Quaternion.Euler(player.eulerAngles.x, player.eulerAngles.y, newRotation));

                //Initialize projectile
                PlayerProjectile projectile = projectileObject.GetComponent <PlayerProjectile>();
                projectile.WeaponIndex = WeaponIndex;
                projectile.Modules     = RWeaponData.Modules;
                projectile.StartCoroutine(projectile.DisableAfterTime());
            }
        }
Пример #5
0
 // Update is called once per frame
 protected virtual void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         objectPooler.SpawnFromPool("CoinPickupEffect", transform.position, Quaternion.identity);
         playerScript.AddUnits(Value);
         gameObject.SetActive(false);
         //StartCoroutine(MoveToUnits());
     }
 }
Пример #6
0
        public override void Fire(ObjectPooler objectPooler, Transform player)
        {
            GameObject Mine = objectPooler.SpawnFromPool("PlayerMine", player.position - (player.up * 0.75f), Quaternion.identity);

            Mine.GetComponent <Rigidbody2D>().AddForce(-player.up * 150);
            PlayerProjectile projectile = Mine.GetComponent <PlayerProjectile>();

            projectile.Modules = RWeaponData.Modules;
            projectile.Initialize();
            projectile.WeaponIndex = WeaponIndex;
            projectile.StartCoroutine(projectile.DisableAfterTime());
        }
Пример #7
0
        protected virtual void SpawnParticleEffect()
        {
            GameObject effect = objectPooler.SpawnFromPool(ParticleEffect, transform.position, Quaternion.identity);

            effect.transform.localScale *= ParticleEffectScale;
        }