예제 #1
0
        private void db_Insert()
        {
            MemberDataContext memContext = new MemberDataContext();
            CardDataContext   card       = new CardDataContext();

            Member mem = new Member();

            mem.MemberName      = txtID.Text;
            mem.MemberPassword  = txtPassword.Text;
            mem.MemberPassword2 = txtPassword2.Text;

            memContext.Member.InsertOnSubmit(mem);
            try
            {
                memContext.SubmitChanges();
                card.Game_CardDeck(txtID.Text);
            }
            catch
            {
                MyMessageBox error = new MyMessageBox();
                error.SetText = "같은 아이디가 있습니다.";
                error.ShowDialog();
            }
        }
예제 #2
0
        private void userCard_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            selectCanvas = (Canvas)sender; // 클릭한놈으로 부터 canvas 연결
            int selectDeckCard = 0;

            try
            {
                if (UpdateCard == true)
                {
                    Test myDialog = new Test();

                    myDialog.SetText = "선택한 카드가 " + selectCanvas.Name + " 이 맞나요?";
                    myDialog.ShowDialog();

                    if (myDialog.DialogResult == true)
                    {
                        // Check
                        for (int i = 0; i < gameCardDeckList.Count; i++)
                        {
                            if (gameCardDeckList[i].CardName.CompareTo(selectCanvas.Name) == 0)
                            {
                                throw new ExceptionError();
                            }
                        }
                        // Update DataBase
                        for (int i = 0; i < playerCardDeckList.Count; i++)
                        {
                            if (playerCardDeckList[i].CardName.CompareTo(selectCanvas.Name) == 0)
                            {
                                selectDeckCard           = playerCardDeckList[i].cardNumber;
                                playerDeckCardList_Index = i;
                                break;
                            }
                        }
                        if (selectDeckCard == selectCardNumber)
                        {
                            throw new ExceptionError();
                        }
                        CardDataContext card = new CardDataContext();

                        var query =
                            from gameDeck in card.GameDeck
                            where gameDeck.MemberName == Player.getInstance().getID() && gameDeck.CardNumberID == selectCardNumber
                            select gameDeck;

                        foreach (var item in query)
                        {
                            item.CardNumberID = selectDeckCard;
                        }

                        try
                        {
                            card.SubmitChanges();
                            gameCardDeckList[gameDeckCardList_Index] = playerCardDeckList[playerDeckCardList_Index];
                            MyMessageBox myMessageBox = new MyMessageBox();
                            myMessageBox.SetText = "카드를 변경 하였어요.";
                            myMessageBox.ShowDialog();
                            gameDeckRef();
                        }
                        catch (Exception error)
                        {
                            MyMessageBox myMessageBoxError = new MyMessageBox();
                            myMessageBoxError.SetText = error.ToString();
                            myMessageBoxError.ShowDialog();
                        }
                    }
                    UpdateCard       = false;
                    selectCardNumber = 0;
                }
            }
            catch (ExceptionError)
            {
                MyMessageBox myMessageBoxError = new MyMessageBox();
                myMessageBoxError.SetText = "선택된 카드가 중복 되었네요. 다른 카드를 선택해 주세요.";
                myMessageBoxError.ShowDialog();
            }
        }
예제 #3
0
        void timer_Tick(object sender, EventArgs e)
        {
            time++;

            try
            {
                if (time <= 1 || time <= 14)
                {
                    int    i               = time - 1;
                    Card   card            = new Card();
                    Canvas playerSubCanvas = new Canvas();

                    card = playerCardDeckList[listCount];

                    playerSubCanvas.Name = card.CardName;

                    if (card.CardName == null)
                    {
                        throw new ExceptionError();
                    }

                    playerSubCanvas.Background = new ImageBrush(new BitmapImage(new Uri(card.CardName + ".png", UriKind.Relative)));
                    TextBlock hp         = new TextBlock();
                    TextBlock dam        = new TextBlock();
                    TextBlock skill      = new TextBlock();
                    TextBlock col        = new TextBlock();
                    TextBlock row        = new TextBlock();
                    TextBlock skillLine1 = new TextBlock();
                    TextBlock skillLine2 = new TextBlock();
                    TextBlock skillLine3 = new TextBlock();

                    hp.Name    = "hp";
                    dam.Name   = "dam";
                    skill.Name = "skill";
                    col.Name   = "index";
                    row.Name   = "gridName";

                    hp.Text         = card.CardHP.ToString();
                    dam.Text        = card.CardDam.ToString();
                    col.Text        = "0";
                    row.Text        = i.ToString();
                    skillLine1.Text = card.skill1 + ": 공격력 업";
                    skillLine2.Text = card.skill2 + ": 체력 업";
                    skillLine3.Text = card.skill3 + ": 턴 업";

                    hp.FontSize   = 10;
                    hp.Foreground = Brushes.Red;
                    hp.FontWeight = FontWeights.Bold;

                    dam.FontSize   = 10;
                    dam.Foreground = Brushes.Red;
                    dam.FontWeight = FontWeights.Bold;

                    skillLine1.FontSize   = 8;
                    skillLine1.Foreground = Brushes.Blue;
                    skillLine1.FontWeight = FontWeights.Bold;

                    skillLine2.FontSize   = 8;
                    skillLine2.Foreground = Brushes.Blue;
                    skillLine2.FontWeight = FontWeights.Bold;

                    skillLine3.FontSize   = 8;
                    skillLine3.Foreground = Brushes.Blue;
                    skillLine3.FontWeight = FontWeights.Bold;

                    playerBackCanvasList[i] = playerSubCanvas;

                    Canvas.SetLeft(hp, 65);
                    Canvas.SetBottom(hp, 37);

                    Canvas.SetLeft(dam, 22);
                    Canvas.SetBottom(dam, 36);

                    Canvas.SetLeft(skillLine1, 10);
                    Canvas.SetBottom(skillLine1, 26);

                    Canvas.SetLeft(skillLine2, 10);
                    Canvas.SetBottom(skillLine2, 17);

                    Canvas.SetLeft(skillLine3, 10);
                    Canvas.SetBottom(skillLine3, 8);

                    playerSubCanvas.Children.Add(hp);
                    playerSubCanvas.Children.Add(dam);
                    playerSubCanvas.Children.Add(skill);
                    playerSubCanvas.Children.Add(col);
                    playerSubCanvas.Children.Add(row);
                    playerSubCanvas.Children.Add(skillLine1);
                    playerSubCanvas.Children.Add(skillLine2);
                    playerSubCanvas.Children.Add(skillLine3);

                    playerSubCanvas.Width  = 100;
                    playerSubCanvas.Height = 150;

                    Canvas.SetTop(playerSubCanvas, 1000 - 150);
                    Canvas.SetLeft(playerSubCanvas, 1400 - 100);


                    Deck_Canvas.Children.Add(playerSubCanvas);
                    string targetGridName = "Me" + i;
                    //mvAni.Invoke(playerSubCanvas, (Grid)Play_Stage.FindName(targetGridName), i);
                    moveAnimation(playerSubCanvas, (Grid)Deck_Canvas.FindName(targetGridName), i);

                    //moveAnimation(playerSubCanvas, Me, i);
                    playerSubCanvas.MouseLeftButtonDown  += new MouseButtonEventHandler(userCard_MouseLeftButtonDown);
                    playerSubCanvas.MouseRightButtonDown += new MouseButtonEventHandler(Card_MouseLeftButtonDown);
                    ++listCount;

                    if (listCount >= playerCardDeckList.Count)
                    {
                        MyMessageBox messagebox = new MyMessageBox();
                        messagebox.SetText = "더이상 카드가 없어요.";
                        messagebox.ShowDialog();
                        //listCount = 0;
                        b2 = false;
                        b1 = true;
                        timer.Stop();
                        time = 0;
                        throw new ExceptionError();
                    }
                }
                else
                {
                    timer.Stop();
                    time = 0;
                    if (gtimeInit == true)
                    {
                        initMyDeck();
                        setGameDeckCard();
                        gtimeInit = false;
                    }
                    if (b1 == true)
                    {
                        button1.IsEnabled = true;
                    }
                    else
                    {
                        button1.IsEnabled = false;
                        b1 = true;
                    }
                    if (b2 == true)
                    {
                        button2.IsEnabled = true;
                    }
                    else
                    {
                        button2.IsEnabled = false;
                        b2 = true;
                    }
                    if (b3 == true)
                    {
                        button3.IsEnabled = true;
                    }
                    else
                    {
                        button3.IsEnabled = false;
                        b3 = true;
                    }
                    if (b4 == true)
                    {
                        button4.IsEnabled = true;
                    }
                    else
                    {
                        button4.IsEnabled = false;
                        b4 = true;
                    }
                    if (b5 == true)
                    {
                        button5.IsEnabled = true;
                    }
                    else
                    {
                        button5.IsEnabled = false;
                        b5 = true;
                    }
                }
            }
            catch (ExceptionError)
            {
                timer.Stop();
                time = 0;
                button2.IsEnabled = false;
                if (gtimeInit == true)
                {
                    initMyDeck();
                    setGameDeckCard();
                    gtimeInit = false;
                }
                if (b1 == true)
                {
                    button1.IsEnabled = true;
                }
                else
                {
                    button1.IsEnabled = false;
                    b1 = true;
                }
                if (b2 == true)
                {
                    button2.IsEnabled = true;
                }
                else
                {
                    button2.IsEnabled = false;
                    b2 = true;
                }
                if (b3 == true)
                {
                    button3.IsEnabled = true;
                }
                else
                {
                    button3.IsEnabled = false;
                    b3 = true;
                }
                if (b4 == true)
                {
                    button4.IsEnabled = true;
                }
                else
                {
                    button4.IsEnabled = false;
                    b4 = true;
                }
                if (b5 == true)
                {
                    button5.IsEnabled = true;
                }
                else
                {
                    button5.IsEnabled = false;
                    b5 = true;
                }
            }
        }