} // public void Initialize(float hp)

    void CheckHealth()
    {
        if (health <= 0f)
        {
            Destroy(gameObject);
            Global.score += 10;
            score.text    = Global.score.ToString();
            ObjectFactory.CreateExplosion(transform.position);
            if (--totalEnemies <= 0)
            {
                enemySpawner.CreateEnemies();
            }
        }
    } // void CheckHealth()
Esempio n. 2
0
        IEnumerator AddPlayers()
        {
            while (!m_AreClientsReady)
            {
                yield return(null);

                foreach (NetworkConnection connection in NetworkServer.connections.Values)
                {
                    if (connection.isReady)
                    {
                        m_AreClientsReady = true;
                    }
                    else
                    {
                        m_AreClientsReady = false;
                    }
                }
            }

            m_Enemies        = m_EnemySpawner.CreateEnemies();
            m_TanksTransform = m_EnemySpawner.GetEnemiesTransforms();
            List <TankManager> tanks = m_TanksNetwork.GetPlayersTanks();

            for (int i = 0; i < tanks.Count; i++)
            {
                m_Tanks.Add(tanks[i]);
            }

            for (int i = 0; i < m_Tanks.Count; i++)
            {
                m_TanksTransform.Add(m_Tanks[i].m_Instance.transform);
            }
            UpdateAllTanks();
            SetCameraTargets();
            RpcSyncTanks(m_Tanks, m_TanksTransform, m_Enemies);
        }
Esempio n. 3
0
 private List <Enemy> CreateEnemies() => enemySpawner.CreateEnemies();