public CardInventory GetCardInventory(string userId) { if (userId == null) { var cardInventory = new CardInventory() { UserId = userId }; return(cardInventory); } string sqlConnectionString = this.configuration["CardsDBConnectionString"]; using (var connection = new SqlConnection(sqlConnectionString)) { string sql = "select CardId, CardValue, CreatedDateTimeUtc from dbo.UserCards where UserId = @UserIdValue"; IEnumerable <Card> cards = connection.Query <Card>(sql, new { UserIdValue = userId }); var cardInventory = new CardInventory() { UserId = userId, Cards = cards.ToArray() }; return(cardInventory); } }
public async Task <IEnumerable <CardInventory> > SelectAllAsync(CardInventory cards = null) { IEnumerable <CardInventory> results = Enumerable.Empty <CardInventory>(); using (var con = base.SqlConnection) { try { con.Open(); var resultData = await con.GetListAsync <CardInventory>().ConfigureAwait(false); results = resultData.ToList(); } catch (Exception ex) { throw ex; } finally { con.Close(); } return(results); } }
private async Task <IDictionary <string, Card> > GetCardInventoryAsync(string authToken) { var cards = new Dictionary <string, Card>(StringComparer.OrdinalIgnoreCase); using (var httpClient = HttpClientProvider.GetHttpClient(authToken)) { string endpoint = this.configuration[Constants.CardsServiceEndpoint]; Uri uri = new Uri(FormattableString.Invariant($"{endpoint}/api/cards")); string result = await httpClient.GetStringAsync(uri); if (string.IsNullOrWhiteSpace(result)) { return(null); } CardInventory cardInventory = JsonConvert.DeserializeObject <CardInventory>(result); if (cardInventory?.Cards != null) { foreach (var card in cardInventory.Cards) { cards[card.CardId] = card; } } } return(cards); }
private void Start() { cardInventory = CardInventory.instance; string temp = ""; if (portalDungeon != null) { //portalDungeon.SetActive(false); } foreach (var item in cardInventory.dungeonCards) { //Debug.Log(item.CardName); temp += item.CardName + "\n"; } if (isDebug) { debugCardOwned.text = "Dungeon Cards Owned: \n\n" + temp; } string temp02 = ""; foreach (var item in allDungeonCards) { // Debug.Log(item.CardName); temp02 += item.CardName + "\n"; } if (isDebug) { debugAllCards.text = "All Dungeon Cards : \n\n" + temp02; } }
void CreateCardInventory() { //GetCardInventory(GameManager._Instance.ThisRoundPlayer.GetComponent<Player>()); CardInventory card1 = new CardInventory(); card1.Card = CardManager._Instance.GetCardById(1); card1.Num = 1; CardInventory card2 = new CardInventory(); card2.Card = CardManager._Instance.GetCardById(2); card2.Num = 3; cardList.Add(card1); cardList.Add(card2); for (int i = 0; i < cardList.Count; i++) { GameObject cardItemUI = GameObject.Instantiate(CardInventoryPrefeb); cardItemUI.GetComponent <CardInventoryItemUI>().SetCardInventory(cardList[i]); //NGUITools.AddChild(this.gameObject, CardInventoryPrefeb); grid.AddChild(cardItemUI.transform); } }
private void Awake() { // Singleton setup if (instance == null) { instance = this; } else if (instance != this) { Destroy(this); } DontDestroyOnLoad(gameObject); }
public void SpawnCard(Card c, CardInventory parent) { CardGrid cardGrid = Instantiate(cardGridPrefab); if (parent) { parent.draggedCard = cardGrid; } cardGrid.Init(this, c, parent, parent == null ? CardGrid.CardSource.OTHER : CardGrid.CardSource.PLAYER); if (activeCard != null) { activeCard.CancelMoveFromInventory(); } activeCard = cardGrid; confirmButton.interactable = true; }
public void Init(ConversationGrid grid, Card card, CardInventory parent, CardSource source) { cardInstance.Init(card, parent == null); this.parent = parent; this.grid = grid; this.source = source; gridPixelPosition = Camera.main.WorldToScreenPoint(grid.transform.position); this.card = card; gridSquarePixels = Screen.height / grid.GridSquaresVertical; transform.SetParent(grid.transform); transform.localScale = Vector3.one * 0.97f; transform.localPosition = new Vector3( (Input.mousePosition.x - gridPixelPosition.x) / gridSquarePixels, (Input.mousePosition.y - gridPixelPosition.y) / gridSquarePixels, 0 ); firstDrag = true; OnMouseDown(); }
public void ShowNextPlayerCard(Player player) { cardList.Clear(); CardInventory card1 = new CardInventory(); card1.Card = CardManager._Instance.GetCardById(3); card1.Num = 2; CardInventory card2 = new CardInventory(); card2.Card = CardManager._Instance.GetCardById(4); card2.Num = 4; CardInventory card3 = new CardInventory(); card3.Card = CardManager._Instance.GetCardById(1); card3.Num = 1; cardList.Add(card1); cardList.Add(card2); cardList.Add(card3); List <Transform> listChild = grid.GetChildList(); for (int i = 0; i < listChild.Count; i++) { grid.RemoveChild(listChild[i]); Destroy(listChild[i].gameObject); } for (int i = 0; i < cardList.Count; i++) { GameObject cardItemUI = GameObject.Instantiate(CardInventoryPrefeb); cardItemUI.GetComponent <CardInventoryItemUI>().SetCardInventory(cardList[i]); //NGUITools.AddChild(this.gameObject, CardInventoryPrefeb); grid.AddChild(cardItemUI.transform); } }
public void DrawHand() { foreach (CardInventory inventoryHandCard in inventoryHandCards) { Destroy(inventoryHandCard.gameObject); } inventoryHandCards = new List <CardInventory>(); inventory.UpdatePlayableDeck(); Card[] hand = inventory.GetHand(); for (int i = 0; i < hand.Length; i++) { CardInventory cardInventory = Instantiate(cardInventoryPrefab); cardInventory.transform.SetParent(transform); cardInventory.transform.localPosition = new Vector3((i - (hand.Length - 1) / 2f) * 1.1f, 0, 0); cardInventory.Init(grid, hand[i]); inventoryHandCards.Add(cardInventory); } cooldownCount.text = inventory.GetCooldownCount().ToString(); deckCount.text = inventory.GetDeckCount().ToString(); }
public async Task <int> InsertAsync(CardInventory cards = null) { var results = 0; using (var con = base.SqlConnection) { try { con.Open(); results = await con.InsertAsync(cards).ConfigureAwait(false) ?? 0; } catch (Exception ex) { throw ex; } finally { con.Close(); } return(results); } }
public void SendPlayerCardInfo(CardInventory bag, int[] updatedSlots) { throw new NotImplementedException(); }
public void Insert(CardInventory card) { _CardInventoryRepo.InsertAsync(card); }
public void Update(CardInventory card) { _CardInventoryRepo.UpdateAsync(card); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = packet.ReadInt(); PlayerInfo arg_12_0 = client.Player.PlayerCharacter; CardInventory cardBag = client.Player.CardBag; string text = ""; switch (num) { case 0: { int num2 = packet.ReadInt(); int num3 = packet.ReadInt(); int templateID = cardBag.GetItemAt(num2).TemplateID; if (cardBag.FindEquipCard(templateID) && num2 != num3) { text = "Thẻ này đã trang bị!"; } else { if (num2 != num3) { text = "Trang bị thành công!"; } cardBag.MoveItem(num2, num3); client.Player.MainBag.UpdatePlayerProperties(); } if (text != "") { client.Out.SendMessage(eMessageType.Normal, text); } break; } case 1: { int slot = packet.ReadInt(); int count = packet.ReadInt(); ItemInfo itemAt = client.Player.MainBag.GetItemAt(slot); int property = itemAt.Template.Property5; int place = client.Player.CardBag.FindFirstEmptySlot(5); UsersCardInfo usersCardInfo = new UsersCardInfo(); CardTemplateInfo card = CardMgr.GetCard(itemAt.Template.Property5); bool flag = false; if (card != null) { if (client.Player.CardBag.FindPlaceByTamplateId(5, property) == -1) { usersCardInfo.CardType = card.CardType; usersCardInfo.UserID = client.Player.PlayerCharacter.ID; usersCardInfo.Place = place; usersCardInfo.TemplateID = card.CardID; usersCardInfo.isFirstGet = true; usersCardInfo.Attack = 0; usersCardInfo.Agility = 0; usersCardInfo.Defence = 0; usersCardInfo.Luck = 0; usersCardInfo.Damage = 0; usersCardInfo.Guard = 0; client.Player.CardBag.AddCardTo(usersCardInfo, place); client.Out.SendGetCard(client.Player.PlayerCharacter, usersCardInfo); } else { flag = true; } } else { flag = true; } if (flag) { int num4 = CardDataHander.random.Next(5, 50); client.Player.AddCardSoul(num4); client.Player.Out.SendPlayerCardSoul(client.Player.PlayerCharacter, true, num4); } client.Player.MainBag.RemoveCountFromStack(itemAt, count); break; } case 4: { int slot2 = packet.ReadInt(); int count = packet.ReadInt(); ItemInfo itemAt = client.Player.PropBag.GetItemAt(slot2); int id = CardDataHander.random.Next(CardMgr.CardCount()); CardTemplateInfo singleCard = CardMgr.GetSingleCard(id); bool flag2 = false; if (singleCard == null) { flag2 = true; } else { int place2 = client.Player.CardBag.FindFirstEmptySlot(5); int cardID = singleCard.CardID; CardTemplateInfo card2 = CardMgr.GetCard(cardID); UsersCardInfo usersCardInfo2 = new UsersCardInfo(); if (card2 == null) { flag2 = true; } else { if (client.Player.CardBag.FindPlaceByTamplateId(5, cardID) == -1) { usersCardInfo2.CardType = card2.CardType; usersCardInfo2.UserID = client.Player.PlayerCharacter.ID; usersCardInfo2.Place = place2; usersCardInfo2.TemplateID = card2.CardID; usersCardInfo2.isFirstGet = true; usersCardInfo2.Attack = 0; usersCardInfo2.Agility = 0; usersCardInfo2.Defence = 0; usersCardInfo2.Luck = 0; usersCardInfo2.Damage = 0; usersCardInfo2.Guard = 0; client.Player.CardBag.AddCardTo(usersCardInfo2, place2); client.Out.SendGetCard(client.Player.PlayerCharacter, usersCardInfo2); } else { flag2 = true; } } } if (flag2) { int num5 = CardDataHander.random.Next(5, 50); client.Player.AddCardSoul(num5); client.Player.Out.SendPlayerCardSoul(client.Player.PlayerCharacter, true, num5); } client.Player.PropBag.RemoveCountFromStack(itemAt, count); break; } } cardBag.SaveToDatabase(); return(0); }
public void SetCardInventory(CardInventory cardInventory) { this.cardInventory = cardInventory; Init(); }