Exemplo n.º 1
0
    void AddCardToDeck()
    {
        GameObject newCard = Instantiate(m_CardPrefab, m_CardPos, transform.rotation) as GameObject;

        m_CardPos.x += newCard.GetComponent <RectTransform>().rect.width + UnityEngine.Screen.width * 0.02f;
        newCard.transform.SetParent(m_Canvas.transform);
        m_PlayerChoice.Add(newCard);
        if (m_PlayerDeck.Count > 0)
        {
            CanonAttribute attribute = m_PlayerDeck[Random.Range(0, m_PlayerDeck.Count)];
            newCard.GetComponent <CardLogic>().m_CanonAttribute = attribute;
            newCard.transform.Find("Direction").gameObject.GetComponent <Text>().text = attribute.Direction + " direction";
            newCard.transform.Find("HP").gameObject.GetComponent <Text>().text        = "HP: " + attribute.HP;
            Text effect = newCard.transform.Find("Effect").gameObject.GetComponent <Text>();
            effect.text  = "";
            effect.text += attribute.InstantSpawn ? "立即发射 " : "";
            effect.text += attribute.DoubleSpeed ? "速度加倍 " : "";
            effect.text += attribute.DoubleAtk ? "攻击加倍 " : "";
            effect.text += attribute.DoubleFrequency ? "频率加倍 " : "";
            if (effect.text == "")
            {
                effect.text = "无特殊效果";
            }
        }
    }
Exemplo n.º 2
0
    void SetCanonAttribute(CanonLogic logic, GameObject card)
    {
        CanonAttribute attribute = card.GetComponent <CardLogic>().m_CanonAttribute;

        logic.m_Active          = false;
        logic.m_DirectionCnt    = attribute.Direction;
        logic.m_MaxHealth       = attribute.HP;
        logic.m_InstantSpawn    = attribute.InstantSpawn;
        logic.m_DoubleSpeed     = attribute.DoubleSpeed;
        logic.m_DoubleAtk       = attribute.DoubleAtk;
        logic.m_DoubleFrequency = attribute.DoubleFrequency;
    }