示例#1
0
    public void RemoveEquip(int index)
    {
        CardProto proto = hand[index];

        if (proto.View.type == CardModel.Type.Equip)
        {
            hand.Remove(proto);
            proto.Destroy();
            grave.Add(proto);

            for (int i = index; i < hand.Count; i++)
            {
                hand[i].View.handId = i;
            }
        }
    }
示例#2
0
    public void DrawACard(bool normal = false)
    {
        deckCount = deck.Count;

        if (deck.Count > 0)
        {
            if (hand.Count < maxHand)
            {
                // 是否抽取普通卡
                CardProto card = normal ? deck[0] : deck[Random.Range(0, deck.Count)];
                Debug.Log(group + " 抽取一张卡片:" + card.GetName());

                deck.Remove(card);
                CardView view = card.Create(group);
                view.handId = hand.Count;

                if (isSelf)
                {
                    view.transform.SetParent(GameObject.Find("CardBattle/SelfHand").transform);
                }
                else
                {
                    view.transform.SetParent(GameObject.Find("CardBattle/EnemyHand").transform);
                }

                // 缩放率为0.5
                view.transform.localPosition = Vector3.zero;
                view.transform.localScale    = new Vector3(0.5f, 0.5f);
                hand.Add(card);
            }
            else
            {
                EventManager.PostEvent(TipSystem.DataType.ShowTip, "手牌不得超过10张,请出牌后继续", isSelf ? true : false);
                //Debug.Log("手牌不得超过10张,请出牌后继续");
            }
        }
        else
        {
            EventManager.PostEvent(TipSystem.DataType.ShowTip, "卡组没有可抽取的卡牌", isSelf ? true : false);
        }
    }
示例#3
0
    // 召唤怪物
    public void CallMonster(int index, Monster.State state)
    {
        if (battle.Count <= 5)
        {
            CardProto proto = hand[index];

            if (proto.View.type == CardModel.Type.Monster)
            {
                if (isSelf)
                {
                    proto.View.transform.SetParent(GameObject.Find("CardBattle/SelfBattle").transform);
                }
                else
                {
                    proto.View.transform.SetParent(GameObject.Find("CardBattle/EnemyBattle").transform);
                }

                proto.View.transform.rotation   = new Quaternion();
                proto.View.transform.localScale = new Vector3(0.4f, 0.4f);
                //proto.View.transform.DOLocalMove(Vector3.zero, 0.5f);
                proto.View.enabled = false;
                //GameObject.Destroy(proto.View);

                hand.Remove(proto);

                // 创建怪物模型
                Object     origin        = Resources.Load("Prefab/Monster");
                GameObject monsterObject = GameObject.Instantiate(origin) as GameObject;

                // 修改怪物模型
                string id = (proto.GetID() / 10 == 0 ? "0" : "") + proto.GetID().ToString();
                origin = Resources.Load("Prefab/Role/" + (isSelf ? "Benefit" : "Harm") + "/" + id);
                if (origin == null)
                {
                    origin = Resources.Load("Prefab/Role/Benefit/01");
                }
                GameObject monsterOrigin = GameObject.Instantiate(origin, monsterObject.transform) as GameObject;
                monsterOrigin.name = "Monster";
                monsterOrigin.transform.DOLocalMoveZ(-50, 0.5f);

                proto.View.monster = monsterObject;
                //proto.View.monster.SetActive(false);

                Monster monster = proto.View.monster.AddComponent <Monster>();
                monster.proto  = proto;
                monster.origin = monsterOrigin;
                // 攻击状态
                monster.isSelf = isSelf;
                monster.state  = state;
                monster.SetState(false, false);
                monster.SetHealth(proto.GetHealth());
                monster.state       = state;
                monster.model.value = proto.GetDefend();
                monster.SetValue(monster.GetValue());

                if (isSelf)
                {
                    proto.View.monster.transform.SetParent(GameObject.Find("CardBattle/SelfBattle/Monsters").transform);
                }
                else
                {
                    proto.View.monster.transform.SetParent(GameObject.Find("CardBattle/EnemyBattle/Monsters").transform);
                }

                proto.View.monster.transform.rotation   = new Quaternion();
                proto.View.monster.transform.localScale = new Vector3(1f, 1f, 1f);

                // 更新卡牌信息
                monster.UpdateCard();

                battle.Add(proto);

                for (int i = index; i < hand.Count; i++)
                {
                    hand[i].View.handId = i;
                }
            }
        }
        else
        {
            EventManager.PostEvent(TipSystem.DataType.ShowTip, "不可召唤,战场怪物数量到达上限", isSelf ? true : false);
        }
    }