public void getGoodTypePrefabUnit(string type, CardUnitBehaviour script)
 {
     if (script != null)
     {
         switch (type) {
         case "BigRange":
             CardUI.GetComponent<Image> ().sprite = script.m_bigRange;
             break;
         case "Range":
             CardUI.GetComponent<Image> ().sprite = script.m_range;
             break;
         case "Close":
             CardUI.GetComponent<Image> ().sprite = script.m_cac;
             break;
         }
     }
 }
    public void copy(CardUnitBehaviour c1)
    {
        this.ATK_Down = c1.ATK_Down;
        this.ATK_Left = c1.ATK_Left;
        this.ATK_Right = c1.ATK_Right;
        this.ATK_Up = c1.ATK_Up;
        this.HP = c1.HP;
        this.Speed = c1.Speed;

        this.m_Illustration.GetComponent<Image>().sprite = c1.m_Illustration.GetComponent<Image>().sprite;

        this.m_name.GetComponent<Text>().text = c1.m_name.GetComponent<Text>().text;
        this.m_HP.GetComponent<Text>().text = c1.m_HP.GetComponent<Text>().text;

        this.m_Description1.GetComponent<Text>().text = c1.m_Description1.GetComponent<Text>().text;
        this.m_Description2.GetComponent<Text>().text = c1.m_Description2.GetComponent<Text>().text;
        this.m_Description3.GetComponent<Text>().text = c1.m_Description3.GetComponent<Text>().text;

        this.m_ATK_Down.GetComponent<Text>().text = c1.m_ATK_Down.GetComponent<Text>().text;
        this.m_ATK_Up.GetComponent<Text>().text = c1.m_ATK_Up.GetComponent<Text>().text;
        this.m_ATK_Right.GetComponent<Text>().text = c1.m_ATK_Right.GetComponent<Text>().text;
        this.m_ATK_Left.GetComponent<Text>().text = c1.m_ATK_Left.GetComponent<Text>().text;

        this.m_Speed.GetComponent<Text>().text = c1.m_Speed.GetComponent<Text>().text;

        this.m_type = c1.m_type;
    }
    public static GameObject CreateTokken(CardUnitBehaviour Card, Vector3 position, Quaternion rotation, bool playerTurn)
    {
        GameObject prefab;
        Player PlayedBy;

        if (playerTurn)
        {
            prefab = (GameObject)Resources.Load("PlayerTokken", typeof(GameObject));

            PlayedBy = Player.Player1;
        }
        else
        {
            prefab = (GameObject)Resources.Load("OpponentTokken", typeof(GameObject));

            PlayedBy = Player.Player2;
        }

        TokkenBehaviour script = prefab.GetComponent<TokkenBehaviour>();
        switch (Card.m_type)
        {
            case "BigRange":
                //Debug.Log("big");
                prefab.GetComponent<Image>().sprite = script.m_BigRange;
                break;
            case "Range":
                //Debug.Log("range");
                prefab.GetComponent<Image>().sprite = script.m_Range;
                break;
            case "Close":
                //Debug.Log("cac");
                prefab.GetComponent<Image>().sprite = script.m_Cac;

                break;
        }

        int cost = Card.m_price;
        int Rubis = 1;
        while (cost > 0)
        {
            Image image = script.m_Rubis1.GetComponent<Image>();
            switch (Rubis)
            {
                case 1: image = script.m_Rubis1.GetComponent<Image>();
                    break;
                case 2: image = script.m_Rubis2.GetComponent<Image>();
                    break;
                case 3: image = script.m_Rubis3.GetComponent<Image>();
                    break;
                case 4: image = script.m_Rubis4.GetComponent<Image>();
                    break;
                case 5: image = script.m_Rubis5.GetComponent<Image>();
                    break;
            }
            if (cost >= 10)
            {
                image.color = Color.red;
                cost = cost - 10;
                Rubis++;
            }
            else if (cost >= 5)
            {
                image.color = Color.blue;
                cost = cost - 5;
                Rubis++;
            }
            else if (cost < 5)
            {
                image.color = Color.green;
                cost = cost - 1;
                Rubis++;
            }

        }
        script.m_hp.GetComponent<Text> ().text = Card.m_HP.GetComponent<Text> ().text;
        script.m_ATK_Up.GetComponent<Text> ().text = Card.m_ATK_Up.GetComponent<Text> ().text;
        script.m_ATK_Right.GetComponent<Text> ().text = Card.m_ATK_Right.GetComponent<Text> ().text;
        script.m_ATK_Down.GetComponent<Text> ().text = Card.m_ATK_Down.GetComponent<Text> ().text;
        script.m_ATK_Left.GetComponent<Text> ().text = Card.m_ATK_Left.GetComponent<Text> ().text;
        script.m_speed.GetComponent<Text> ().text = Card.m_Speed.GetComponent<Text> ().text;

        script.m_Illustration.GetComponent<Image>().sprite = Card.m_Illustration.GetComponent<Image>().sprite;

        GameObject Tokken = (GameObject)Instantiate (prefab, position, rotation);

        TokkenBehaviour TokkenB = (TokkenBehaviour)Tokken.GetComponent<TokkenBehaviour> ();

        TokkenB.m_playedBy = PlayedBy;

        TokkenB.hp = int.Parse (Card.m_HP.GetComponent<Text> ().text);
        TokkenB.ATK_Up = int.Parse (Card.m_ATK_Up.GetComponent<Text> ().text);
        TokkenB.ATK_Right = int.Parse (Card.m_ATK_Right.GetComponent<Text> ().text);
        TokkenB.ATK_Down = int.Parse (Card.m_ATK_Down.GetComponent<Text> ().text);
        TokkenB.ATK_Left = int.Parse (Card.m_ATK_Left.GetComponent<Text> ().text);

        TokkenB.speed = int.Parse (Card.m_Speed.GetComponent<Text> ().text);

        TokkenB.victoryPoint =  Card.m_price;

        TokkenB.name = Card.m_name.GetComponent<Text> ().text;

        TokkenB.type = Card.m_type;

        TokkenB.descriptionL1 = Card.m_Description1.GetComponent<Text> ().text;
        TokkenB.descriptionL2 = Card.m_Description2.GetComponent<Text> ().text;
        TokkenB.descriptionL3 = Card.m_Description3.GetComponent<Text> ().text;

        return Tokken;
    }
    public void setNewCardUnit(CardUnitBehaviour cardToAdd)
    {
        if (currentCard != null)
            this.removeCard ();

        CardViewer.GetComponent<CardViewerBehaviour> ().setAllyTexture ();

        CardUI = (GameObject)Resources.Load("CardGUIUnit", typeof(GameObject));
        CardUnitBehaviour script = CardUI.GetComponent<CardUnitBehaviour>();

        script.copy (cardToAdd);

        getGoodTypePrefabUnit (script.m_type, script);

        int cost = int.Parse(script.PropVictory_Point.ToString());
        int Rubis = 1;
        while (cost > 0)
        {
            Image image = script.m_Rubis1.GetComponent<Image>();
            switch (Rubis)
            {
                case 1: image = script.m_Rubis1.GetComponent<Image>();
                    break;
                case 2: image = script.m_Rubis2.GetComponent<Image>();
                    break;
                case 3: image = script.m_Rubis3.GetComponent<Image>();
                    break;
                case 4: image = script.m_Rubis4.GetComponent<Image>();
                    break;
                case 5: image = script.m_Rubis5.GetComponent<Image>();
                    break;
            }
            if (cost >= 10)
            {
                image.color = Color.red;
                cost = cost - 10;
                Rubis++;
            }
            else if (cost >= 5)
            {
                image.color = Color.blue;
                cost = cost - 5;
                Rubis++;
            }
            else if (cost < 5)
            {
                image.color = Color.green;
                cost = cost - 1;
                Rubis++;
            }

        }
        currentCard = GameObject.Instantiate((GameObject)CardUI);

        currentCard.transform.SetParent (transform);
        currentCard.transform.localScale = Vector3.one;
    }