// Use this for initialization
    void Start()
    {
        ScrollRect myViewport = ScrollView.GetComponent <ScrollRect>();
        Transform  myContent  = myViewport.content;

        int nbCards = myActionDataBase.dataAsArray.Length;

        for (int i = 0; i < nbCards; i++)
        {
            GameObject myCardCollection = Instantiate(ActionCard);

            DisplayActionCard theDisplayCard = myCardCollection.GetComponent <DisplayActionCard>();
            theDisplayCard.card = myActionDataBase.dataAsArray[i];

            OnClickAddActionDeck clickScript = myCardCollection.GetComponent <OnClickAddActionDeck>();
            clickScript.myDeck = currentDeck;
            clickScript.myCard = myActionDataBase.dataAsArray[i];

            myCardCollection.transform.SetParent(myContent);
        }
    }
Пример #2
0
    public void OnPointerDown(PointerEventData eventData)
    {
        //Debug.Log("Cliqué "+ gameObject.transform.parent.name);


        if (gameObject.GetComponent <DisplayUtilCard>() == null)
        {
            //Debug.Log(eventData.pointerPress.GetComponent<CardDisplay1>());
            int   Cardstamina   = int.Parse(gameObject.GetComponent <DisplayActionCard>().staminaText.text);
            float PlayerStamina = Player.GetPlayerStamina();
            int   PlayerAction  = Player.GetPlayerAction();
            //Effectue l'action et applique les dégats pour l'instant seulement des cartes attaques
            DisplayActionCard carte = gameObject.GetComponent <DisplayActionCard>();
            //Debug.Log(Cardstamina + " -- " + PlayerStamina );

            if (gameObject.transform.parent.name == "DropZoneAction" && Player.GetPlayerStamina() > 0 && PlayerStamina >= Cardstamina && PlayerAction > 0 && PlayerTurn1 == true)
            {
                //Debug.Log(carte.multAttackText.text);
                float attaqueBrut = float.Parse(carte.multAttackText.text);
                //float attaque = attaqueBrut * ArmeBrut;
                float attaque     = attaqueBrut * 10;
                float attaqueElem = float.Parse(carte.multElemText.text);
                //float attaque1 = attaqueElem * ArmeElem;
                float attaque1      = attaqueElem * 10;
                float dmg           = attaque + attaque1;
                int   stamina       = int.Parse(carte.staminaText.text);
                int   NbUtilisation = int.Parse(carte.nbTurnText.text);
                NbUtilisation = NbUtilisation - 1;
                if (NbUtilisation == 0)
                {
                    Destroy(gameObject);
                }
                carte.nbTurnText.text = NbUtilisation.ToString();
                Enemy.ReceiveDamage(dmg);
                Player.SpendStamina(stamina);
                Player.SpendAction();
            }
        }
        else
        {
            //Debug.Log(eventData.pointerPress.GetComponent<CardDisplay1>());

            int PlayerAction = Player.GetPlayerAction();

            //Effectue l'action et applique les dégats pour l'instant seulement des cartes attaques
            DisplayUtilCard carte = gameObject.GetComponent <DisplayUtilCard>();
            //Debug.Log(Cardstamina + " -- " + PlayerStamina );

            if (gameObject.transform.parent.name == "DropZoneUtilitaire" && PlayerAction > 0 && PlayerTurn1 == true)

            {
                string CardTitle = gameObject.GetComponent <DisplayUtilCard>().nameText.text;
                int    CardUse   = int.Parse(gameObject.GetComponent <DisplayUtilCard>().nbUseText.text);
                Debug.Log(CardUse);
                CardUse = CardUse - 1;
                if (CardUse == 0)
                {
                    Destroy(gameObject);
                }
                carte.nbUseText.text = CardUse.ToString();
                Debug.Log(CardTitle);
                Utilitaire(CardTitle);
                Player.SpendAction();
            }
        }
    }