Example #1
0
    //清理场上已经死亡的卡牌
    //参数为卡牌唯一id
    public void destroyCard(int id)
    {
        int number = FightingCardsDic[id].getNumber();

        MineFightData.getInstance().subHp(number);
        FightingCardsDic.Remove(id);
    }
Example #2
0
    //处理战斗view的事件
    public IEnumerator FightViewTouchFn(Const.FIGHT_BTN_TYPE state)
    {
        //场上必须得有卡牌才能响应
        if (MineFightData.getInstance().usingCardsNumber() > 0 && FightController.getInstance().RightToPlay == FightController.RIGHTTOPLAY.MINE)
        {
            if (Const.FIGHT_BTN_TYPE.NO_OUT == state)
            {
                noOut();
                FightController.getInstance().RightToPlay = FightController.RIGHTTOPLAY.ENEMY;
            }
            else if (Const.FIGHT_BTN_TYPE.TIP == state)
            {
                noOut();
                if (currOutCardRule.Count == 0)
                {
                    currOutCardRule = getItemOutCardRule();
                }
                if (currOutCardRule.Count > 0)
                {
                    List <int> l = new List <int>();
                    l = currOutCardRule[0];
                    currOutCardRule.RemoveAt(0);
                    foreach (var pos in l)
                    {
                        cardToWaitPos(pos);
                    }
                }
            }
            //出击
            else if (Const.FIGHT_BTN_TYPE.ATK == state)
            {
                //此时是否有卡片可以出
                bool isHaveCardCanOut = false;
                for (int i = 1; i <= Const.FRIST_CARD_NUM; ++i)
                {
                    if (viewCardDic.ContainsKey(i) && viewCardDic[i].getCardState() == Card.CardState.waitFight)
                    {
                        isHaveCardCanOut = true;
                        FightController.getInstance().RightToPlay = FightController.RIGHTTOPLAY.MINEING;

                        viewCardDic[i].getObj().transform.SetAsLastSibling();
                        viewCardDic [i].getObj().GetComponent <RectTransform> ().DOLocalMove(FightUIData.getInstance().EnemyVec3 + new Vector3(0, Screen.height * 0.2f, 0), 0.1f)
                        .SetEase(Ease.InBack).SetUpdate(true);
                        yield return(new WaitForSeconds(0.3f));
                    }
                }
                if (isHaveCardCanOut)
                {
                    yield return(new WaitForSeconds(0.6f));

                    FightController.getInstance().RightToPlay = FightController.RIGHTTOPLAY.ENEMY;
                }
                else
                {
                    MsgPrompts.create("请选择至少一张卡牌", Color.red);
                }
            }
        }
    }
Example #3
0
    //拿取首发卡牌
    public Dictionary <int, CardData> getFristCards()
    {
        Dictionary <int, CardData> dic = new Dictionary <int, CardData>();

        for (int num = 1; num <= Const.FRIST_CARD_NUM; ++num)
        {
            int      pos   = num;
            CardData cards = MineFightData.getInstance().takeCard(pos);
            dic.Add(pos, cards);
        }
        return(dic);
    }
Example #4
0
    public void createCardObject(int pos)
    {
        if (MineFightData.getInstance().cardsNumber() > 0)
        {
            CardData cardData = MineFightController.getInstance().substitute(pos);
            Card     card     = Card.create(cardData);
            card.setParent(parentGame);
            card.setPosition(new Vector3(Screen.width, 0, 0));
            card.setScale(doSize);
            card.moveTo(viewPosList[pos]);
            viewCardDic.Add(pos, card);

            EventListener eve = EventListener.Get(card.getObj());
            eve.onDown = BtnCallBack;
            eve.DOKill();
            initOutCardRule();
        }
    }
Example #5
0
    public void DestroyCardsObject(Card card)
    {
        int pos = card.cardData.Pos;
        int id  = viewCardDic[pos].getCardData().getId();

        //清理数据
        MineFightController.getInstance().destroy(id);

        card.DestoryCard();

        //移除表现对象
        viewCardDic.Remove(pos);

        createCardObject(pos);

        _mineCardNumsObj.text = (MineFightData.getInstance().cardsNumber() + MineFightData.getInstance().usingCardsNumber()).ToString();

        shake();
    }
Example #6
0
 //view报告销毁数据
 public void destroy(int id)
 {
     MineFightData.getInstance().destroyCard(id);
 }
Example #7
0
 //从仓库随机一个替补数据
 public CardData substitute(int pos)
 {
     //断言
     //Debug.Assert( 0 == MineFightData.getInstance().cardsNumber() );
     return(MineFightData.getInstance().takeCard(pos));
 }
Example #8
0
 //初始化我的仓库
 public void initMineFightData()
 {
     MineFightData.getInstance().createCards();
 }
Example #9
0
    // Use this for initialization
    void Start()
    {
        clearnDictionary();
        MineFightController.getInstance().initMineFightData();
        _mineCardNumsObj      = mineCardNumsObj;
        _mineCardNumsObj.text = MineFightData.getInstance().cardsNumber().ToString();

        _hpObj      = hpObj;
        _hpObj.text = MineFightData.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 = MineFightController.getInstance().getFristCards();

        for (int i = 1; i <= cardDataDic.Count; i++)
        {
            Card card = Card.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);

            int key = cardDataDic[i].Pos;

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

            viewCardDic.Add(key, card);

            card.setPosition(viewPosList[i]);

            EventListener.Get(card.getObj()).onDown = BtnCallBack;
        }
        outCardPosY = outCardPosY * doSize;

        initOutCardRule();
    }
Example #10
0
 //遭受攻击
 static public void Atkend()
 {
     _hpObj.text = MineFightData.getInstance().getHp().ToString();
     FightController.getInstance().RightToPlay = FightController.RIGHTTOPLAY.MINE;
 }