示例#1
0
 public static AdaptationResolutionMG getInstance()
 {
     if (null == instance)
     {
         instance = new AdaptationResolutionMG();
     }
     return(instance);
 }
 public static AdaptationResolutionMG getInstance()
 {
     if( null == instance )
     {
         instance = new AdaptationResolutionMG();
     }
     return instance;
 }
示例#3
0
    void Start()
    {
        //初始化出牌权
        FightController.getInstance().RightToPlay = FightController.RIGHTTOPLAY.MINE;

        float doSizeH = AdaptationResolutionMG.getInstance().getDoSizeHeight();

        float   bg_topHeight         = bg_top.transform.GetComponent <RectTransform>().sizeDelta.y *doSizeH;
        float   bg_bottomHeight      = bg_bottom.transform.GetComponent <RectTransform>().sizeDelta.y *doSizeH;
        Vector2 oldMiddPanelShowSize = middPanelShow.transform.GetComponent <RectTransform>().sizeDelta *doSizeH;

        FightUIData.getInstance().setFightUIHeight(bg_topHeight, bg_bottomHeight);

        middPanelShow.transform.GetComponent <RectTransform>().sizeDelta = new Vector2(Screen.width, oldMiddPanelShowSize.y);

        middPanel.transform.GetComponent <RectTransform>().sizeDelta = new Vector2(Screen.width, oldMiddPanelShowSize.y);
        mainPanel.transform.GetComponent <RectTransform>().sizeDelta = new Vector2(Screen.width, Screen.height);
        bg_top.transform.GetComponent <RectTransform>().sizeDelta    = new Vector2(Screen.width, bg_topHeight);

        GameObject bg_name = bg_top.transform.FindChild("bg_name").gameObject;

        doSizeUI(bg_name, doSizeH);


        GameObject icon_hp = bg_top.transform.FindChild("icon_hp").gameObject;

        doSizeUI(icon_hp, doSizeH);

        bg_bottom.transform.GetComponent <RectTransform>().sizeDelta = new Vector2(Screen.width, bg_bottomHeight);
        icon_hp = bg_bottom.transform.FindChild("icon_hp").gameObject;
        doSizeUI(icon_hp, doSizeH);

        //初始化战斗按钮相关
        GameObject Buttons = bg_bottom.transform.FindChild("Buttons").gameObject;

        doSizeUI(Buttons, doSizeH);
        GameObject ButtonNoOut = Buttons.transform.FindChild("ButtonNoOut").gameObject;
        GameObject ButtonTip   = Buttons.transform.FindChild("ButtonTip").gameObject;
        GameObject ButtonAtk   = Buttons.transform.FindChild("ButtonAtk").gameObject;

        EventListener.Get(ButtonNoOut).onClick = BtnCallBack;
        EventListener.Get(ButtonTip).onClick   = BtnCallBack;
        EventListener.Get(ButtonAtk).onClick   = BtnCallBack;


        FightUIData.getInstance().EnemyVec3 = enemyPanel.transform.GetComponent <RectTransform>().position;
        FightUIData.getInstance().MineVec3  = minePanel.transform.GetComponent <RectTransform>().position;

        _mainPanel = mainPanel;
    }
示例#4
0
    void Start()
    {
        clearnDictionary();
        _enemyCardNumsObj = enemyCardNumsObj;
        _hpObj            = hpObj;
        EnemyFightController.getInstance().initEnemyFightData();

        _enemyCardNumsObj.text = EnemyFightData.getInstance().cardsNumber().ToString();
        _hpObj.text            = EnemyFightData.getInstance().getHp().ToString();
        parentGame             = this.gameObject;
        //初始化摆位

        //卡牌父节点尺寸
        Vector2 vec2 = this.gameObject.transform.GetComponent <RectTransform>().sizeDelta;

        //卡牌节点尺寸
        float itemWidth = 0.0f;

        float itemHeight = 0.0f;

        //卡牌间的距离间距
        float space = 20.0f;

        //卡牌加间隙占的总宽度
        float allCardWidth = 0.0f;

        //第一张卡牌的坐标位置
        float fristX = 0.0f;

        doSize = 1.0f;

        float middPanelHeight = FightUIData.getInstance().getMiddHeight();

        //初始化首发卡牌对象
        Dictionary <int, CardData> cardDataDic = EnemyFightController.getInstance().getFristCards();

        for (int i = 1; i <= cardDataDic.Count; i++)
        {
            CardEnemy card = CardEnemy.create(cardDataDic[i]);
            card.setParent(this.gameObject);

            if (1 == i)
            {
                itemWidth  = card.getSize().x;
                itemHeight = card.getSize().y;
                if (AdaptationResolutionMG.getInstance().getDeviceSizeType() == DEVICE_SIZE_TYPE.Leng)
                {
                    doSize = AdaptationResolutionMG.getInstance().getRawWidth() / (float)Screen.width;
                }
                else if (AdaptationResolutionMG.getInstance().getDeviceSizeType() == DEVICE_SIZE_TYPE.Compare)
                {
                    doSize = AdaptationResolutionMG.getInstance().getDoSizeWidth();
                }
                else
                {
                    doSize = Screen.width / (float)(itemWidth * Const.FRIST_CARD_NUM + space * (Const.FRIST_CARD_NUM - 1));
                }

                allCardWidth = (itemWidth * Const.FRIST_CARD_NUM) + (Const.FRIST_CARD_NUM - 1) * space;
                allCardWidth = allCardWidth * doSize;
                //表示已经超出屏幕 在现有的基础上再一次缩放
                if (Screen.width < allCardWidth)
                {
                    doSize = doSize * Screen.width / allCardWidth;
                }
                itemWidth  = itemWidth * doSize;
                itemHeight = itemHeight * doSize;
                space      = space * doSize;

                allCardWidth = (itemWidth * Const.FRIST_CARD_NUM) + (Const.FRIST_CARD_NUM - 1) * space;

                fristX = (Screen.width - allCardWidth) * 0.5f - Screen.width * 0.5f + itemWidth * 0.5f;
            }

            card.setScale(doSize * enemyCardScale);

            int key = cardDataDic[i].Pos;

            viewPosList.Add(key, new Vector2(fristX + (i - 1) * (itemWidth + space), -middPanelHeight * 0.5f + itemHeight * 1.3f));

            viewCardDic.Add(key, card);

            card.setPosition(viewPosList[i]);
        }
    }