public void PutCard(DeckTag putDeck, int playerCardIndex, bool isBack = false, float reverseTime = 0.5f) { var deck = DeckSystem.GetInstance().GetDeck(putDeck); var putCardIdx = PlayerCard[playerCardIndex].GetCardIndex(); var putShapeIdx = PlayerCard[playerCardIndex].GetShapeIndex(); PlayerCard[playerCardIndex].transform.DOMove(deck.GetPosition(), 0.5f); PlayerCard[playerCardIndex].transform.DORotate(deck.GetAngle(), 0.5f); if (isBack) { CardAnimationSystem.GetInstance().ReverseAnimation( PlayerCard[playerCardIndex], reverseTime); } deck.AddCard(PlayerCard[playerCardIndex]); ////////////////////////////////////// /// TODO : 커플링으로 인해 분리해야함 RuleSystem.GetInstance().AddAttackCardDamage(putCardIdx, putShapeIdx); AlertSystem.GetInstance().AddAlerts(putCardIdx, putShapeIdx); ////////////////////////////////////// IsPutCard = true; PlayerCard.RemoveAt(playerCardIndex); RePosition(); NetworkSystem.GetInstance().SendServer(string.Format("PUT-CARD:{0}:{1}", PlayerId, playerCardIndex)); }
public void SelectCard_Ended(int playerIdx) { if (IsHoldCard == true) { IsHoldCard = false; var isPut = PlayerSystem.GetInstance().Players[playerIdx].IsPutCard; var isCompare = RuleSystem.GetInstance().CompareCard( DeckSystem.GetInstance().GetTopCardPeekWithDeck(DeckTag.PUT_DECK), _myCardList[HoldCardNum], isPut); if (_myCardList[HoldCardNum].GetPosition().y < -SceneSystem.GetInstance().ScreenSize.y * 0.4f || !isCompare) { PlayerSystem.GetInstance().Players[playerIdx].RePosition(); PlayerSystem.GetInstance().Players[playerIdx].ReScale(); } else { _myCardList[HoldCardNum].SetSortingOrder(HoldCardNum + 1); PlayerSystem.GetInstance().PlayerPutCard(DeckTag.PUT_DECK, PlayerSystem.GetInstance().MyPlayerId, HoldCardNum); RuleSystem.GetInstance().CheckSpecialCard( _myCardList[HoldCardNum].GetCardIndex(), isPut); } } }
public int RandomCard(string playerId, ref int cardIndex) { var player = PlayerSystem.GetInstance().GetPlayer(playerId); var cardIndexs = new List <int>(); var card = DeckSystem.GetInstance().GetTopCardPeekWithDeck(DeckTag.PUT_DECK); for (int i = 0; i < player.PlayerCard.Count; i++) { if (RuleSystem.GetInstance().CompareCard( card, player.PlayerCard[i], player.IsPutCard)) { cardIndexs.Add(i); } } if (cardIndexs.Count <= 0) { Debug.Log("no card"); return(-1); } var rand = new Random(); var randIndex = rand.Next(0, cardIndexs.Count - 1); cardIndex = cardIndexs[randIndex]; return(1); }
public void SetupOneCardAi() { IsStartAi.Subscribe(value => { if (value) { Debug.Log("ai start"); var cardIndex = 0; var playerId = TurnSystem.GetInstance().PlayerNowTurn.Value; var isPut = PlayerSystem.GetInstance().GetPlayerIsPutCard(playerId); Observable.Interval(TimeSpan.FromSeconds(0.5f)) .TakeWhile(_ => RandomCard(playerId, ref cardIndex) >= 0) .Subscribe(i => { var card = PlayerSystem.GetInstance().GetPlayerCard(playerId, cardIndex); PlayerSystem.GetInstance().PlayerPutCard(DeckTag.PUT_DECK, playerId, cardIndex, true); RuleSystem.GetInstance().CheckSpecialCard(card, isPut); }, () => { IsStartAi.Value = false; TurnSystem.GetInstance().EndTurn(); }); } }); }
/// <summary>deck1의 카드가 부족할 때 deck2의 카드로 채우고 섞음 </summary> /// <param name="deck1"></param> /// <param name="deck2"></param> public void FillDecktoDeckofAttack(DeckTag deck1, DeckTag deck2) { var nowTurn = TurnSystem.GetInstance().GetNowTurnPlayerIndex(); var isPut = PlayerSystem.GetInstance().Players[nowTurn].IsPutCard; var damage = RuleSystem.GetInstance().GetAttackDamage(isPut); var deck2Count = DeckSystem.GetInstance().GetCardCountWithDeck(deck2); Action addCardAction = () => { DeckSystem.GetInstance().ShuffleDeck(DeckTag.DRAW_DECK, 1000); NextTurn(nowTurn, damage); }; if (damage > deck2Count) { var count = DeckSystem.GetInstance().GetCardCountWithDeck(deck1); if (count + deck2Count <= damage) { return; } Debug.Log("move put -> draw : " + count); DeckSystem.GetInstance().MoveCardDecktoDeck( deck1, deck2, 0, 0, count - 1, 0, 0.2f, addCardAction); } else { NextTurn(nowTurn, damage); } }
/// <summary>플레이어 카드가 룰의 Max 카드를 넘었을 때 </summary> /// <returns>플레이어가 패배했다면 true, 아니라면 false</returns> public bool CheckDefeatPlayer() { var nowTurn = TurnSystem.GetInstance().GetNowTurnPlayerIndex(); var isPut = PlayerSystem.GetInstance().Players[nowTurn].IsPutCard; var damage = RuleSystem.GetInstance().GetAttackDamage(isPut); var playerCardCount = PlayerSystem.GetInstance().GetPlayerCardCount(nowTurn); var playerId = PlayerSystem.GetInstance().GetPlayerId(nowTurn); var isReverse = PlayerSystem.GetInstance().MyPlayerId == playerId ? true : false; if (damage + playerCardCount > RuleSystem.GetInstance().PlayerMaxCard) { PlayerSystem.GetInstance().PlayerCardMoveDeck(DeckTag.DRAW_DECK, nowTurn, isReverse, 0.1f); DeckSystem.GetInstance().ShuffleDeck(DeckTag.DRAW_DECK, 1000); TurnSystem.GetInstance().NextTurn(); PlayerSystem.GetInstance().RemovePlayer(playerId); TurnSystem.GetInstance().RemoveTurnPlayer(playerId); EndAttackTurn(); return(true); } return(false); }
public void EndAttackTurn() { RuleSystem.GetInstance().IsAttackTurn = false; RuleSystem.GetInstance().SaveAttackDamage = 0; AlertSystem.GetInstance().ClearAlert(); }