Esempio n. 1
0
 // Start is called before the first frame update
 void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     _instance = this;
     //DontDestroyOnLoad(this.gameObject);
 }
    public void Init(IDamageable healthContainer, int spawnAmount, float pushForce)
    {
        m_HealthContainer = healthContainer;
        m_SpawnAmount     = spawnAmount;
        m_PushForce       = pushForce;

        m_SpawnManager = FindObjectOfType <AsteroidSpawnManager>();
        Assert.IsNotNull(m_SpawnManager,
                         $"Couldn't find AsteroidSpawnManager in the scene. {name} requires it.");
        Assert.IsNotNull(m_HealthContainer, $"IDamageable couldn't been found on {gameObject.name}.");
        RenewSubscriptions();
    }
Esempio n. 3
0
 // Start is called before the first frame update
 void Start()
 {
     gameIsRunning        = true;
     gm                   = GameManager.Instance;
     gm.OnStateChange    += HandleOnStateChange;
     asm                  = AsteroidSpawnManager.Instance;
     speed                = Random.Range(0.1f, 0.6f);
     rotationSpeed        = Random.Range(0.5f, 1.5f);
     newScale             = Random.Range(0.5f, 4);
     transform.localScale = new Vector3(newScale, newScale, newScale);
     explosion            = Instantiate(explosionParticle, transform.position, Quaternion.identity);
 }
Esempio n. 4
0
 // Start is called before the first frame update
 void Awake()
 {
     gm = GameManager.Instance;
     gm.OnStateChange    += HandleOnStateChange;
     asteroidSpawnManager = AsteroidSpawnManager.Instance;
     //asteroidManager = GameObject.FindGameObjectWithTag("AsteroidManager");
     //planet = GameObject.FindGameObjectWithTag("Planet");
     //asteroidManager.gameObject.SetActive(false);
     //planet.gameObject.SetActive(false);
     gm.SetGameState(GameState.MainMenu);
     costText.text = DefenseFund.ToString();
     buildPlatformQuantity.text = amountOfTurretPlatformsAllowed.ToString();
     if (gameOverPanel == null)
     {
         Debug.Log("Game over panel has not been assigned.", this);
     }
 }