public bool OnMouseClicked(ALayer2D parentLayer, ControlEventType eventType) { if (parentLayer is BoardGameLayer2D) { if (parentLayer.FocusedGraphicEntity2D == this) { if (eventType == ControlEventType.MOUSE_LEFT_CLICK) { BoardGameLayer2D boardGameLayer2D = (parentLayer as BoardGameLayer2D); if (boardGameLayer2D.CardPicked != null) { StarEntity starEntity = parentLayer.GetEntityFromEntity2D(this) as StarEntity; CardEntity cardEntity = parentLayer.GetEntityFromEntity2D(boardGameLayer2D.CardPicked) as CardEntity; if (starEntity.CanSocketCard(cardEntity)) { boardGameLayer2D.SendEventToWorld(Model.Event.EventType.SOCKET_CARD, starEntity, null); } } else if (boardGameLayer2D.SourceCardEntities2D != null && boardGameLayer2D.SourceCardEntities2D.Count > 0) { StarEntity starEntity = parentLayer.GetEntityFromEntity2D(this) as StarEntity; boardGameLayer2D.SendEventToWorld(Model.Event.EventType.PICK_CARD, starEntity.CardSocketed, null); } } } } return(true); }
private void UpdateCardInteraction() { if (this.CardPicked != null) { Vector2i mousePosition = this.MousePosition; Vector2f cardPosition = new Vector2f(mousePosition.X, mousePosition.Y); CardEntity cardEntity = this.object2DToObjects[this.CardPicked] as CardEntity; if (this.focusedGraphicEntity2D is StarEntity2D) { StarEntity2D starEntity2D = this.focusedGraphicEntity2D as StarEntity2D; StarEntity starEntity = this.object2DToObjects[starEntity2D] as StarEntity; if (starEntity.CanSocketCard(cardEntity)) { cardPosition = new Vector2f(starEntity2D.Position.X, starEntity2D.Position.Y); } } this.CardPicked.Position = cardPosition; } }