예제 #1
0
        public void DealCards()
        {
            // Reset the board
            GameHelper.ResetImages(Player, Computer);
            GameHelper.ResetGame(Player, Computer);
            View.ResetResult();
            View.SplitDeck(Player, false);
            BetPlaced = true;

            int cardOne = Random.Next(2, 12);
            int cardTwo = Random.Next(2, 12);

            GameHelper.AddAces(Player, cardOne);
            GameHelper.AddAces(Player, cardTwo);

            Player.Images[0].Source = ImagesHelper.RandomColorCard(CardImages.First(x => x.Key == cardOne).Value);
            Player.Images[1].Source = ImagesHelper.RandomColorCard(CardImages.First(x => x.Key == cardTwo).Value);
            Player.Score            = cardOne + cardTwo;
            View.DisplayPoints(Player);

            if (cardOne == cardTwo)
            {
                DoubleCards = true;
            }
            if (Player.Score > 21)
            {
                GameHelper.HasAces(Player);
                View.DisplayPoints(Player);
            }
        }
예제 #2
0
        public void Stand(bool isSplit)
        {
            int cardOne = Random.Next(2, 12);
            int cardTwo = Random.Next(2, 12);

            GameHelper.AddAces(Computer, cardOne);
            GameHelper.AddAces(Computer, cardTwo);

            Computer.Images[0].Source =
                ImagesHelper.RandomColorCard(CardImages.First(x => x.Key == cardOne).Value);
            Computer.Images[1].Source =
                ImagesHelper.RandomColorCard(CardImages.First(x => x.Key == cardTwo).Value);

            Computer.Score = cardOne + cardTwo;
            View.DisplayPoints(Computer);

            if (Computer.Score < 17 || (Computer.Score > 21 && GameHelper.HasAces(Computer)))
            {
                TaskFactory = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext());
                new Thread(() => HitCardComputer(isSplit)).Start();
            }
            else
            {
                End(isSplit);
            }
            BetPlaced = false;
        }
예제 #3
0
 private void DisplayCard(int card)
 {
     Computer.Images[Computer.CurrentImage].Source =
         ImagesHelper.RandomColorCard(CardImages.First(x => x.Key == card).Value);
     Computer.CurrentImage++;
     View.DisplayPoints(Computer);
 }
예제 #4
0
    //ドラ表示牌を表示
    private void ShowBonusCards()
    {
        GameManagerScript.DestroyGameObjects(ref bonusObjects); //表示しているドラ表示牌のゲームオブジェクトを削除

        int[] cards = GetBonusCards();                          //ドラ表示牌を取得

        for (int i = 0; i < cards.Length / 2; i++)
        {
            GameObject cardObject = new GameObject();
            Sprite     sprite;
            if (i <= showBonusIndex)
            {
                sprite =
                    CardImages.Image_Front(cards[i]);    //表向きの牌画像
            }
            else
            {
                sprite = CardImages.Image_Back();                       //裏向きの牌画像
            }
            cardObject.AddComponent <SpriteRenderer>().sprite = sprite; //牌画像を格納
            cardObject.transform.localScale = Layouts.bonusScale;       //大きさを決定
            cardObject.transform.position   = Layouts.bonusOffset + Layouts.bonusLineupDirection * i;
            cardObject.transform.rotation   =
                Quaternion.Euler(Layouts.bonusRotation); //角度を決定

            bonusObjects.Add(cardObject);                //メモリ解放用のリストに格納
        }
    }
예제 #5
0
        public void SeedData(string path)
        {
            JArray json;

            using (var textReader = new StreamReader(path))
                using (var jsonReader = new JsonTextReader(textReader))
                {
                    json = JArray.Load(jsonReader);
                }

            foreach (JObject cardJson in json)
            {
                var cardImage = new CardImage
                {
                    Id          = Guid.Parse((string)cardJson["ImageId"]),
                    OtherId     = Guid.Parse((string)cardJson["OtherImageId"]),
                    IsLightSide = (bool)cardJson["IsLightSide"],
                    IsFront     = (bool)cardJson["IsFront"],
                    Title       = (string)cardJson["CardName"],
                    Destiny     = (string)cardJson["Destiny"],
                    Expansion   = (string)cardJson["Expansion"],
                    InfoJson    = cardJson.ToString(Formatting.Indented)
                };

                cardImage.TitleNormalized = cardImage.Title.NormalizedForSearch();
                CardImages.Add(cardImage);
            }

            SaveChanges();
        }
예제 #6
0
    //プレイヤー1名分の手牌を表示(基底関数)
    private void ShowHand_Only(int player, bool show)
    {
        GameManagerScript.DestroyGameObjects(ref handObjects[player]);    //表示している手牌のゲームオブジェクトを削除
        for (int i = 0; i < hands[player].Count; i++)
        {
            GameObject card = new GameObject();
            Sprite     sprite;
            int        handCard = hands[player][i];
            if (show)
            {
                sprite =
                    CardImages.Image_Front(handCard);    //表向きの牌画像
            }
            else
            {
                sprite = CardImages.Image_Back();    //裏向きの牌画像
            }

            card.AddComponent <SpriteRenderer>().sprite = sprite;       //牌画像を格納
            card.transform.localScale = Layouts.handScales[player];     //大きさを決定
            card.transform.position   = Layouts.handOffsets[player] + Layouts.handLineupDirections[player] * i;
            card.transform.rotation   =
                Quaternion.Euler(Layouts.handRotations[player]);    //角度を決定

            if (player == 0 && UserActions.Playing())
            {
                card.AddComponent <BoxCollider2D>();

                int index = i;
                for (int j = 0; j < UserActions.handIndexes_forCall.Length; j++)
                {
                    if (index == UserActions.handIndexes_forCall[j])
                    {
                        Color color = card.GetComponent <SpriteRenderer>().color;
                        color.a = 0.5f;
                        card.GetComponent <SpriteRenderer>().color = color;
                    }
                }

                EventTrigger.Entry down = new EventTrigger.Entry();
                down.eventID = EventTriggerType.PointerDown;
                down.callback.AddListener((f) => UserActions.MouseDown(handCard, index, this));
                card.AddComponent <EventTrigger>().triggers.Add(down);

                EventTrigger.Entry drag = new EventTrigger.Entry();
                drag.eventID = EventTriggerType.PointerEnter;
                drag.callback.AddListener((f) => UserActions.MouseMove(index, this, ref hands[0]));
                card.GetComponent <EventTrigger>().triggers.Add(drag);

                EventTrigger.Entry click = new EventTrigger.Entry();
                click.eventID = EventTriggerType.PointerClick;
                click.callback.AddListener((f) => UserActions.MouseClick(index, this));
                card.GetComponent <EventTrigger>().triggers.Add(click);
            }

            handObjects[player].Add(card);      //メモリ解放用のリストに格納
        }
    }
예제 #7
0
        public async Task SeedDataAsync(string path)
        {
            using (var document = await LoadDocumentAsync(path))
            {
                foreach (var cardJson in document.RootElement.EnumerateArray())
                {
                    var cardImage = CardImage.FromJson(cardJson);
                    await CardImages.AddAsync(cardImage);
                }

                await SaveChangesAsync();
            }
        }
예제 #8
0
        public void HitCard()
        {
            int card = Random.Next(2, 12);

            GameHelper.AddAces(Player, card);

            Player.Images[Player.CurrentImage].Source = ImagesHelper.RandomColorCard(CardImages.First(x => x.Key == card).Value);
            Player.CurrentImage++;
            Player.Score += card;

            if (Player.Score > 21 && !GameHelper.HasAces(Player))
            {
                BetPlaced = false;
                End(false);
            }
            View.DisplayPoints(Player);
        }
예제 #9
0
    private int seed;       //乱数のseed値(表示用)


    // Use this for initialization
    void Start()
    {
        //Random.SetSeed(DateTime.Now.Millisecond);

        //272:PL明カン→PL加カン,552&977:初手PL暗カン
        seed = 540;
        seed = DateTime.Now.Millisecond;                                           //seed値決定
        Random.SetSeed(10000 + seed);                                              //seed値を入力

        GameObject.Find("Canvas/SeedText").GetComponent <Text>().text = "" + seed; //seed値を表示

        CardImages.Initialize();
        UserActions.ti_PL      = Ti_PL;
        UserActions.pon_PL     = Pon_PL;
        UserActions.kan_PL     = Kan_PL;
        UserActions.discard_PL = Discard_PL;

        Initialize_NewGame();       //ゲーム開始時用の初期化処理
    }
예제 #10
0
    //プレイヤー1名分の捨て牌を表示(基底関数)
    private void ShowTableCard_Only(int player)
    {
        GameManagerScript.DestroyGameObjects(ref tableObjects[player]);       //捨て牌のゲームオブジェクトを削除

        for (int i = 0; i < tables[player].Count; i++)
        {
            GameObject card   = new GameObject();
            Sprite     sprite = CardImages.Image_Front(tables[player][i]);  //画像を取得
            card.AddComponent <SpriteRenderer>().sprite = sprite;           //画像を格納
            card.transform.localScale = Layouts.tableScales[player];        //大きさを決定
            card.transform.position   =
                Layouts.tableOffsets[player] +
                Layouts.tableLineupNextDirections[player] * (i % 6) +
                Layouts.tableLineupNewLineDirections[player] * (i / 6); //表示場所を決定
            card.transform.rotation =
                Quaternion.Euler(Layouts.tableRotations[player]);       //角度を決定

            tableObjects[player].Add(card);                             //メモリ解放用のリストに格納
        }
    }
예제 #11
0
        public void HitCardSplit(bool leftDeck)
        {
            int card = Random.Next(2, 12);

            GameHelper.AddAcesSplit(Player, card, leftDeck);

            if (leftDeck)
            {
                Player.SplitDeck.ImagesLeft[Player.SplitDeck.CurrentImageLeft].Source =
                    ImagesHelper.RandomColorCard(CardImages.First(x => x.Key == card).Value);
                Player.SplitDeck.CurrentImageLeft++;
                Player.SplitDeck.ScoreLeft += card;

                if (Player.SplitDeck.ScoreLeft > 21 && !GameHelper.HasAcesSplit(Player, true))
                {
                    Player.SplitDeck.FinishedLeft = true;
                    if (Player.SplitDeck.FinishedRight)
                    {
                        Stand(true);
                    }
                }
                View.DisplayPointsSplit(Player);
            }
            else
            {
                Player.SplitDeck.ImagesRight[Player.SplitDeck.CurrentImageRight].Source =
                    ImagesHelper.RandomColorCard(CardImages.First(x => x.Key == card).Value);
                Player.SplitDeck.CurrentImageRight++;
                Player.SplitDeck.ScoreRight += card;

                if (Player.SplitDeck.ScoreRight > 21 && !GameHelper.HasAcesSplit(Player, false))
                {
                    Player.SplitDeck.FinishedRight = true;
                    if (Player.SplitDeck.FinishedLeft)
                    {
                        Stand(true);
                    }
                }
                View.DisplayPointsSplit(Player);
            }
        }
        public FidelityViewModel()
        {
            NewCard     = new CommandHandler(CreateCard, param => CanExecute);
            BackLogin   = new CommandHandler(BackToLogin, param => CanExecute);
            ChangePhoto = new CommandHandler(ItemClick, param => CanExecute);

            DatabaseInteraction = new DataService();
            Cards = DatabaseInteraction.GetFidelityCards();
            if (Cards.Count > 0)
            {
                WelcomeText = "Alegeti cardul dorit!";
            }
            else
            {
                WelcomeText = "Nu aveti nici un card in aplicatie!";
            }
            foreach (CardFidelitate card in Cards)
            {
                CardImages.Add(card.FrontPath);
            }
        }
예제 #13
0
        private void PopulateCardImages()
        {
            string imagesDirectory = "Images";

            CardImages.Clear();
            for (int i = 1; i <= DifferentCardsCount; i++)
            {
                string fileName = Path.GetFullPath(Path.Combine(imagesDirectory, +i + ".jpg"));
                if (!File.Exists(fileName))
                {
                    MessageBox.Show(this, "Cannot open file " + fileName, "Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    Close();
                }


                CardImages.Add(new CardImage()
                {
                    FilePath = fileName, Name = "name" + i, Date = File.GetCreationTime(fileName)
                });
            }
        }
예제 #14
0
    //鳴き牌表示
    private void ShowCallCard_Only(int player)
    {
        GameManagerScript.DestroyGameObjects(ref callObjects[player]);    //表示している手牌のゲームオブジェクトを削除

        Vector2 position =
            new Vector2(Layouts.callOffsets[player].x, Layouts.callOffsets[player].y);  //表示位置の初期地点

        for (int s = 0; s < calls[player].Count; s++)
        {
            for (int i = 0; i < calls[player][s].callCards.Count; i++)
            {
                CallCard   callCard = calls[player][s].callCards[i]; //牌の情報を取得
                GameObject card     = new GameObject();
                Sprite     sprite;
                if (callCard.closedKan_hide)
                {
                    sprite = CardImages.Image_Back();   //裏向き
                }
                else
                {
                    sprite = CardImages.Image_Front(callCard.cardId);   //表向き
                }
                card.AddComponent <SpriteRenderer>().sprite = sprite;   //画像を格納
                card.transform.localScale = Layouts.callScales[player]; //大きさを決定

                float   addDirection;                                   //回転した牌のための余白を用意するかどうかのフラグ
                Vector3 addRotation;                                    //回転した牌の場合に追加する回転量
                Vector2 addY = new Vector2(0f, 0f);                     //加カン牌用のずらしフラグ
                if (callCard.discardPlayer == player)
                {
                    //自分の鳴き牌の場合は回転はなし
                    addDirection = 0f;
                    addRotation  = new Vector3(0f, 0f, 0f);
                }
                else
                {
                    //他家の捨て牌の場合は回転させる
                    position    += Layouts.callLineupRotatedAddDirections[player]; //回転分の座標補正
                    addDirection = 1.0f;                                           //余白用意フラグを立てる
                    addRotation  = new Vector3(0f, 0f, 90f);                       //回転させる
                    addY         = Layouts.callLineupRotatedAddYPositions[player]; //高さ補正
                }
                if (callCard.addKan)
                {
                    //加カン牌の場合は基本位置xを戻す。yはずらすフラグを立てる
                    position -=
                        Layouts.callLineupDirections[player] +
                        Layouts.callLineupRotatedAddDirections[player];
                    addY =
                        Layouts.callLineupRotatedAddYPositions[player] +
                        Layouts.callLineupAddDoubleYPositions[player];

                    addDirection = 1.0f;                     //余白用意フラグを立てる
                    addRotation  = new Vector3(0f, 0f, 90f); //回転させる
                }
                card.transform.position = position + addY;   //牌の表示位置を決定
                //回転の有無を考慮して次の牌の基本位置を決定
                position +=
                    Layouts.callLineupDirections[player] +
                    Layouts.callLineupRotatedAddDirections[player] * addDirection;
                card.transform.rotation =
                    Quaternion.Euler(Layouts.callRotations[player] + addRotation); //牌の角度を決定

                callObjects[player].Add(card);                                     //メモリ解放用のリストに格納
            }
        }
    }