Beispiel #1
0
        void Fire()
        {
            if (!Mathf.Approximately(m_LastFireTime, 0f) &&
                m_LastFireTime + m_FireRate > Time.time)
            {
                return;
            }

            m_LastFireTime = Time.time;
            Serivces.Get <IPoolingService>().Instantiate(m_MuzzleEffects.gameObject, m_MuzzleEffectsPosition.position, m_MuzzleEffectsPosition.rotation);
            Serivces.Get <IPoolingService>().Instantiate(m_Projectile.gameObject, m_ProjectileSpawnSpot.position, m_ProjectileSpawnSpot.rotation);

            GetComponent <AudioSource>().PlayOneShot(m_FireSound);
        }
        private void AddHealthBar(Health health)
        {
            if (!healthBars.ContainsKey(health))
            {
                ///  Debug.Log("AddHealthBar");
                var healthBarObject = Serivces.Get <IPoolingService>().Instantiate <HealthBar>(pr_healthBarPrefab.gameObject);
                //     Debug.Log("healthBarObject " + healthBarObject.gameObject.name);
                //var healtBarObject = Instantiate(pr_healthBarPrefab, transform/*, false*/);
                healthBarObject.SetHealth(health);
                ///healthBarObject.transform.SetParent(this.transform);

                healthBars.Add(health, healthBarObject);
            }
        }
        void CreateAsteroid()
        {
            var index    = Random.Range(0, m_Asteroids.Count - 1);
            var asteroid = Serivces.Get <IPoolingService>().Instantiate <Asteroid>(m_Asteroids[index].gameObject);

            var asteroidGameObject = asteroid.gameObject;
            var spawnSpread        = Random.Range(-m_SpawnRang, m_SpawnRang);

            asteroidGameObject.transform.SetParent(transform);
            asteroidGameObject.transform.localPosition = new Vector3(spawnSpread, 0, 0);

            var v = GameServices.Get <CameraService>().MainCamera.transform.position - transform.position;

            asteroidGameObject.GetComponent <Rigidbody>().AddForce(v.normalized * 250f);
        }
Beispiel #4
0
 public void Fire()
 {
     if (Time.time > shootRateTimeStamp)
     {
         foreach (var point in shootPoints)
         {
             //  GameObject projectile = GameObject.Instantiate(Pr_projectile, point.position, point.transform.rotation) as GameObject;
             var projectile = Serivces.Get <IPoolingService>().Instantiate(Pr_projectile.gameObject, point.position, point.transform.rotation);
             projectile.GetComponent <Projectile>().Damage = damage;
             projectile.tag = this.gameObject.tag;
             ///projectile.transform.SetParent(transform);
         }
         laserAudio.Play();
         shootRateTimeStamp = Time.time + shootRate;
     }
 }
        private void CreateEnemy(Vector3 pos)
        {
            if (GetNumberOfActiveEnemies() >= maxEnemiesOnField)
            {
                return;
            }
            var index     = UnityEngine.Random.Range(0, m_EnemyPrefabs.Count - 1);
            var enemyShip = Serivces.Get <IPoolingService>().Instantiate <Enemy>(m_EnemyPrefabs[index].gameObject);

            enemyShip.GetComponent <EnemyController>().navAgent.nextPosition = pos;
            /// enemyShip.gameObject.transform.SetPositionAndRotation(pos, Quaternion.identity);
            ///    enemySheep.transform.SetParent(this.transform);
            //float scaleModifier = (Random.Range(5f, 8f));
            //asteroid.transform.localScale = new Vector3(scaleModifier, scaleModifier, scaleModifier);
            ///   enemyShip.GetComponent<Health>().InitilazeHealth();
            enemies.Add(enemyShip);
        }
Beispiel #6
0
        void CreateAsteroid(Vector3 pos)
        {
            if (GetNumberOfActiveAsteroids() >= maxAsteroidsCapacity)
            {
                return;
            }


            var index    = Random.Range(0, m_Asteroids.Count - 1);
            var asteroid = Serivces.Get <IPoolingService>().Instantiate <Asteroid>(m_Asteroids[index].gameObject);

            asteroid.transform.position = pos;
            asteroid.transform.SetParent(this.transform);
            float scaleModifier = (Random.Range(5f, 12f));

            asteroid.transform.localScale = new Vector3(scaleModifier, scaleModifier, scaleModifier);
            asteroids.Add(asteroid);
        }
Beispiel #7
0
 public void Explode()
 {
     Serivces.Get <IPoolingService>().Instantiate(m_Explosion.gameObject, transform.position, Quaternion.identity);
     //  GameServices.Get<AudioServise>().OnExplode();
     OnDestroyEnemy();
 }
 void Explode(Vector3 position)
 {
     Serivces.Get <IPoolingService>().Instantiate(m_Explosion.gameObject, position, Quaternion.identity);
     DestroyProjectile();
 }
Beispiel #9
0
 public void Explode()
 {
     Serivces.Get <IPoolingService>().Instantiate(m_Explosion.gameObject, transform.position, Quaternion.identity);
     OnDestroyAsteroid();
 }
Beispiel #10
0
 void Explode()
 {
     Serivces.Get <IPoolingService>().Instantiate(m_Explosion.gameObject, transform.position, Quaternion.identity);
     GetComponentInChildren <MeshRenderer>().forceRenderingOff = true;
 }