Example #1
0
        private void SwarmEnemy()
        {
            _spawnDeltaTime    -= Time.deltaTime;
            _timeBetweenSpawns -= Time.deltaTime;

            var number = _random.Next(-5, 5);


            if (_spawnDeltaTime <= 0 && EnemiesSpawnedPerSwarm < EnemiesPerSwarm && _totalEnemiesSwarmed < TotalNumEnemies)
            {
                var spawnPosition = new Vector3(Random.Range(-SpawnValues.position.x, SpawnValues.position.x),
                                                SpawnValues.position.y, SpawnValues.position.z);

                if (number > 0)
                {
                    GameObjectController.Instantiate(PurpleEnemy, spawnPosition, Quaternion.identity);
                }
                else
                {
                    GameObjectController.Instantiate(RedEnemy, spawnPosition, Quaternion.identity);
                }

                EnemiesSpawnedPerSwarm++;
                _totalEnemiesSwarmed++;
                _spawnDeltaTime = SpawnTime;
            }

            if (_timeBetweenSpawns <= 0)
            {
                EnemiesSpawnedPerSwarm = 0;
            }
        }
Example #2
0
        void FireInFormation()
        {
            if (!_swarmFormation.InFormation)
            {
                return;
            }

            GameObjectController.Instantiate(Shot, ShotSpawn.position, ShotSpawn.rotation);
            audio.Play();
        }
Example #3
0
        /// <summary>
        /// Updates every frame our scene.
        /// </summary>
        private void Update()
        {
            if (GameObjectController.IsConnected() && !networkView.isMine)
            {
                enabled = false;
                return;
            }

            if (Input.GetKeyDown(KeyCode.T) && Time.time > _nextFire)
            {
                _nextFire = Time.time + FireRate;
                var clone = GameObjectController.Instantiate(Shot, ShotSpawn.position, ShotSpawn.rotation, ignoreServerCheck: true);
                audio.Play();
            }
        }
Example #4
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.tag.Equals("WorldBoundary") || other.tag == "Enemy" || other.tag == "EnemyRed" || other.tag == "EnemyBolt")
            {
                return;
            }

            try
            {
                if (other.tag.Equals("Player") && (gameObject.tag.Equals("EnemyBolt") || gameObject.tag.Equals("Enemy") || gameObject.tag.Equals("EnemyRed")))
                {
                    GameObjectController.Instantiate(PlayerExplosion, other.transform.position, other.transform.rotation);
                    //GameObjectController.Destroy(gameObject);
                    //GameObjectController.Destroy(other.gameObject);
                    Debug.Log(string.Format("Destroyed By Contact - {0} Collided with {1}", gameObject.name, other.gameObject.name));
                    _gameControllerObject.IsPlayerAlive = false;
                }

                Debug.Log(other.name);

                if ((gameObject.tag.Equals("Enemy") || gameObject.tag.Equals("EnemyRed")) && other.tag.Equals("Bolt"))
                {
                    _gameControllerObject.EnemiesKilled++;
                    _gameControllerObject.AddScore(ScoreValue);
                }

                if (Explosion != null)
                {
                    GameObjectController.Instantiate(Explosion, transform.position, transform.rotation);
                }


                GameObjectController.Destroy(gameObject);
                GameObjectController.Destroy(other.gameObject);
                Debug.Log(string.Format("Destroyed By Contact - {0} Collided with {1}", gameObject.name, other.gameObject.name));
            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
            }
        }
Example #5
0
 public void SpawnPlayer()
 {
     GameObjectController.Instantiate(Player1, new Vector3(0, 0), Quaternion.identity, 0);
     IsPlayerAlive = true;
 }