Beispiel #1
0
        void Start()
        {
            Hands = GameObject.FindGameObjectsWithTag("Hand");

            cardInventory = ScriptableObject.CreateInstance <CardsList>();

            if (!File.Exists(Application.dataPath + "/Resources/MyCards/CardsInventory.json"))
            {
                return;
            }

//			_jsonString = File.ReadAllText(Application.dataPath + "/Resources/MyCards/CardsInventory.json").ToString();

            _myCardsJson = JsonMapper.ToObject(_jsonString);

            if (_myCardsJson.Count == 0)
            {
                return;
            }

            for (int i = 0; i < _myCardsJson.Count; i++)
            {
                _myCard = new PlayCard((int)_myCardsJson[i]["Health"], (int)_myCardsJson[i]["AttackTop"], (int)_myCardsJson[i]["AttackBottom"],
                                       (int)_myCardsJson[i]["AttackLeft"], (int)_myCardsJson[i]["AttackRight"], (int)_myCardsJson[i]["GemSlotsCount"], (int)_myCardsJson[i]["Hand"],
                                       (int)_myCardsJson[i]["CID"], (int)_myCardsJson[i]["CFaction"], _myCardsJson[i]["CName"].ToString(), _myCardsJson[i]["CDesc"].ToString(),
                                       (int)_myCardsJson[i]["CPieces"], (int)_myCardsJson[i]["CLevel"]);
                cardInventory.AddNewCard(_myCard);
            }

            foreach (GameObject hand in Hands)
            {
                hand.GetComponent <CreateCards>().CreateSomeCards(cardInventory);
            }
        }
Beispiel #2
0
        public void CreateSomeCards(CardsList _cardsToGenerate)
        {
            for (int i = 0; i < _cardsToGenerate.Count; i++)
            {
                if (_cardsToGenerate.Get(i).Hand == hand)
                {
                    GameObject _tempCard = Instantiate(_genericPC) as GameObject;
                    _tempCard.transform.SetParent(this.transform);
                    _tempCard.transform.localScale = Vector3.one;
                    _tempCard.GetComponent <GenericPlayCard>()._myCard = _cardsToGenerate.Get(i);
                    _tempCard.name = _tempCard.GetComponent <GenericPlayCard>()._myCard.CName;
                }
            }

            for (int i = 0; i < this.transform.childCount; i++)
            {
                this.transform.GetChild(i).transform.position = this.transform.position + new Vector3((i * 2f), (i * 2f), 0f);
            }
        }