void selectok()
    {
        Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
        //Debug.DrawRay(ray.origin, ray.direction * 100, Color.red, 0.1f, false);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 200))
        {
            if (hit.collider.CompareTag("Cards"))
            {
                if (Input.GetMouseButtonDown(0) && Isselect == false)
                {
                    GameObject hit_obj = hit.collider.gameObject;
                    CCont          = hit_obj.GetComponent <CardControl>();
                    CCont.flipflag = true;

                    //Sound
                    PlayTurnSounds(hit_obj);

                    //Effect
                    ActiveEff(hit.collider.gameObject);

                    Debug.Log(CCont.cardIndex);

                    if (CCont.cardIndex == 32)
                    {
                        CC.Issetting = 10;
                        Invoke("ready", 2.0f);
                        StartCoroutine(Discards(hit_obj));
                    }
                }
            }
        }
    }
        private async void CreateBtn_Click(object sender, EventArgs e)
        {
            if (ValidateForm())
            {
                Announcement newAnnounce = new Announcement
                {
                    Title       = titleValue.Text,
                    Description = descriptionValue.Text
                };
                // Add to DB
                myDashboard._context.Announcements.Add(newAnnounce);
                await myDashboard._context.SaveChangesAsync();

                // Update announcements listBox
                myDashboard.Announcements.Insert(0, newAnnounce);

                // Update panel with new set of recent announcements
                myDashboard.announcementsFLPanel.Controls.Clear();
                foreach (var announcement in myDashboard.Announcements.Take(3))
                {
                    CardControl cardControl = new CardControl(announcement);
                    myDashboard.announcementsFLPanel.Controls.Add(cardControl);
                }

                this.Close();
            }
        }
Esempio n. 3
0
        public LocationAnimation(CardControl control) : base(control)
        {
            Control.Style.RegisterBinding(this);

            m_locationTrack = new Animation.CurveTrack(GameApp.Service<Services.ResourceManager>().Acquire<Curve>("Curves/CardMove"));
            m_locationTrack.Elapsed += w =>
            {
                m_locationTransform = Matrix.Lerp(m_locationSrcTransform, m_locationDstTransform, w);
                m_cardSummoned.EffectInstances.ForEach(fx => fx.IsEmitting = m_playToBattlefield && w != 1.0f);
            };

            NextLocation = m_lastLocation = new LocationParameter { m_zone = null, m_numCards = 0, m_thisIndex = -1, m_focusIndex = -1 };

            m_cardSummoned = new Particle.ParticleSystemInstance(GameApp.Service<Services.ResourceManager>().Acquire<Particle.ParticleSystem>("Particles/CardSummoned"));
            m_cardSummoned.LocalFrameProvider = this;

            m_cardActivated = new Particle.ParticleSystemInstance(GameApp.Service<Services.ResourceManager>().Acquire<Particle.ParticleSystem>("Particles/CardActivated"));
            m_cardActivated.LocalFrameProvider = this;
            m_activateEffectTimer = new Animation.LinearTrack(0.4f);
            m_activateEffectTimer.Elapsed += w =>
            {
                m_cardActivated.EffectInstances.ForEach(fx => fx.IsEmitting = m_lastActivated && w != 1.0f);
            };
            m_activateEffectTimer.Play();
        }
Esempio n. 4
0
 public CurrentPlayControl(CardControl cardOne, CardControl cardTwo)
 {
     InitializeComponent();
     playedCardOne = new CardControl(new Card(cardOne.Suit, cardOne.Rank, cardOne.CardImage));
     playedCardTwo = cardTwo;
     //format();
 }
Esempio n. 5
0
        public Flip(CardControl control) : base(control)
        {
            Control.Style.RegisterBinding(this);

            m_track = new Animation.LinearTrack(0.3f);
            m_track.Elapsed += w => UpdateMatrix(Flipped ? w : 1 - w);
        }
    IEnumerator AddCardAnimationCoroutine(CardControl card, int removeVirusCount = 0)
    {
        var targetpos = transform.position;

        targetpos.z -= 0.2f;
        var srcpos = card.transform.position;

        var d = new Vector3((targetpos.x - srcpos.x) / 20f, (targetpos.y - srcpos.y) / 20f, (targetpos.z - srcpos.z) / 20f);

        for (int i = 0; i < 20; i++)
        {
            card.transform.Translate(d);
            yield return(null);
        }

        card.transform.position = targetpos;

        Debug.Log(removeVirusCount + "個を消す");

        for (int i = 0; i < removeVirusCount; i++)
        {
            // 菌をランダムにinactiveにする
            List <GameObject> activeBacterias = _bacterias.FindAll(bpv => bpv.activeSelf == true);
            System.Random     r = new System.Random(1000);
            activeBacterias[r.Next(0, activeBacterias.Count - 1)].SetActive(false);
        }
    }
Esempio n. 7
0
        private bool ValidateThirtyMinutesRule(CardControl cardSavedInDataBase)
        {
            var timeNowInUTC = DateTime.UtcNow;
            var diffTimes    = timeNowInUTC - cardSavedInDataBase.RegistrationDate;

            return(diffTimes.TotalMinutes <= 30);
        }
Esempio n. 8
0
        private void cardClicked(object sender, RoutedEventArgs e)
        {
            CardControl cardControl = ((CardControl)sender);
            GameWindow  parent      = ((GameWindow)Window.GetWindow(this));

            OnCardClicked(cardControl);
        }
Esempio n. 9
0
    /// 完成思考,开始出价
    private void onCompleteBid()
    {
        int value = roomControl.RoomData.CurBidPrice;
        // TODO 电脑策略,暂时使用3种
        List <int> cards = roomControl.sendCardControl.GetBindCards(playerData.UUID);

        bidCards = new List <CardControl>();
        int curCardPrice = 0;

        for (int i = 0; i < cards.Count; ++i)
        {
            CardControl card = roomControl.sendCardControl.GetCardControl(cards[i]);
            Coins       data = card.cardData.GetData <Coins>();
            if (data != null)
            {
                // TODO 最优解不同面值组合刚好达到目标价格
                // 临时简单叠加,够了就不继续了
                bidCards.Add(card);
                curCardPrice += data.Value;
                if (curCardPrice > value)
                {
                    break;
                }
            }
        }
        if (curCardPrice > value)
        {
            SignalManager.Instance.Create <RoomControl.CompleteBidSignal>().Dispatch(this, curCardPrice);
            GetPlayerItem().ShowBidPrice(curCardPrice);
        }
    }
Esempio n. 10
0
    /// 卡牌位置变更
    public void MoveCardPosEnum(int cardUId, RoomCardPosEnum toPosEnum)
    {
        CardControl cc = GetCardControl(cardUId);

        // if(cc.LastPosEnum == toPosEnum) return;
        if (cc.LastPosEnum != RoomCardPosEnum.None)
        {
            if (cardPosList.ContainsKey(cc.LastPosEnum))
            {
                int last = cardPosList[cc.LastPosEnum].IndexOf(cardUId);
                if (last != -1)
                {
                    cardPosList[cc.LastPosEnum].RemoveAt(last);
                }
            }
        }
        if (toPosEnum != RoomCardPosEnum.None)
        {
            if (!cardPosList.ContainsKey(toPosEnum))
            {
                cardPosList.Add(toPosEnum, new List <int>());
            }
            cardPosList[toPosEnum].Add(cardUId);
        }
        int       playerUId = GetCardPlayer(cardUId) == null ? -1 : GetCardPlayer(cardUId).playerData.UUID;
        Transform cardItem  = cc.GetItem().transform;

        cardItem.SetParent(roomControl.GetTransByPos(toPosEnum, cc.cardData, playerUId), true);
        cardItem.localScale    = new Vector3(1, 1, 1);
        cardItem.localRotation = Quaternion.identity;
        cc.MoveCard(roomControl.GetCardPos(cc.LastPosEnum, cc.cardData, playerUId), roomControl.GetCardPos(toPosEnum, cc.cardData, playerUId), toPosEnum, onMoveCompleted);
    }
    IEnumerator AddCardAnimationCoroutine(CardControl card)
    {
        var targetpos = transform.position;

        targetpos.z -= 0.2f;
        var srcpos = card.transform.position;

        var d = new Vector3((targetpos.x - srcpos.x) / 20f, (targetpos.y - srcpos.y) / 20f, (targetpos.z - srcpos.z) / 20f);

        for (int i = 0; i < 20; i++)
        {
            card.transform.Translate(d);
            yield return(null);
        }

        card.transform.position = targetpos;

        // periodをactiveにする
        _period.SetActive(true);

        // Typeをactiveにする
        _type.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Type/" + card.Type.ToString());
        _type.SetActive(true);

        // ウイルスの色を点灯
        _virus[(int)card.Color].SetActive(true);
    }
Esempio n. 12
0
    //抽一张卡
    public CardControl CreateCard(CardInfo cardInfo)
    {
        GameObject  newCard  = Instantiate(cardPrefab, transform);
        CardControl cardCtrl = newCard.GetComponent <CardControl>();

        cardCtrl.Init(cardInfo);
        return(cardCtrl);
    }
Esempio n. 13
0
    public void SetData(CardControl control)
    {
        this.control = control;
        cardData     = control.cardData;

        ChangePosEnum();
        addEvent();
    }
Esempio n. 14
0
    public void addToStack(SpriteRenderer heldCard, List <SpriteRenderer> targetStack)
    {
        CardControl heldCardControl = heldCard.GetComponent <CardControl>();

        heldCardControl.currentStack.Remove(heldCard);
        heldCardControl.currentStack = targetStack;
        heldCardControl.currentStack.Add(heldCard);
        initHand();
    }
Esempio n. 15
0
    /// 是否显示卡面
    public bool IsShowContent()
    {
        CardControl cc = PlayerManager.Instance.PlayerSelf.roomControl.sendCardControl.GetCardControl(cardData.UUID);

        return(IsSelfCard() ||
               // cc.LastPosEnum == RoomCardPosEnum.PublicDesk && isFlipFront ||
               cc.LastPosEnum == RoomCardPosEnum.PublicDesk ||
               cc.LastPosEnum == RoomCardPosEnum.PlayerHand && cardData.IsT <Animals>());
    }
Esempio n. 16
0
        public CardControl GetCardDuplication(TokenControlContext _context, CardControl cardControl)
        {
            var cardSaved = _context.CardControl.FirstOrDefault(e =>
                                                                (e.Cardnumber == cardControl.Cardnumber) &&
                                                                (e.CustomerId == cardControl.CustomerId) &&
                                                                (e.CVV == cardControl.CVV));

            return(cardSaved);
        }
Esempio n. 17
0
        public void AddCard(CardControl c)
        {
            if (OnCardClicked != null)
            {
                c.AddHandler(MouseUpEvent, new RoutedEventHandler(cardClicked));
            }

            cards.Insert(0, c);
        }
Esempio n. 18
0
 public CardIcons(CardControl control)
     : base(control)
 {
     m_counterFmtOptions = new Graphics.TextRenderer.FormatOptions(
         new Graphics.TextRenderer.FontDescriptor("Helvetica", 26, System.Drawing.FontStyle.Bold));
     m_textFmtOptions = new Graphics.TextRenderer.FormatOptions(
         new Graphics.TextRenderer.FontDescriptor("Microsoft YaHei", 12),
         new Graphics.TextRenderer.FontDescriptor("Constantia", 12));
 }
Esempio n. 19
0
    public void AddCard()
    {
        int hand        = transform.childCount;
        int countVowels = 0;
        int maxVowl     = 2;

        foreach (Transform child in transform)
        {
            CardControl c = child.GetComponent <CardControl>();
            if (c.letter.ToLower().Equals("a") || c.letter.ToLower().Equals("e") || c.letter.ToLower().Equals("u") || c.letter.ToLower().Equals("i") || c.letter.ToLower().Equals("o"))
            {
                countVowels++;
            }
        }

        if (countVowels < 2)
        {
            maxVowl = 2;
        }

        for (int i = hand; i < 7; i++)
        {
            GameObject randomBlankCard = RandomColor.Instance.GetRandomCard();

            GameObject instantCard = Instantiate(randomBlankCard, transform);

            Card card;
            if (maxVowl != 0)
            {
                card = ResourceManager.Instance.GuarenteeVowels();
                maxVowl--;
            }
            else
            {
                card = ResourceManager.Instance.Draw();
            }


            if (card != null)
            {
                CardControl cc     = instantCard.GetComponent <CardControl>();
                Text        letter = instantCard.transform.GetChild(0).GetComponent <Text>();
                Text        value  = instantCard.transform.GetChild(1).GetComponent <Text>();

                cc.letter = card.Letter.ToString();
                cc.value  = card.Value;

                letter.text = cc.letter;
                value.text  = cc.value.ToString();
            }
            else
            {
                GameController.Instance.isDeckOut = true;
            }
        }
    }
Esempio n. 20
0
    public List <SpriteRenderer> addToStack(SpriteRenderer heldCard, SpriteRenderer targetCard)
    {
        CardControl heldCardControl   = heldCard.GetComponent <CardControl>();
        CardControl targetCardControl = targetCard.GetComponent <CardControl>();

        if (heldCardControl.currentStack == targetCardControl.currentStack)
        {
            refreshStack(heldCardControl.currentStack);
            initHand();
            return(heldCardControl.currentStack);
        }
        if (targetCardControl.currentStack == hand)
        {
            heldCardControl.currentStack.Remove(heldCard);
            heldCardControl.currentStack = targetCardControl.currentStack;
            heldCardControl.currentStack.Add(heldCard);
            initHand();
        }
        else
        {
            List <SpriteRenderer> boss;
            List <SpriteRenderer> member;
            List <SpriteRenderer> tool;
            sortCrewCards(targetCardControl.currentStack, out boss, out member, out tool);
            if (heldCard.tag.Equals("Boss"))
            {
                if (boss.Count < 1)
                {
                    heldCardControl.currentStack.Remove(heldCard);
                    heldCardControl.currentStack = targetCardControl.currentStack;
                    heldCardControl.currentStack.Add(heldCard);
                }
            }
            if (heldCard.tag.Equals("Member"))
            {
                if (member.Count < 4)
                {
                    heldCardControl.currentStack.Remove(heldCard);
                    heldCardControl.currentStack = targetCardControl.currentStack;
                    heldCardControl.currentStack.Add(heldCard);
                }
            }
            if (heldCard.tag.Equals("Tool"))
            {
                if (tool.Count < 3)
                {
                    heldCardControl.currentStack.Remove(heldCard);
                    heldCardControl.currentStack = targetCardControl.currentStack;
                    heldCardControl.currentStack.Add(heldCard);
                }
            }
        }
        initHand();
        refreshStack(heldCardControl.currentStack);
        return(heldCardControl.currentStack);
    }
Esempio n. 21
0
 void AddPoints()
 {
     numPoints = 0;
     for (int i = this.transform.childCount - 2; i >= 0; i--)
     {
         CardControl c = transform.GetChild(i).GetComponent <CardControl>();
         numPoints += c.value;
     }
     totalPoints += numPoints * numSyllables;
 }
Esempio n. 22
0
        public async Task <ActionResult <CardControlDTO> > PostCardControl(CardControl cardControl)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            CardControlDTO returnCardinformation = await _cardControlsService.ProcessCustomerCard(_context, cardControl);

            return(CreatedAtAction(nameof(GetCardControl), new { id = cardControl.Id }, returnCardinformation));
        }
Esempio n. 23
0
 /*
  *  選択したカード以外を非選択状態にする。
  */
 private void resetSelected(CardControl selectedCard)
 {
     foreach (CardControl _card in cardList)
     {
         Debug.Log(selectedCard.isSelected);
         if (selectedCard != _card)
         {
             _card.isSelected = false;
         }
     }
 }
Esempio n. 24
0
 /// 暂无人出价,选择最后一个出价者
 private void chooseBidToPay()
 {
     if (CurBidPlayer != null)
     {
         CurBidPlayer.PayFlipCard();
     }
     CurBidPlayer = null;
     curFlipCard  = null;
     roundComplete();
     nextRound();
 }
Esempio n. 25
0
 //enable the cards in the hand to be draggable.
 public void UnlockHand()
 {
     foreach (Transform child in transform)
     {
         CardControl cac = child.GetComponent <CardControl>();
         if (cac != null)
         {
             cac.isLock = false;
         }
     }
 }
Esempio n. 26
0
        private CardControlDTO ReturnCardInformation(CardControl cardControl)
        {
            var lastFourDigitsArray   = _operationsService.GetLastFourDigitsFromCard(cardControl.Cardnumber);
            var returnCardinformation = new CardControlDTO
            {
                Id = cardControl.Id,
                RegistrationDate = cardControl.RegistrationDate,
                Token            = _tokenService.GenerateToken(lastFourDigitsArray, cardControl.CVV)
            };

            return(returnCardinformation);
        }
    private void Start()
    {
        cardStack      = Resources.LoadAll("ani/deal");
        cardStackImage = transform.Find("CardStack").GetComponent <Image>();
        panle          = transform.Find("Panle").gameObject;
        cc             = GetComponent <CardControl>();

        left  = transform.Find("Left");
        top   = transform.Find("Up");
        right = transform.Find("Right");
        down  = transform.Find("Down");
    }
Esempio n. 28
0
    void SetCardControlLayout(CardControl ctl, int atIndex)
    {
        ctl.Width  = CardWidth;
        ctl.Height = CardHeight;
        //calc visible column count
        int columnCount = Width / CardWidth;
        //calc the x index and y index.
        int xPos = (atIndex % columnCount) * CardWidth;
        int yPos = (atIndex / columnCount) * CardHeight;

        ctl.Location = new Point(xPos, yPos);
    }
Esempio n. 29
0
        public ToneAnimation(CardControl control) : base(control)
        {
            m_saturateTrack = new Animation.LinearTrack(0.5f);
            m_saturateTrack.Elapsed += w => Control.Saturate = w;
            m_saturateTrack.PlayFrom(m_saturateTrack.Duration);
            m_saturateTrack.Stop();

            m_brightnessTrack = new Animation.LinearTrack(0.5f);
            m_brightnessTrack.Elapsed += w => Control.Brightness = w * 0.5f + 0.5f;
            m_brightnessTrack.PlayFrom(m_brightnessTrack.Duration);
            m_brightnessTrack.Stop();
        }
Esempio n. 30
0
 //disable the cards in the hands to be drag
 public void LockHand()
 {
     Debug.Log(gameObject.name);
     foreach (Transform child in transform)
     {
         CardControl cac = child.GetComponent <CardControl>();
         if (cac != null)
         {
             cac.isLock = true;
         }
     }
 }
Esempio n. 31
0
 /// 竞价阶段选择自己的金币牌出售
 private void onSelectSelfCard(CardControl card)
 {
     if (curRoundPlayer == PlayerManager.Instance.PlayerSelf)
     {
         return;
     }
     if (sendCardControl.GetCardPlayer(card.cardData.UUID) != PlayerManager.Instance.PlayerSelf)
     {
         return;
     }
     card.Select();
 }
Esempio n. 32
0
    IEnumerator OpenAnimationCoroutine(CardControl view)
    {
        var position = transform.position;

        position.z -= 2f;
        view.transform.position = position;

        for (int i = 0; i < 20; i++)
        {
            view.transform.position = new Vector3(view.transform.position.x, view.transform.position.y, view.transform.position.z - 0.5f);
            yield return(null);
        }
    }
Esempio n. 33
0
        public Highlight(CardControl control) : base(control)
        {
            Control.Style.RegisterBinding(this);

            m_quadHighlight = new Graphics.TexturedQuad(GameApp.Service<Resources>().CardHighlight);
            m_quadHighlight.BlendState = new BlendState { ColorSourceBlend = Blend.SourceAlpha, ColorDestinationBlend = Blend.One };

            m_borderBlinkTrack = new Animation.CurveTrack(GameApp.Service<Resources>().CardFloat);
            m_borderBlinkTrack.Loop = true;
            m_borderBlinkTrack.Play();

            m_enlargeTrack = new Animation.CurveTrack(GameApp.Service<Resources>().CardEnlarge);
        }
Esempio n. 34
0
    /// 创建卡牌
    public Card CreateCard(string name, int value, Type dataType, int id, CardTypeEnum typeEnum)
    {
        Card card = new Card(name, value);

        card.SetDataFrom(dataType, id);
        card.SetCardType(typeEnum);

        CardControl cc = new CardControl();

        cc.Init(card);
        cardUUId2Control.Add(card.UUID, cc);
        return(card);
    }
Esempio n. 35
0
        public void WhenProcessCustomerCard_New_ReturnCardControlDTO()
        {
            //arrange
            CardControl cardControlNew = new CardControl {
                CustomerId = 3, Cardnumber = 103456789015, CVV = 789
            };

            //act
            var cardDTO = cardControlsService.ProcessCustomerCard(dbContextMock.Object, cardControlNew);

            //assert
            Assert.That(cardDTO.Result.Token, Is.EqualTo(5901));
        }
Esempio n. 36
0
		public RotationAnimation(CardControl control) : base(control)
		{
			Control.Style.RegisterBinding(this);

			m_rotationTrack = new Animation.CurveTrack(GameApp.Service<Services.ResourceManager>().Acquire<Curve>("Curves/CardSelected"));
			m_rotationTrack.Elapsed += w =>
			{
				w = m_lastRotated ? w : 1 - w;
				var halfWidth = Control.Region.Width * 0.5f;
				var halfHeight = Control.Region.Height * 0.5f;
				m_rotationTransform = MatrixHelper.Translate(-halfWidth, -halfHeight)
									* MatrixHelper.RotateZ(MathUtils.PI * 0.5f * w)
									* MatrixHelper.Translate(halfWidth, halfHeight);
			};
		}
Esempio n. 37
0
 public void LinkToCard(CardControl cardCtrl)
 {
     _toCard = cardCtrl;
     UpdateToPoint(this, EventArgs.Empty);
     cardCtrl.rotate90.Changed += UpdateToPoint;
     var adornedCard = (CardControl) AdornedElement;
     DependencyPropertyDescriptor leftDescriptor = DependencyPropertyDescriptor.FromProperty(
         Canvas.LeftProperty, typeof (Canvas));
     DependencyPropertyDescriptor topDescriptor = DependencyPropertyDescriptor.FromProperty(Canvas.TopProperty,
                                                                                            typeof (Canvas));
     leftDescriptor.AddValueChanged(VisualTreeHelper.GetParent(cardCtrl), UpdateToPoint);
     topDescriptor.AddValueChanged(VisualTreeHelper.GetParent(cardCtrl), UpdateToPoint);
     leftDescriptor.AddValueChanged(VisualTreeHelper.GetParent(adornedCard), UpdateToPoint);
     topDescriptor.AddValueChanged(VisualTreeHelper.GetParent(adornedCard), UpdateToPoint);
     cardCtrl.Unloaded += RemoveFromLayer;
 }
        public SelectorLocationAnimation(CardControl control, IWindow window)
            : base(control)
        {
            if (window == null)
            {
                throw new ArgumentNullException("locationResolver");
            }

            m_window = window;

            m_locationTrack = new Animation.CurveTrack(GameApp.Service<Services.ResourceManager>().Acquire<Curve>("Curves/CardMove"));
            m_locationTrack.Elapsed += w =>
            {
                m_locationTransform = Matrix.Lerp(m_locationSrcTransform, m_locationDstTransform, w);
            };

            Control.Style.RegisterBinding(this);
        }
Esempio n. 39
0
        public SelectorHighlight(CardControl control, IControlUI ui)
            : base(control)
        {
            m_ui = ui;

            m_quadHighlight = new Graphics.TexturedQuad(GameApp.Service<Highlight.Resources>().CardHighlight);
            m_quadHighlight.BlendState = new BlendState
            {
                ColorSourceBlend = Blend.SourceAlpha,
                ColorDestinationBlend = Blend.One,
                AlphaBlendFunction = BlendFunction.Max,
                AlphaSourceBlend = Blend.One,
                AlphaDestinationBlend = Blend.One
            };

            m_borderBlinkTrack = new Animation.CurveTrack(GameApp.Service<Highlight.Resources>().CardFloat);
            m_borderBlinkTrack.Loop = true;
            m_borderBlinkTrack.Play();
        }
Esempio n. 40
0
        public SpellButtons(CardControl control) : base(control)
        {
            // TODO: spell button shall be stylized from cardcontrol's style
            const int IntervalV = 10;

            m_buttonFaceTexture = GameApp.Service<Services.ResourceManager>().Acquire<Graphics.VirtualTexture>("atlas:Textures/UI/InGame/Atlas0$Button");
            var buttonFace = new Graphics.TexturedQuad(m_buttonFaceTexture);
            var font = new Graphics.TextRenderer.FontDescriptor("Segoe UI", 16);

            int y = 0;
            foreach (var spell in Card.Spells)
            {
                y -= m_buttonFaceTexture.Height + IntervalV;

                var btn = new Button
                {
                    NormalFace = buttonFace,
                    ButtonText = GameApp.Service<Graphics.TextRenderer>().FormatText(spell.Model.Name, new Graphics.TextRenderer.FormatOptions(font))
                };
                btn.Transform = MatrixHelper.Translate(-m_buttonFaceTexture.Width / 2, y);
                btn.MouseButton1Up += new EventHandler<MouseEventArgs>(SpellButton_MouseButton1Up);
                btn.Dispatcher = m_spellButtonContainer;
                m_spellButtons.Add(btn);
            }
 
            m_fadeInOutTrack.Elapsed += w =>
            {
                foreach (var button in Buttons)
                {
                    var clr = new Color(1.0f, 1.0f, 1.0f, w);
                    button.NormalFace.ColorToModulate = clr;
                    button.TextColor = clr;
                }
                if (w == 0.0f)
                {
                    m_spellButtonContainer.Dispatcher = null;
                }
            };
        }
Esempio n. 41
0
 public DamageIndicator(CardControl control) : base(control)
 {
 }
Esempio n. 42
0
        private void DrawDecks()
        {
            controlCanvas.Children.Clear();
              if (CurrentPlayer == null || Deck == null || !GameStarted)
            return;

              List<CardControl> stackedCards = new List<CardControl>();
              for (int i = 0; i < Deck.CardsInDeck; i++)
            stackedCards.Add(new CardControl(Deck.GetCard(i))
            {
              Margin =
            new Thickness(150 + (i * 1.25), 25 - (i * 1.25), 0, 0),
              IsFaceUp = false
            });

              if (stackedCards.Count > 0)
            stackedCards.Last().MouseDoubleClick += Deck_MouseDoubleClick;
              if (AvailableCard != null)
              {
            var availableCard = new CardControl(AvailableCard)
            {
              Margin =
            new Thickness(0, 25, 0, 0)
            };
            availableCard.MouseDoubleClick += AvailalbleCard_MouseDoubleClick;
            controlCanvas.Children.Add(availableCard);
              }
              stackedCards.ForEach(x => controlCanvas.Children.Add(x));
        }
 private void RecycleCardControl(CardControl cardControl)
 {
     cardControl.Dispatcher = null;
     cardControl.SetCardDesign(null);
     m_cardControlPool.Add(cardControl);
 }
Esempio n. 44
0
        //fix MAINWINDOW bug
        public CardDragAdorner(CardControl anchor, CardControl sourceCard, Vector mousePoint)
            : base(Program.PlayWindow.Content as UIElement)
        {
            SourceCard = sourceCard;
            bool isCardInverted = anchor.IsOnTableCanvas && (Player.LocalPlayer.InvertedTable ^ anchor.IsInverted);
            Point cardOrigin;
            if (isCardInverted)
            {
                CardDef cardDef = Program.Game.Definition.CardDefinition;
                cardOrigin = new Point(cardDef.Width, cardDef.Height);
                _mouseOffset = new Vector(cardDef.Width - mousePoint.X, cardDef.Height - mousePoint.Y);
            }
            else
            {
                cardOrigin = new Point();
                _mouseOffset = mousePoint;
            }
            //fix MAINWINDOW bug
            _basePt = anchor.TranslatePoint(cardOrigin, Program.PlayWindow.Content as UIElement);

            _faceUp = sourceCard.IsAlwaysUp || sourceCard.Card.FaceUp;
            _lightRedBrush = Brushes.Red.Clone();
            _faceDownBrush = new ImageBrush(sourceCard.Card.GetBitmapImage(false));
            _faceUpBrush = _faceUp
                               ? new VisualBrush(sourceCard.GetCardVisual())
                                     {
                                         Viewbox = new Rect(0, 0, sourceCard.ActualWidth, sourceCard.ActualHeight),
                                         ViewboxUnits = BrushMappingMode.Absolute
                                     }
                               : (Brush)
                                 new ImageBrush(new BitmapImage(new Uri(Program.Game.Definition.CardDefinition.Front)));
            _invertTransform = new ScaleTransform {CenterX = 0.5, CenterY = 0.5};
            _faceUpBrush.RelativeTransform = _invertTransform;
            if (_faceUpBrush is VisualBrush)
                RenderOptions.SetCachingHint(_faceUpBrush, CachingHint.Cache);

            _child.BeginInit();
            _child.Width = anchor.ActualWidth*CardControl.ScaleFactor.Width;
            _child.Height = anchor.ActualHeight*CardControl.ScaleFactor.Height;
            _child.Fill = _faceUp ? _faceUpBrush : _faceDownBrush;
            _child.StrokeThickness = 3;

            var transforms = new TransformGroup();
            _child.RenderTransform = transforms;
            _rot = sourceCard.Card.Orientation;
            if ((_rot & CardOrientation.Rot180) != 0)
            {
                _rot180Transform = new RotateTransform(180, _child.Width/2, _child.Height/2);
                transforms.Children.Add(_rot180Transform);
            }
            if ((_rot & CardOrientation.Rot90) != 0)
            {
                _rot90Transform = isCardInverted
                                      ? new RotateTransform(90, _child.Width/2, _child.Width/2)
                                      : new RotateTransform(90, _child.Width/2, _child.Height - _child.Width/2);
                transforms.Children.Add(_rot90Transform);
            }
            _translate = new TranslateTransform();
            transforms.Children.Add(_translate);

            _child.IsHitTestVisible = false;
            _child.EndInit();
            AddVisualChild(_child);

            var animation = new DoubleAnimation(0.55, 0.75, new Duration(TimeSpan.FromMilliseconds(500)))
                                {AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever};
            animation.Freeze();

            _faceUpBrush.BeginAnimation(Brush.OpacityProperty, animation);
            _faceDownBrush.BeginAnimation(Brush.OpacityProperty, animation);
            _lightRedBrush.BeginAnimation(Brush.OpacityProperty, animation);
        }
Esempio n. 45
0
        private void DrawDecks()
        {
            controlCanvas.Children.Clear();

              if (CurrentPlayer == null || Deck == null | !GameStarted)
            return;

              List<CardControl> stackedCards = new List<CardControl>();
              for (int i = 0; i < Deck.CardsInDeck; i++)
            stackedCards.Add(new CardControl(Deck.GetCard(i)) { Margin = new Thickness(150 + (i * 1.25), 25 - (i * 1.25), 0, 0), IsFaceUp = false });

              if (stackedCards.Count > 0)
            stackedCards.Last().Tapped += GameDecksControl_Tapped;
              if (AvailableCard != null)
              {
            var availableCard = new CardControl(AvailableCard) { Margin = new Thickness(0, 25, 0, 0) };
            availableCard.Tapped += availableCard_Tapped;
            controlCanvas.Children.Add(availableCard);
              }
              foreach (var card in stackedCards)
            controlCanvas.Children.Add(card);
        }
Esempio n. 46
0
 public Pile(CardControl control, Func<int> pileHeight)
     : base(control)
 {
     Control.Style.RegisterBinding(this);
     m_pileHeight = pileHeight;
 }
        private void DrawDecks()
        {
            if ((AvailableCard == null || AvailableCard.Count == 0) && (CurrentPlayer != null&&CurrentPlayer.Index != AvailableCardPlayer))   ////no change, no flush; clear when same user
                return;
            Console.WriteLine("Pass");
            controlCanvas.Children.Clear();
            if (CurrentPlayer == null || Deck == null || !GameStarted)
                return;

            List<CardControl> stackedCards = new List<CardControl>();//Deck.CardsInDeck
            for (int i = 0; i < Deck.CardsInDeck; i++)
                stackedCards.Add(new CardControl(Deck.GetCard(i))
                {
                    Margin =
                      new Thickness(150 + (i * 1.25), 25 - (i * 1.25), 0, 0),
                    IsFaceUp = false
                });

            if (stackedCards.Count > 0)
                stackedCards.Last().MouseDoubleClick += Deck_MouseDoubleClick;
            if (AvailableCard != null)
            {
                for (var i = 0; i < AvailableCard.Count; i++)
                {
                    var cardControl = new CardControl(AvailableCard[i]);
                    cardControl.Margin = new Thickness(i * 35, 35, 0, 0);
                    controlCanvas.Children.Add(cardControl);
                }
            }
            stackedCards.ForEach(x => controlCanvas.Children.Add(x));
        }
Esempio n. 48
0
 public Glow(CardControl control) : base(control)
 {
     m_quadGlow = new Graphics.TexturedQuad(GameApp.Service<Resources>().CardGlow);
     m_quadGlow.BlendState = BlendState.AlphaBlend;
 }
        private CardControl TakeCardControl()
        {
            CardControl cc;
            if (m_cardControlPool.Count != 0)
            {
                cc = m_cardControlPool[m_cardControlPool.Count - 1];
                m_cardControlPool.RemoveAt(m_cardControlPool.Count - 1);
            }
            else
            {
                var cardStyle = GameApp.Service<Services.Styler>().GetCardStyle("Normal");
                var ccStyle = new Style.CardControlStyle(cardStyle, -1);
                ccStyle.Initialize();

                cc = ccStyle.TypedTarget;
                cc.Addins.Add(new CardControlAddins.SelectorLocationAnimation(cc, this));
                cc.Addins.Add(new CardControlAddins.SelectorHighlight(cc, this));
                cc.MouseTracked.MouseEnter += (s, e) =>
                {
                    m_mouseHoverControl = cc;
                };
                cc.MouseTracked.MouseLeave += (s, e) =>
                {
                    if (m_mouseHoverControl == cc)
                    {
                        m_mouseHoverControl = null;
                    }
                };
                cc.MouseTracked.MouseButton1Down += (s, e) =>
                {
                    Center = cc.GetAddin<CardControlAddins.SelectorLocationAnimation>().LocationIndex;
                };
            }

            return cc;
        }
 bool CardControlAddins.SelectorHighlight.IControlUI.IsCardSelected(CardControl cardControl)
 {
     return m_mouseHoverControl == null
            ? cardControl.GetAddin<CardControlAddins.SelectorLocationAnimation>().LocationIndex == Center
            : m_mouseHoverControl == cardControl;
 }
Esempio n. 51
0
    private void DrawCards()
    {
      bool isFaceup = (Owner.State != PlayerState.Inactive);

      if (Owner is ComputerPlayer)
        isFaceup = (Owner.State == CardLib.PlayerState.Loser || Owner.State == CardLib.PlayerState.Winner || Game == null ? true : Game.ComputerPlaysWithOpenHand);

      var cards = Owner.GetCards();
      if (cards == null || cards.Count == 0)
        return;

      for (var i = 0; i < cards.Count; i++)
      {
        var cardControl = new CardControl(cards[i]);
        if (PlayerOrientation == Orientation.Horizontal)
          cardControl.Margin = new Thickness(i * 35, 35, 0, 0);
        else
          cardControl.Margin = new Thickness(5, 35 + i * 30, 0, 0);
        cardControl.Tapped += cardControl_Tapped;
        cardControl.IsFaceUp = isFaceup;
        CardSurface.Children.Add(cardControl);
      }
    }
Esempio n. 52
0
 public CardDragAdorner(CardControl sourceCard, Vector mousePoint)
     : this(sourceCard, sourceCard, mousePoint)
 {
 }
Esempio n. 53
0
 public InstantRotation(CardControl control) : base(control)
 {
     Control.Style.RegisterBinding(this);
     m_transform = Matrix.Identity;
 }
        private void DrawCards()
        {
            bool isFaceup = true;//(Owner.State != PlayerState.Inactive);
            if (Owner is ComputerPlayer)
                isFaceup = (Owner.State == CardLib.PlayerState.Loser || Owner.State == CardLib.PlayerState.Winner);
            var cards = Owner.GetCards();
            var chosenCards = Owner.GetChosenCards();
            if (cards == null || cards.Count == 0)
                return;

            for (var i = 0; i < cards.Count; i++)
            {
                var cardControl = new CardControl(cards[i]);
                if (PlayerOrientation == Orientation.Horizontal)
                {
                    if (chosenCards.Contains(cardControl.Card))
                        cardControl.Margin = new Thickness(i * 35, 25, 0, 0);
                    else
                        cardControl.Margin = new Thickness(i * 35, 35, 0, 0);
                }
                else
                {
                    if (chosenCards.Contains(cardControl.Card))
                        cardControl.Margin = new Thickness(10, 35 + i * 30, 0, 0);
                    else
                        cardControl.Margin = new Thickness(5, 35 + i * 30, 0, 0);
                }
                //cardControl.MouseDoubleClick += cardControl_MouseDoubleClick;
                cardControl.MouseLeftButtonDown += cardControl_Click;
                cardControl.IsFaceUp = isFaceup;
                CardSurface.Children.Add(cardControl);
            }
        }