Ejemplo n.º 1
0
    //根据currentModuleID生成该种类的塔
    private void InitBasicTower()
    {
        m_CurrentModule = Instantiate(m_TowerModules[(int)currentModuleID], transform.position, transform.rotation) as GameObject;
        //BasicTower附在Tower上
        m_CurrentModule.transform.parent = transform;

        m_BasicTower = m_CurrentModule.GetComponent <BasicTower>();

        m_BasicTower.Init();
        for (int i = 0; i < (int)TowerElem.MaxCount; i++)
        {
            for (int j = 0; j < towerElemCount[i]; j++)
            {
                m_BasicTower.AddElem((TowerElem)i);//添加元素
            }
        }
        m_BasicTower.RecalcInfo();//重新计算塔信息
    }
Ejemplo n.º 2
0
    public void AddElem(TowerElem towerElem)
    {
        elemCount++;
        towerElemCount[(int)towerElem]++;

        //如果加入的元素后,同类元素数量大于等于2,表示当前该塔拥有相同元素,可用于升级3级塔
        if (towerElemCount[(int)towerElem] >= 2)
        {
            multipleElem = towerElem;
            //如果同种元素大于等于2,而且塔的模型不是该种元素的模型
            if (currentModuleID != towerElem)
            {
                //换模型
                Destroy(m_CurrentModule);
                currentModuleID = towerElem;
                InitBasicTower();
                return;
            }
        }
        m_BasicTower.AddElem(towerElem);
        m_BasicTower.RecalcInfo();
    }