void MoveUsedCitizens()
    {
        GameObject yourCard  = yPlayZone.GetChild(0).gameObject;
        CardModel  cardModel = yourCard.GetComponent <CardModel>();

        cardModel.ToggleFace(true);
        if (yourCard.GetComponent <MoveCard>() != null)
        {
            MoveCard mv = yourCard.GetComponent <MoveCard>();
            Destroy(mv);
        }
        yourCard.transform.position = yDiscardZone.position;
        yourCard.transform.SetParent(yDiscardZone);

        GameObject enemyCard = ePlayZone.GetChild(0).gameObject;

        cardModel = enemyCard.GetComponent <CardModel>();
        cardModel.ToggleFace(true);
        if (enemyCard.GetComponent <MoveCard>() != null)
        {
            MoveCard mv = enemyCard.GetComponent <MoveCard>();
            Destroy(mv);
        }
        enemyCard.transform.position = eDiscardZone.position;
        enemyCard.transform.SetParent(eDiscardZone);
    }
예제 #2
0
 private void InitDecks()
 {
     House            = new HouseCard(6);
     Church           = new ChurchCard(7);
     TransportToInner = new MoveCard(10, 109);
     TransportToOuter = new MoveCard(17, 14);
     Medic            = new MedicCard(9);
     BlackSmith       = new BlackSmithCard(8);
     Dragon           = new DragonCard(12, 16);
     L1       = new List <Card>();
     L2       = new List <Card>();
     BlueDeck = new Stack <Card>();
     RedDeck  = new Stack <Card>();
     for (int i = 0; i < 20; i++)
     {
         L1.Add(new MonsterCard(2, 0));
         L1.Add(new MonsterCard(3, 1));
         L1.Add(new MonsterCard(4, 2));
         L2.Add(new MonsterCard(7, 12));
         L2.Add(new MonsterCard(9, 11));
         L2.Add(new MonsterCard(8, 15));
     }
     for (int i = 0; i < 10; i++)
     {
         L1.Add(new GoldCard(2, 3));
         L1.Add(new BlessCard(5));
         L1.Add(new CurseCard(4));
         L2.Add(new BlessCard(14));
         L2.Add(new CurseCard(13));
     }
 }
예제 #3
0
        private void SteppedOnCommunityChestSpace(Player[] players, IList <Space> listOfSpaces,
                                                  CommunityChestSpace CommunityChestSpaceObject, ChanceSpace ChanceSpaceObject, int currentPlayerCounter,
                                                  Player player, Space currentSpace)
        {
            ChanceCard drawCommunityChestCard = CommunityChestSpaceObject.DrawCard();

            if (drawCommunityChestCard is SpaceCard)
            {
                SpaceCard drawChanceCardAsSpaceCard = drawCommunityChestCard as SpaceCard;
                player.Position = drawChanceCardAsSpaceCard.PositionToGo;
                currentSpace    = listOfSpaces[player.Position];
                CheckSpaces(players, listOfSpaces, CommunityChestSpaceObject, ChanceSpaceObject, currentPlayerCounter, player, currentSpace);
            }
            if (drawCommunityChestCard is MoveCard)
            {
                MoveCard drawChanceCardAsMoveCard = drawCommunityChestCard as MoveCard;
                player.Position = drawChanceCardAsMoveCard.SquaresToMove + player.Position;
                currentSpace    = listOfSpaces[player.Position];
                CheckSpaces(players, listOfSpaces, CommunityChestSpaceObject, ChanceSpaceObject, currentPlayerCounter, player, currentSpace);
            }
            if (drawCommunityChestCard is GoodLuckCard)
            {
                GoodLuckCard drawChanceCardAsMoveCard = drawCommunityChestCard as GoodLuckCard;
                player.AddCash((int)drawChanceCardAsMoveCard.Cash);
            }
        }
예제 #4
0
    private bool CalculateHandValuesMove()
    {
        int[]  cardValues  = new int[cardManager.hand.Count];
        Tile[] cardTargets = new Tile[cardManager.hand.Count];
        for (int i = 0; i < cardManager.hand.Count; i++)
        {
            cardValues[i] = int.MaxValue;
            if (cardManager.hand[i] == null)
            {
                continue;
            }
            if (cardManager.hand[i].apCost > ap)
            {
                continue;
            }

            if (cardManager.hand[i] is MoveCard)
            {
                cardValues[i] = CardValueToMove(cardManager.hand[i], ref cardTargets[i], aggroTarget.tile);
            }
        }
        int playCardIdx = cardValues.ToList().IndexOf(cardValues.Min());

        if (cardValues[playCardIdx] == int.MaxValue)
        {
            return(false);
        }

        MoveCard chosenCard = (MoveCard)cardManager.hand[playCardIdx];

        cardManager.hand[playCardIdx].Use(cardTargets[playCardIdx], this);

        return(true);
    }
예제 #5
0
        public async Task <IActionResult> Move([FromBody] Card card)
        {
            var moving = new MoveCard(card);

            Console.WriteLine("Moving card {0}.", card.Id);
            return(await _commands.Execute(moving, When <CardMoved> .ThenOk));
        }
    public void Visit(MoveCard card)
    {
        var moveVector = Vector2Int.zero;

        switch (card.Direction)
        {
        case MoveDirection.Up:
            moveVector.y = card.Moves;
            break;

        case MoveDirection.Down:
            moveVector.y = -card.Moves;
            break;

        case MoveDirection.Right:
            moveVector.x = card.Moves;
            break;

        case MoveDirection.Left:
            moveVector.x = -card.Moves;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        _player.Movement.Move(moveVector);

        HandledCard(card);
    }
예제 #7
0
        public async void OnMoveCard(MoveCard moveCard)
        {
            bool result = await CardService.MoveCard(ActiveUser.Instance.LoggedUser.Token, moveCard.CardId, moveCard.NewListId);

            if (!result)
            {
                ShowMessageBox(null, "Error moving card.");
                return;
            }

            CardListViewModel oldListVM = CardListViewModels.FirstOrDefault(listVM => listVM.CardList.ListId == moveCard.OldListId);

            if (oldListVM == null)
            {
                return;
            }

            ReadCard oldCard = oldListVM.CardList.Cards.FirstOrDefault(card => card.CardId == moveCard.CardId);

            if (oldCard == null)
            {
                return;
            }

            oldListVM.CardList.Cards.Remove(oldCard);
            oldCard.ListId = moveCard.NewListId;

            CardListViewModel newListVM = CardListViewModels.FirstOrDefault(listVM => listVM.CardList.ListId == moveCard.NewListId);

            if (newListVM == null)
            {
                return;
            }
            newListVM.CardList.Cards.Add(oldCard);
        }
예제 #8
0
    private Card RandomMoveCard()
    {
        int         value = Random.Range(0, 100);
        Card        card  = null;
        List <Temp> list  = new List <Temp>();

        for (int i = 0; i < TBL_MOVE_CARD.CountEntities; i++)
        {
            TBL_MOVE_CARD data = TBL_MOVE_CARD.GetEntity(i);
            MoveCard      c    = new MoveCard(data);
            list.Add(new Temp(c.percent, CardType.EnergyCard, c));
        }

        float cumulative = 0f;

        for (int i = 0; i < list.Count; i++)
        {
            cumulative += list[i].percent;
            if (value <= cumulative)
            {
                card = list[i].card;
                break;
            }
        }
        return(card);
    }
    void CmdGrantPlayAbility()
    {
        if (GameObject.Find("You").transform.childCount == 3 && GameObject.Find("Opponent").transform.childCount == 3)
        {
            GameObject yourHand  = GameObject.Find("You").transform.GetChild(2).gameObject;
            GameObject enemyHand = GameObject.Find("Opponent").transform.GetChild(2).gameObject;

            if (hostTurn)
            {
                for (int i = 0; i < yourHand.transform.childCount; i++)
                {
                    if (yourHand.transform.GetChild(i).GetComponent <MoveCard>() == null)
                    {
                        yourHand.transform.GetChild(i).gameObject.AddComponent <MoveCard>();
                    }

                    yourHand.transform.GetChild(i).GetChild(0).gameObject.SetActive(true);
                }

                for (int i = 0; i < enemyHand.transform.childCount; i++)
                {
                    if (enemyHand.transform.GetChild(i).GetComponent <MoveCard>() != null)
                    {
                        MoveCard moveCard = enemyHand.transform.GetChild(i).GetComponent <MoveCard>();
                        Destroy(moveCard);
                    }

                    enemyHand.transform.GetChild(i).GetChild(0).gameObject.SetActive(false);
                }

                message = "It's your turn. Please play a card...";
            }

            else if (clientTurn)
            {
                for (int i = 0; i < yourHand.transform.childCount; i++)
                {
                    if (yourHand.transform.GetChild(i).GetComponent <MoveCard>() != null)
                    {
                        MoveCard moveCard = yourHand.transform.GetChild(i).GetComponent <MoveCard>();
                        Destroy(moveCard);
                    }

                    yourHand.transform.GetChild(i).GetChild(0).gameObject.SetActive(false);
                }

                for (int i = 0; i < enemyHand.transform.childCount; i++)
                {
                    enemyHand.transform.GetChild(i).GetChild(0).gameObject.SetActive(true);
                }

                message = "It's your opponent's turn. They are playing a card...";
            }

            guidelines.text = message;
            RpcGrantPlayAbility();
        }
    }
예제 #10
0
        public IActionResult MoveCard(MoveCard input)
        {
            var card = _databaseContext.Cards.Find(input.CardId);

            _gameManager.MoveCard(card, input.Destination, input.DestinationId);
            _databaseContext.SaveChanges();

            return(Ok());
        }
예제 #11
0
        public void TestMoveCardBackWardsAndCrossStart()
        {
            Game game      = new Game(new Player[] { new Player("X"), new Player("Y"), new Player("Z") });
            int  stepsToGo = -3;

            game.SetPlayerPos(game.Players[0], 0);
            MoveCard card = new MoveCard("", stepsToGo, game);

            card.UseCard(game.Players[0]);
            Assert.That(game.PlayerPos[game.Players[0]], Is.EqualTo(10));
        }
예제 #12
0
        public void TestMoveCardForwards()
        {
            Game game      = new Game(new Player[] { new Player("X"), new Player("Y"), new Player("Z") });
            int  stepsToGo = 3;

            game.SetPlayerPos(game.Players[0], 0);
            MoveCard card = new MoveCard("", stepsToGo, game);

            card.UseCard(game.Players[0]);
            Assert.That(game.PlayerPos[game.Players[0]], Is.EqualTo(3));
        }
예제 #13
0
        private void ListBox_Drop(object sender, DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(typeof(MoveCard)))
            {
                return;
            }

            MoveCard     moveCard = e.Data.GetData(typeof(MoveCard)) as MoveCard;
            ReadCardList cardList = ((CardListViewModel)DataContext).CardList;

            moveCard.NewListId = cardList.ListId;

            ((CardListViewModel)DataContext).OnMoveCard(moveCard);
        }
예제 #14
0
        public void RunProcessing(Object state)
        {
            bool isError = false;

            while (!isError)
            {
                // TODO будет ошибка если
                byte[] data = new byte[1024];

                try
                {
                    BinaryFormatter bf = new BinaryFormatter();

                    Message msg = (Message)bf.Deserialize(stream);

                    // TODO дополнительная проверка на возможность данного действия
                    if (msg.Action.Equals("move"))
                    {
                        MoveCard move = msg.Data as MoveCard;
                        if (move != null)
                        {
                            // TODO добавить проверку
                            context.Cards[move.MoveTo]   = context.Cards[move.MoveFrom];
                            context.Cards[move.MoveFrom] = null;

                            foreach (Client c in context.Clients)
                            {
                                c.SendEventToClient(msg);
                            }
                        }
                    }

                    //if (msg.Data is String)
                    //{
                    //	Console.ForegroundColor = ConsoleColor.Yellow;
                    //	Console.WriteLine(">>>" + Name + " " + msg.Action+":"+ msg.Data + "<<<");
                    //	Console.ResetColor();
                    //}
                } catch (Exception)
                {
                    isError = true;

                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(">>>" + Name + " " + "Bad man! Disconected!!! " + "<<<");
                    Console.ResetColor();
                }
            }

            stream.Close();
        }
예제 #15
0
        void network_ServerActionEvent(GameDomain.Message obj)
        {
            switch (obj.Action)
            {
            case "data":


                CardInfo[] cinf = obj.Data as CardInfo[];
                if (cinf == null)
                {
                    throw new Exception("No valid data");
                }

                for (int i = 0; i < cinf.Length; i++)
                {
                    if (cinf[i] != null)
                    {
                        places[i].Card = new Card(cinf[i].Color);
                    }
                }


                break;

            case "move":


                MoveCard move = obj.Data as MoveCard;
                if (move != null)
                {
                    places[move.MoveTo].Card   = places[move.MoveFrom].Card;
                    places[move.MoveFrom].Card = null;
                }


                if (activePlace != null)
                {
                    //	if (places[activePlace.Id] != null)
                    //	{
                    //		activePlace.Card = null;
                    activePlace.IsSelected = false;
                    activePlace            = null;
                    //	}
                }

                break;
            }

            repaint();
        }
예제 #16
0
    // 무브 카드 사용
    public float UseMoveCard(MoveCard cardData)
    {
        guard = 0;

        Vector2 newPosition;

        switch (cardData.moveType)
        {
        case MoveType.Left:
            newPosition = m_TilePosition + new Vector2(0, -cardData.distance);
            if (TileManager.Instance.CanMove(newPosition))
            {
                SetTilePosition(newPosition);
                SoundManager.Instance.PlaySFX("Move_Sound1");
            }
            break;

        case MoveType.Right:
            newPosition = m_TilePosition + new Vector2(0, cardData.distance);
            if (TileManager.Instance.CanMove(newPosition))
            {
                SetTilePosition(newPosition);
                SoundManager.Instance.PlaySFX("Move_Sound2");
            }
            break;

        case MoveType.Up:
            newPosition = m_TilePosition + new Vector2(-cardData.distance, 0);
            if (TileManager.Instance.CanMove(newPosition))
            {
                SetTilePosition(newPosition);
                SoundManager.Instance.PlaySFX("Move_Sound3");
            }
            break;

        case MoveType.Down:
            newPosition = m_TilePosition + new Vector2(cardData.distance, 0);
            if (TileManager.Instance.CanMove(newPosition))
            {
                SetTilePosition(newPosition);
                SoundManager.Instance.PlaySFX("Move_Sound4");
            }
            break;
        }

        return(GameSetting.MoveCardTime);
    }
예제 #17
0
        private void listbox_MouseMove(object sender, MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (e.LeftButton == MouseButtonState.Pressed && ((CardListViewModel)DataContext).SelectedCard != null)
            {
                if (DataContext is CardListViewModel)
                {
                    CardListViewModel cardListVM = DataContext as CardListViewModel;
                    ReadCardList      cardList   = cardListVM.CardList;
                    ReadCard          card       = cardListVM.SelectedCard;

                    MoveCard moveCard = new MoveCard()
                    {
                        CardId = card.CardId, OldListId = cardList.ListId, NewListId = cardList.ListId
                    };

                    DataObject data = new DataObject();
                    data.SetData(typeof(MoveCard), moveCard);

                    DragDrop.DoDragDrop(this, data, DragDropEffects.Move);
                    cardListVM.OnMoveCardDrag(card.CardId);
                }
            }
        }
예제 #18
0
 public void OnMoveCard(MoveCard moveCard)
 {
     OnMoveCardAction?.Invoke(moveCard);
 }
예제 #19
0
 void When(MoveCard c)
 {
     Then(new CardMoved(c.Card));
 }
예제 #20
0
    void SetCard()
    {
        int startCount = CardSetting.AttackCardStartCount;

        while (startCount > 0)
        {
            int        random = Random.Range(0, TBL_ATTACK_CARD.CountEntities);
            AttackCard card   = new AttackCard(TBL_ATTACK_CARD.GetEntity(random));
            if (!CheckDuplicate(card))
            {
                cardList.Add(card);
                startCount--;
            }
        }

        startCount = CardSetting.EnergyCardStartCount;
        while (startCount > 0)
        {
            int        random = Random.Range(0, TBL_ENERGY_CARD.CountEntities);
            EnergyCard card   = new EnergyCard(TBL_ENERGY_CARD.GetEntity(random));
            if (!CheckDuplicate(card))
            {
                cardList.Add(card);
                startCount--;
            }
        }

        startCount = CardSetting.GuardCardStartCount;
        while (startCount > 0)
        {
            int       random = Random.Range(0, TBL_GUARD_CARD.CountEntities);
            GuardCard card   = new GuardCard(TBL_GUARD_CARD.GetEntity(random));
            if (!CheckDuplicate(card))
            {
                cardList.Add(card);
                startCount--;
            }
        }

        startCount = CardSetting.HealCardStartCount;
        while (startCount > 0)
        {
            int      random = Random.Range(0, TBL_HEAL_CARD.CountEntities);
            HealCard card   = new HealCard(TBL_HEAL_CARD.GetEntity(random));
            if (!CheckDuplicate(card))
            {
                cardList.Add(card);
                startCount--;
            }
        }

        startCount = CardSetting.MoveCardStartCount;
        while (startCount > 0)
        {
            int      random = Random.Range(0, TBL_MOVE_CARD.CountEntities);
            MoveCard card   = new MoveCard(TBL_MOVE_CARD.GetEntity(random));
            if (!CheckDuplicate(card))
            {
                cardList.Add(card);
                startCount--;
            }
        }



        Shuffle(cardList);

        //for(int i=0; i<list.Count; i++)
        //{
        //    cardPos[i].GetComponent<CardComponent>().SetCard(list[i]);
        //}

        UpdateCardPos();
    }