Example #1
0
    public void InitWithData(int idx, _tWave wave)
    {
        m_IndexText.text = (idx + 1).ToString();

        var   rt = GetComponent <RectTransform>();
        float sx = 0 - (wave.monsterNumber - 1) * 100 * 0.5f;

        Vector3 pos = new Vector3(sx, rt.rect.height * 0.25f, 0);

        foreach (var m in wave.monsters)
        {
            // create thief ui from prefab.
            var thief = Instantiate(m_ThiefUIPrefabs[0], pos, Quaternion.identity) as GameObject;
            thief.transform.SetParent(transform, false);

            // set the Text of monster number.
            var numTxt = thief.GetComponentInChildren <Text>();
            if (numTxt)
            {
                numTxt.text = m.number.ToString();
            }

            pos.x += 100;
        }
    }
Example #2
0
    void CreateWaveUI(int idx, _tWave w)
    {
        GameConfig cfg = GameManager.instance.configuration;
        float      y   = cfg.firstWaveTime * m_PixelPerSeconds;

        y += idx * (cfg.waveInterval * m_PixelPerSeconds);

        // Instantiate ui element
        var item = Instantiate(m_WaveUIPrefab, new Vector3(0, y), Quaternion.identity) as GameObject;

        item.transform.SetParent(m_WavePanelRT, false);

        // Initial ui element
        WaveInfoUI wiu = item.GetComponent <WaveInfoUI>();

        wiu.InitWithData(idx, w);

        m_WaveUIs.Add(wiu);
    }
Example #3
0
    void NewWave(int wave)
    {
        if (wave < 0 || wave >= waveData.waveNumber)
        {
            return;
        }

        m_CurrentWave = wave;

        float      delaySeconds = 0f;
        GameObject thieves      = GameObject.Find("Thieves");
        _tWave     wd           = waveData[m_CurrentWave];

        foreach (_tWaveMonster m in wd.monsters)
        {
            for (int i = 0; i < m.number; i++)
            {
                CreateThiefObject(thieves.transform, delaySeconds);
                delaySeconds += Random.Range(configuration.minDelaySeconds, configuration.maxDelaySeconds);
            }
        }
    }