private void PlayerBuyCard() { SoundEngine.Instance.PlaySoundEffect("coin", 0.4f); // Create card animation from hand zone to play zone uint totalFrame = 40; Vector2 position = new Vector2(this.game.DISCARD_POSITION.X + 3, this.game.DISCARD_POSITION.Y + 3); CardAnimation anim = new CardAnimation(this.CardList[mouse_hover_index], this.getHandCardPosition(mouse_hover_index), position, totalFrame, 1.0f, 1.0f, this.cardRotation, this.cardRotation, true, Color.Black, "cardPlace1"); this.game.AnimationList.Add(anim); anim.RegisterCallback(MainPlayerBuyCard, this.CardList[mouse_hover_index]); this.game.AnimationList.Add(anim); // Restock card CardList[mouse_hover_index] = this.game.RandomlyGenerateCard(); }
//ButtonUI resourceButton; public CardSelectedOverlay( GameInstance game, Card card, Vector2 originCardPosition, Vector2 goalCardPosition, float originCardRotation = 0.0f, float goalCardRotation = 0.0f) : base(game) { this.card = card; this.flyInAnimation = new CardAnimation(card, originCardPosition, goalCardPosition, 10, 1.0f, 5.0f, originCardRotation, goalCardRotation, false); this.flyOutAnimation = new CardAnimation(card, goalCardPosition, originCardPosition, 10, 5.0f, 1.0f, goalCardRotation, originCardRotation, true); this.goalCardPosition = goalCardPosition; this.viewPort = new Rectangle(game.GraphicsDevice.PresentationParameters.Bounds.Width / 2, game.GraphicsDevice.PresentationParameters.Bounds.Height/2, game.GraphicsDevice.PresentationParameters.Bounds.Width, game.GraphicsDevice.PresentationParameters.Bounds.Height); this.playButton = new ButtonUI(game, new Rectangle(550, 420, 300, 100), 1, "Play!"); //this.resourceButton = new ButtonUI(game, new Rectangle(400, 400, 205, 50), 3, "Resource"); }
public override void Update() { base.Update(); // Right mouse click: Show CardSelectedOverlay if (mouse_hover_index != -1 && mouse_hover_index < this.cardDisplaySize) { // Left mouse click: Play card if (game.controller.isLeftMouseButtonClicked()) { if (this.mainPlayer.ActionPoint > 0) { CardAnimation anim; uint totalFrame = 20; // Create card animation from hand zone to play zone int playZoneIndex = Math.Min(this.game.PlayZone.CardList.Count, 4); anim = new CardAnimation(this.mainPlayer.Hand[mouse_hover_index], this.getHandCardPosition(mouse_hover_index), this.game.PlayZone.getHandCardPosition(playZoneIndex), totalFrame, 1.0f, 1.0f, GameInstance.CARD_ROTATION, GameInstance.CARD_ROTATION, true, Color.Black, "cardSlide3"); anim.RegisterCallback(this.game.PlayZone.IncrementDisplaySize); this.game.AnimationList.Add(anim); // Play Card this.mainPlayer.PlayCard(this.mainPlayer.Hand[mouse_hover_index]); } else { SoundEngine.Instance.PlaySoundEffect("error"); } } } }