IEnumerator getUserDeck(DeckBean deckBean) { string jsonToServer = JsonUtility.ToJson(deckBean); UnityWebRequest request = new UnityWebRequest("https://cardgamejavaserver.herokuapp.com/deck/userDeck", "POST"); byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonToServer); request.uploadHandler = new UploadHandlerRaw(bodyRaw); request.downloadHandler = new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); yield return(request.Send()); if (request.isError) { // todo обработать } else { deck = JsonUtility.FromJson <DeckBean>(request.downloadHandler.text); Vector3 position = transform.position; position.y = position.y + 2.5f; position.x = position.x + 7f; position.z = 0; Card newCard = Instantiate(card, position, card.transform.rotation) as Card; newCard.name = deck.leader.id; newCard.gameObject.AddComponent <CardInColl>(); newCard.Id = deck.leader.id; newCard.Strength = deck.leader.strength; newCard.changeStrength(newCard.Strength); newCard.sprites[0] = Resources.Load("sprites/Cards/SmallSize/" + newCard.Id, typeof(Sprite)) as Sprite; newCard.sprites[1] = Resources.Load("sprites/Cards/FullSize/" + newCard.Id, typeof(Sprite)) as Sprite; newCard.transform.Find("Count").gameObject.SetActive(false); newCard.changeSprite(0); newCard.transform.position = position; newCard.transform.localScale = new Vector3(0.9F, 0.9F, 0); newCard.transform.parent = GameObject.Find("RightPanel").transform; foreach (CardBean card in deck.cards) { ItemList itemList = GameObject.Find("Item List").GetComponent <ItemList>(); itemList.AddToList(card.id, card.name, false); Sprite sprite = GameObject.Find(card.id).transform.Find("Count").GetComponent <SpriteRenderer>().sprite; if (sprite != null) { if (Int32.Parse(sprite.name) == 1) { sprite = null; GameObject.Find(card.id).GetComponentInChildren <SpriteRenderer>().color = new Color32(100, 100, 100, 255); } else { sprite = Resources.Load("sprites/Cards/power/" + (Int32.Parse(sprite.name) - 1).ToString(), typeof(Sprite)) as Sprite; } GameObject.Find(card.id).transform.Find("Count").GetComponent <SpriteRenderer>().sprite = sprite; } } } }
public void ShowChooseForm(Player player) { ChooseProperty.SetActive(true); _player = player; _player.CurrentState = Player.State.OfferToMortgageProperty; InitScroll(); foreach (var property in _player.Owned) { _itemList.AddToList(property, true); } }
public void ChoosePropertyToSellHouse() { _gameManager.CurrentPlayer.CurrentState = Player.State.OfferToSellHouse; this.gameObject.SetActive(true); ChooseProperty.gameObject.SetActive(true); _itemList.scroll = Scroll; _itemList.Clear(); _itemList.SetAction(SetProperty, false); var sellProperties = _gameManager.CurrentPlayer.Owned.FindAll(x => x.GetType() == typeof(Street)) .Select(x => (Street)x).ToList() .FindAll(x => x.CurrentUpgradeLevel > 0); foreach (var property in sellProperties) { _itemList.AddToList(property, true); } }
public void OnMouseUp() { Sprite sprite = gameObject.transform.Find("Count").GetComponent <SpriteRenderer>().sprite; if (sprite != null) { itemList = GameObject.Find("Item List").GetComponent <ItemList>(); itemList.AddToList(gameObject.GetComponent <Card>().Id, gameObject.GetComponent <Card>().Name, true); if (Int32.Parse(sprite.name) == 1) { sprite = null; gameObject.GetComponentInChildren <SpriteRenderer>().color = new Color32(100, 100, 100, 255); } else { sprite = Resources.Load("sprites/Cards/power/" + (Int32.Parse(sprite.name) - 1).ToString(), typeof(Sprite)) as Sprite; } gameObject.transform.Find("Count").GetComponent <SpriteRenderer>().sprite = sprite; } }
private void AddToPlayer2Offer(Ownable property) { _player2OfferProperties.Add(property); _itemListPlayer2PropertiesOffer.AddToList(property, true); }
private void RemoveFromPlayer2Offer(Ownable property) { _player2OfferProperties.Remove(property); _itemListPlayer2PropertiesLeft.AddToList(property, true); }