示例#1
0
    public void SwapIndex(CardIndex cardIndex)
    {
        int temp = index;

        index           = cardIndex.index;
        cardIndex.index = temp;
    }
示例#2
0
        /// <summary>
        /// 找到不是顺子,不是对子的牌,出掉
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        private static CardIndex FindDropCard(List <Card> list)
        {
            CardIndex        index = CardIndex.None;
            List <CardIndex> cards = new List <CardIndex>();

            for (int i = 0; i < list.Count; i++)
            {
                cards.Add(list[i].CardIndex);
            }

            if (cards[0] != cards[1] && (cards[0] + 1) != cards[1])
            {
                return(cards[0]);
            }

            for (int i = 1; i < cards.Count - 1; i++)
            {
                if (cards[i] != cards[i - 1] && cards[i] != cards[i + 1] && (cards[i] - 1) != cards[i - 1] && (cards[i] + 1) != cards[i + 1])
                {
                    return(cards[i]);
                }
            }

            for (int i = 0; i < cards.Count; i++)
            {
                if (cards[cards.Count - 1] != cards[cards.Count - 2])
                {
                    return(cards[cards.Count - 1]);
                }
            }

            return(index);
        }
示例#3
0
        public CardDesc(
			CardType type,
			CardIndex index)
        {
            Type = type;
            Number = index;
        }
示例#4
0
    public void Awake()
    {
        CardIndex   = FindObjectOfType <CardIndex>();
        DiscardPile = FindObjectOfType <IndexDiscardPile>();

        var notDummyCardRenderers =
            from r in FindObjectsOfType <CardRenderer>()
            where r.DummyRenderer == false
            select r;

        CardsInPlay.Clear();
        CardsInPlay.AddRange(notDummyCardRenderers);

        for (int i = 0; i < CardsInPlay.Count; i++)
        {
            CardRenderer capturedRenderer = CardsInPlay[i];

            CardsInPlay[i].Background.GetComponent <RightClickListener>().rightClick.AddListener(
                delegate {
                OnAnyCardButtonUI(capturedRenderer.Index, true);
            }
                );
        }

        collectionViewer.OnAnyCardClickedDelegate = (b) => {
            OnAnyCardButtonUI(b, false);
        };
    }
示例#5
0
    public static void AddCardEnemy(CardIndex note)
    {
        bool alrNoted   = false;
        int  noteID     = note.GetID();
        int  Foundindex = -1;

        foreach (CardIndex nt in BestiaryElements.Bestiary)
        {
            alrNoted = (nt.GetID() == noteID);
            if (alrNoted)
            {
                Foundindex = BestiaryElements.Bestiary.IndexOf(nt);
                break;
            }
        }
        if (!alrNoted)
        {
            BestiaryElements.Bestiary.Capacity++;
            BestiaryElements.Bestiary.Add(note);
        }
        else
        {
            note.TimesKilled++;
            BestiaryElements.Bestiary[Foundindex] = note;
            Debug.Log(noteID);
        }
        Debug.Log(BestiaryElements.Bestiary.Count);
    }
        public static MCard Create(CardIndex card)
        {
            string path = "LFX/TableMajiang/Prefab/Majiang";

            GameObject go = Instantiate(Resources.Load <GameObject>(path));

            return(go.GetComponent <MCard>());
        }
示例#7
0
    private void Die()
    {
        anim.SetTrigger("Die");
        player.TogglePlayable(false);
        Time.timeScale = 1f;
        CardIndex enemyCard = new CardIndex(enemyID, realImg, inGameImg, encounterLocal, enemyBehavior, enemyName, realInfo);

        BestiaryElements.AddCardEnemy(enemyCard);
        PontuationCounter.AddScore(3000);
    }
    public void Die()
    {
        Fire.Play();
        destination += Vector3.down * 50;
        speed        = 12;
        CardIndex enemyCard = new CardIndex(enemyID, realImg, inGameImg, encounterLocal, enemyBehavior, enemyName, realInfo);

        BestiaryElements.AddCardEnemy(enemyCard);
        PontuationCounter.AddScore(3000);
    }
    void Awake()
    {
        lastCardIndex       = new CardIndex();
        getCardIndex_result = new CardIndex();

        lastCardIndex.groupIndex   = 0;
        lastCardIndex.cardSubIndex = 0;

        rndCard  = ScriptableObject.CreateInstance(typeof(RandomElementWithPropability)) as RandomElementWithPropability;
        instance = this;
    }
示例#10
0
    void Awake()
    {
        CardIndex = FindObjectOfType <CardIndex>();

        rectTransform = GetComponent <RectTransform>();

        OnSettled += () => {
            UseSpeed = BaselineSpeed;
        };

        MoveTarget = rectTransform.anchoredPosition;
    }
    void Update()      //método padrão do unity que roda no início de cada frame
    {
        if (life <= 0) //verifica se o inimigo está morto
        {
            if (DieDestroy)
            {
                if (!stuned)                                                                                                     // se ele não estiver atordoado...
                {
                    Destroy(this.gameObject);                                                                                    //destrua esse objeto
                }
                else                                                                                                             //se ele estiver atordoado (pra gente poder ver o inimigo saindo voando depois de tomar o último hit)
                {
                    HitF       = Instantiate(hiteffect, transform.position, transform.rotation).GetComponent <SpriteRenderer>(); //instanciar o efeito visual de dano
                    HitF.color = new Color(1f, stun, stun, 1f);                                                                  //escolher uma cor para o efeito cada vez mais avermelhada de acordo com o tempo de atordoamento restante
                    HitF.gameObject.transform.localScale = new Vector3(1 / (stun + 0.1f) + 6f, 1 / (stun + 0.1f) + 6f, 1f);      // ir aumentando o tamanho do efeito visual
                    this.gameObject.GetComponent <Collider2D>().enabled = false;                                                 // desabilitar os colisores do inimigo, para ele não bater em nada
                }
            }
            else
            {
                if (!stuned)
                {
                    GameEvents.ScreamEvent("EnemyKilled");
                    CardIndex enemyCard = new CardIndex(enemyID, realImg, inGameImg, encounterLocal, enemyBehavior, enemyName, realInfo);
                    BestiaryElements.AddCardEnemy(enemyCard);
                    PontuationCounter.AddScore(500);
                    a.PlaySound("die");
                }
                SetStuned(5);
                life = 0;
            }
        }
        else
        {
            if (stuned && stun <= 0)
            {
                stuned = false;
            }
        }

        if (stun > 0.0f && (DieDestroy || life > 0)) //se o inimigo estiver atordoado..
        {
            stun -= Time.deltaTime;                  //diminuir o tempo restante de atordoamento, com base em quanto tempo passa entre cada frame
        }
        else if (DieDestroy || life > 0)             //se ele não estiver atordoado
        {
            stuned = false;                          //então ele não está atordoado. (não dá pra ser verdadeiro e falso ao mesmo tempo ainda.)
        }
    }
    bool cardIndexValid(CardIndex ci)
    {
        //test, if index is within allowed range of upper group
        if (ci.groupIndex >= allCards.Length)
        {
            return(false);
        }
        //test, if index is within allowed range of sub group
        if (ci.cardSubIndex >= allCards [ci.groupIndex].groupCards.Length)
        {
            return(false);
        }

        return(true);
    }
示例#13
0
        /// <summary>
        /// 人家玩家点击麻将出牌
        /// </summary>
        /// <param name="cardIndex"></param>
        /// <param name="cardName"></param>
        private void PlayerClickMaJiang(CardIndex card)
        {
            if (index % 4 != 0 || isSend || !canClick)
            {
                return;
            }

            foreach (var item in CurPlayerCards)
            {
                if (item.CardIndex == card)
                {
                    PlayerPlay(item, true);
                    return;
                }
            }
        }
    //spawn a card, set its parameters and count it
    GameObject spawnCard(GameObject go)
    {
        //Debug.Log ("new card");
        spawnedCard = (GameObject)Instantiate(go);

        addDrawCnt(go);
        lastCardIndex = getCardIndex(go);
        saveCardIndex();

        getCardAnimator();
        spawnedCard.transform.SetParent(CardParent);
        spawnedCard.transform.localScale = new Vector3(1f, 1f, 1f);
        actMoveDistance = 0f;

        return(spawnedCard);
    }
    void Start()
    {
        if (cardIndex == null)
        {
            cardIndex = FindObjectOfType <CardIndex>();
        }

        if (loadAllCardsOnStart)
        {
            List <byte> indices = new List <byte>();
            indices.AddRange(cardIndex.AllCardIndices);

            List <byte> sortedList = indices.OrderBy(o => cardIndex.GetCard(o).CardName).ToList();

            SetValues(sortedList);
        }
    }
示例#16
0
        /// <summary>
        /// 生成卡牌数据
        /// </summary>
        private void InitCards()
        {
            foreach (int item in Enum.GetValues(typeof(CardIndex)))
            {
                CardIndex cardType = (CardIndex)item;
                if (cardType > CardIndex.None &&
                    cardType < CardIndex.Dong)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        Card cardInfo = new Card(cardType);
                        tCards.Add(cardInfo);
                    }
                }
            }

            //洗牌
            tCards = GetRandomList <Card>(tCards);
        }
示例#17
0
    void Return(Card card)
    {
        Assert.IsNotNull(card);
        if (!cardPositions.ContainsKey(card))
        {
            throw new ArgumentException("Can only add card to active pile if it was removed from there.");
        }

        if (removedCardIndices.Count == 0)
        {
            throw new InvalidOperationException("No removals to undo.");
        }

        CardIndex index = removedCardIndices.Pop();

        Assert.IsNull(activeCards[index.x, index.y]);

        SetCard(card, index.x, index.y);
    }
    public void takedamage(int dmg, Vector2 knockback)    //método que faz o inimigo tomar dano, dmg = dano recebido (inteiro) e Knockback = direção e intensidade da repulsão (Vector2(x, y))
    {
        if (life > 0 || (life <= 0 && !DieDestroy))       //verifica se o inimigo é capaz de receber dano de alguma forma
        {
            stun   = hitstun;                             //faz com que o inimigo tenha o tempo de atordoamento ativado
            stuned = true;                                //ativa o status de atordoado
            if (life > dmg || (life <= 0 && !DieDestroy)) // se o inimigo não for morrer ao tomar esse dano...
            {
                if (hiteffect != null)
                {
                    Instantiate(hiteffect, transform.position, transform.rotation);                     // instanciar o efeito visual para tomar dano não-letal
                }

                if (a != null)
                {
                    a.PlaySound("dmg");
                }

                life -= dmg;                 //diminuir a vida do inimigo
            }

            else             //se ele for morrer ao receber esse dano
            {
                if (a != null)
                {
                    a.PlaySound("die");
                }

                life = 0;                 // duh, vida = 0


                GameEvents.ScreamEvent("EnemyKilled");                 //diga pra todo mundo que um inimigo morreu
                CardIndex enemyCard = new CardIndex(enemyID, realImg, inGameImg, encounterLocal, enemyBehavior, enemyName, realInfo);
                BestiaryElements.AddCardEnemy(enemyCard);
                PontuationCounter.AddScore(500);
            }

            this.gameObject.GetComponent <Rigidbody2D>().velocity += knockback * KnBackIntensity;
        }
    }
 void Awake()
 {
     Index     = FindObjectOfType <GameplayNetworking>().TheCardIndex;
     gameTimer = FindObjectOfType <GameTimer>();
 }
示例#20
0
        /// <summary>
        /// 检测碰、杠
        /// </summary>
        /// <returns></returns>
        private bool CheckPengGang()
        {
            CardIndex result = CardIndex.None;

            tempIndex = index;
            //检测其他三个玩家的碰、杠
            for (int i = index + 1; i < index + 4; i++)
            {
                if (Rules.IsPeng(players[i % 4].myCards, pCard) ||
                    Rules.IsGang(players[i % 4].myCards, pCard))
                {
                    result = pCard.CardIndex;
                }

                if (result != CardIndex.None)
                {
                    index = i % 4;
                    //有玩家碰、杠了
                    temp.Clear();
                    for (int j = 0; j < CurPlayerCards.Count; j++)
                    {
                        if (CurPlayerCards[j].CardIndex == result)
                        {
                            temp.Add(CurPlayerCards[j]);
                        }
                    }
                    temp.Add(pCard);

                    //如果碰、杠的玩家是电脑玩家,直接碰、杠
                    if (index != 0)
                    {
                        if (temp.Count == 3)
                        {
                            Peng(temp);
                        }
                        if (temp.Count == 4)
                        {
                            Gang(temp);
                        }
                        temp.Clear();
                        return(true);
                    }

                    //人玩家
                    if (index == 0)
                    {
                        canClick = false;
                        if (temp.Count == 3)
                        {
                            SetButton(true, false, false, true);
                        }
                        else
                        {
                            SetButton(false, true, false, true);
                        }
                        //等待过按钮按下
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#21
0
 public Anotation(CardIndex cd)
 {
     pic  = cd.RealImage.texture;
     ID   = cd.ID;
     text = cd.CInfo;
 }
示例#22
0
 public Card(CardIndex cardType)
 {
     this.cardIndex = cardType;
 }
示例#23
0
 void Awake()
 {
     cardRenderer = GetComponent <CardRenderer>();
     cardIndex    = FindObjectOfType <CardIndex>();
 }
示例#24
0
 internal bool Equals(CardIndex i_CompareTo)
 {
     return(this.m_Row == i_CompareTo.Row && this.m_Column == i_CompareTo.Column);
 }
示例#25
0
 public void SetIndex(CardIndex index)
 {
     Indices.Clear();
     cardIndex = index;
     Indices.AddRange(cardIndex.AllCardIndices);
 }
 public void SetCardIndex(CardIndex card)
 {
     this.card = card;
     ApplySprite();
 }
 public byte GetCardCount(CardType card, CardIndex index, bool isPremium) =>
 OnCard(card, isPremium, x => SaveData.McWork.CardInventoryCount[x + index]);
 public void SetCardCount(CardType card, CardIndex index, bool isPremium, byte count) =>
 OnCard(card, isPremium, x => SaveData.McWork.CardInventoryCount[x + index] = count);