Beispiel #1
0
 public void assignWindow(string huaRoot)
 {
     mScript.newObject(out mHuaRoot, huaRoot, 0);
     for (int i = 0; i < GameDefine.MAX_HUA_COUNT; ++i)
     {
         txNGUISprite obj = mScript.newObject(out obj, mHuaRoot, "Mahjong" + i);
         mHuaMahjong.Add(obj);
     }
 }
Beispiel #2
0
 public void assignWindow(string showRoot)
 {
     mScript.newObject(out mShowRoot, showRoot, 0);
     for (int i = 0; i < GameDefine.MAX_HAND_IN_COUNT; ++i)
     {
         txNGUISprite obj = mScript.newObject(out obj, mShowRoot, "Mahjong" + i);
         mShowMahjong.Add(obj);
     }
 }
Beispiel #3
0
 public override void assignWindow()
 {
     string[] rootName = new string[] { "MyDropRoot", "LeftDropRoot", "OppositeDropRoot", "RightDropRoot" };
     for (int i = 0; i < GameDefine.MAX_PLAYER_COUNT; ++i)
     {
         newObject(out mRootList[i], rootName[i], 1);
         for (int j = 0; j < mMaxDropCount; ++j)
         {
             txNGUISprite obj = newObject(out obj, mRootList[i], "Mahjong" + j, 0);
             mDropList[i].Add(obj);
         }
     }
 }
Beispiel #4
0
    public void assignWindow(string rootName)
    {
        mScript.newObject(out mPengGangRoot, rootName);
        for (int i = 0; i < GameDefine.MAX_PENG_TIMES; ++i)
        {
            txUIObject obj = mScript.newObject(out obj, mPengGangRoot, "PengGang" + i);
            mPengGangSingleRoot.Add(obj);
        }
        int pengTimes = mMahjongWindows.Count;

        for (int i = 0; i < pengTimes; ++i)
        {
            for (int j = 0; j < GameDefine.MAX_SINGLE_COUNT; ++j)
            {
                txNGUISprite obj = mScript.newObject(out obj, mPengGangSingleRoot[i], "Mahjong" + j, 0);
                mMahjongWindows[i].Add(obj);
            }
        }
    }
    public void createTile(TileWindow tileWindow, MapTileAdvance tile)
    {
        // 只有真正要使用该地砖时才解析
        if (!tile.mParsed)
        {
            tile.parseTile();
        }
        int    x          = tileIndexToTileX(tile.mIndex);
        int    y          = tileIndexToTileY(tile.mIndex);
        string tileSuffix = x + "_" + y;

        // 偶数行偶数列才渲染大地砖
        if (tileWindow.mBackTile == null && x % 2 == 0 && y % 2 == 0)
        {
            // 大地砖图集
            UIAtlas bngAtlas = getBackTileAtlas(tile);
            // 大地砖图片窗口
            string bngSpriteName = "" + (tile.mBngImgIdx - 1);
            if (bngAtlas != null && bngAtlas.GetSprite(bngSpriteName) != null)
            {
                if (!mBackAtlasList.ContainsKey(tile.mBngAtlasIndex))
                {
                    mBackAtlasList.Add(tile.mBngAtlasIndex, new List <int>());
                }
                // 一个panel中只允许有一个Drawcall
                // 一个panel满时,就应该放入新的panel中
                // 查找该图集存放在哪些panel中
                int        panelIndex     = -1;
                List <int> panelIndexList = mBackAtlasList[tile.mBngAtlasIndex];
                int        panelCount     = panelIndexList.Count;
                for (int j = 0; j < panelCount; ++j)
                {
                    // 找到一个包含该图集,且数量未达上限的panel
                    if (mBackPanelList[panelIndexList[j]].mObjectCount < MAX_WINDOW_PER_PANEL)
                    {
                        panelIndex = panelIndexList[j];
                        break;
                    }
                }
                // 没有找到合适的panel,则创建新的panel
                if (panelIndex == -1)
                {
                    panelIndex = GameUtility.makeID();
                    PanelInfo panelInfo = new PanelInfo();
                    panelInfo.mPanel       = createObject <txNGUIPanel>(mBackRoot, "BackPanel" + panelIndex);
                    panelInfo.mObjectCount = 0;
                    panelInfo.mAtlasIndex  = tile.mBngAtlasIndex;
                    mBackPanelList.Add(panelIndex, panelInfo);
                    mBackAtlasList[tile.mBngAtlasIndex].Add(panelIndex);
                }
                // panel中的窗口计数+1
                mBackPanelList[panelIndex].mObjectCount += 1;
                tileWindow.mBackTile = mWindowPool.createWindow <txNGUISprite>("back_" + tileSuffix, mBackPanelList[panelIndex].mPanel);
                tileWindow.mBackTile.setAtlas(bngAtlas);
                tileWindow.mBackTile.setSpriteName(bngSpriteName, true);
                Vector2 posOffset = tileWindow.mBackTile.getSpriteSize() / 2.0f;
                posOffset += new Vector2(48 * x - mHalfMap.x, mHalfMap.y - 32 * y - 32);
                tileWindow.mBackTile.setLocalPosition(posOffset);
                tileWindow.mBackTile.setDepth(1);
                if (tile.mHasBng)
                {
                    tileWindow.mBackTile.getSprite().color = new Color(0.5f, 0.0f, 0.0f);
                }
                else
                {
                    tileWindow.mBackTile.getSprite().color = Color.white;
                }
            }
        }
        if (tileWindow.mMidTile == null)
        {
            // 小地砖图片窗口
            string midSpriteName = "" + (tile.mMidImgIdx - 1);
            if (midAtlas.GetSprite(midSpriteName) != null)
            {
                tileWindow.mMidTile = mWindowPool.createWindow <txNGUISprite>("mid_" + tileSuffix, mMiddleRoot);
                tileWindow.mMidTile.setAtlas(midAtlas);
                tileWindow.mMidTile.setSpriteName(midSpriteName, true);
                Vector2 posOffset = tileWindow.mMidTile.getSpriteSize() / 2.0f;
                posOffset += new Vector2(48 * x - mHalfMap.x, mHalfMap.y - 32 * y);
                tileWindow.mMidTile.setLocalPosition(posOffset);
            }
        }
        if (tileWindow.mObjectTile == null)
        {
            if (!tile.mHasAni)
            {
                // 加载对象图集
                UIAtlas atlas = getObjTileAtlas(tile);
                // 创建对象图片窗口
                string spriteName = "" + (tile.mObjImgIdx - 1);
                if (atlas != null && atlas.GetSprite(spriteName) != null)
                {
                    tileWindow.mObjectTile = mWindowPool.createWindow <txNGUISprite>("obj_" + tileSuffix, mObjRoot);
                    txNGUISprite objTile = tileWindow.mObjectTile;
                    objTile.setAtlas(atlas);
                    objTile.setSpriteName(spriteName, true);
                    Vector2 posOffset = objTile.getSpriteSize() / 2.0f;
                    posOffset += new Vector2(48 * x - mHalfMap.x, mHalfMap.y - 32 * y);
                    objTile.setLocalPosition(posOffset);
                    objTile.setDepth(y);
                    if (!tile.mCanWalk)
                    {
                        BoxCollider collider = objTile.getBoxCollider(true);
                        collider.size = objTile.getSpriteSize();
                    }
                    objTile.setHandleInput(!tile.mCanWalk);
                    if (tile.mHasObj)
                    {
                        objTile.getSprite().color = new Color(0.5f, 0.0f, 0.0f);
                    }
                    else
                    {
                        objTile.getSprite().color = Color.white;
                    }
                }
            }
        }
        if (tileWindow.mEffect == null)
        {
            if (tile.mHasAni)
            {
                // 加载对象图集
                UIAtlas atlas = getEffectAtlas(tile);
                // 创建对象图片窗口
                if (atlas != null)
                {
                    tileWindow.mEffect = mWindowPool.createWindow <txNGUISpriteAnim>("effect_" + tileSuffix, mObjRoot);
                    tileWindow.mEffect.setAtlas(atlas);
                    tileWindow.mEffect.setTextureSet(intToString(tile.mObjImgIdx - 1));
                    tileWindow.mEffect.play();
                    tileWindow.mEffect.setLoop(LOOP_MODE.LM_LOOP);
                    tileWindow.mEffect.setSpeed(0.5f);
                    Vector2 posOffset = new Vector2(0.0f, tileWindow.mEffect.getSpriteSize().y * 1.5f);
                    posOffset += new Vector2(48 * x - mHalfMap.x, mHalfMap.y - 32 * y);
                    tileWindow.mEffect.setLocalPosition(posOffset);
                    tileWindow.mEffect.setDepth(y);
                }
            }
        }
    }