Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void OnMouseFocused(ALayer2D parentLayer, ControlEventType eventType)
        {
            StarEntity starEntity = parentLayer.GetEntityFromEntity2D(this) as StarEntity;

            if (starEntity.CardSocketed != null)
            {
                parentLayer.SendEventToWorld(Model.Event.EventType.FOCUS_CARD_BOARD, starEntity.CardSocketed, null);
            }
        }
Ejemplo n.º 3
0
        public void OnMouseFocused(ALayer2D parentLayer, ControlEventType eventType)
        {
            CJStarDomain domainEntity = parentLayer.GetEntityFromEntity2D(this) as CJStarDomain;

            if (domainEntity != null)
            {
                parentLayer.SendEventToWorld(Model.Event.EventType.FOCUS_DOMAIN_BOARD, domainEntity, null);
            }
        }
Ejemplo n.º 4
0
        public void OnMouseFocused(ALayer2D parentLayer, ControlEventType eventType)
        {
            parentLayer.SendEventToWorld(Model.Event.EventType.FOCUS_CARD_HAND, parentLayer.GetEntityFromEntity2D(this), null);

            Layer2D.BoardPlayerLayer2D.BoardPlayerLayer2D boardPlayerLayer2D = parentLayer as Layer2D.BoardPlayerLayer2D.BoardPlayerLayer2D;
            if (boardPlayerLayer2D == null || boardPlayerLayer2D.SourceCardEntities2D == null || boardPlayerLayer2D.SourceCardEntities2D.Count == 0)
            {
                this.IsFocused = true;
            }
        }
Ejemplo n.º 5
0
        public bool OnMouseReleased(ALayer2D parentLayer, ControlEventType eventType)
        {
            if (parentLayer.FocusedGraphicEntity2D == this)
            {
                Layer2D.BoardPlayerLayer2D.BoardPlayerLayer2D boardPlayerLayer2D = parentLayer as Layer2D.BoardPlayerLayer2D.BoardPlayerLayer2D;
                if (boardPlayerLayer2D != null && boardPlayerLayer2D.LevelTurnPhase == Model.Node.TestWorld.TurnPhase.MAIN)
                {
                    Vector2i mousePosition = parentLayer.MousePosition;

                    mousePosition.Y -= (int)(this.Bounds.Height / 2);
                    if (eventType == ControlEventType.MOUSE_LEFT_CLICK)
                    {
                        parentLayer.SendEventToWorld(Model.Event.EventType.PICK_CARD, parentLayer.GetEntityFromEntity2D(this), mousePosition.X + ":" + mousePosition.Y);
                    }
                }

                Layer2D.BoardNotifLayer2D.BoardNotifLayer2D boardNotifLayer2D = parentLayer as Layer2D.BoardNotifLayer2D.BoardNotifLayer2D;
                if (boardNotifLayer2D != null && boardNotifLayer2D.LevelTurnPhase == Model.Node.TestWorld.TurnPhase.MAIN)
                {
                    Vector2i mousePosition = parentLayer.MousePosition;

                    mousePosition.Y -= (int)(this.Bounds.Height / 2);
                    if (eventType == ControlEventType.MOUSE_LEFT_CLICK)
                    {
                        parentLayer.SendEventToWorld(Model.Event.EventType.PICK_CARD, parentLayer.GetEntityFromEntity2D(this), mousePosition.X + ":" + mousePosition.Y);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 6
0
        private void UpdateFocusedEntity(Time deltaTime)
        {
            ICardFocusedLayer firstCardLayerFocused = this.cardFocusedLayers.FirstOrDefault(pElem => pElem.CardFocused != null);
            ALayer2D          layer2D = firstCardLayerFocused as ALayer2D;

            if (firstCardLayerFocused != null)
            {
                CardEntity2D cardFocused = firstCardLayerFocused.CardFocused;
                if (this.cardFocused != cardFocused)
                {
                    CardEntity cardEntity = layer2D.GetEntityFromEntity2D(cardFocused) as CardEntity;

                    this.cardToolTip.DisplayToolTip(cardEntity.Card, cardFocused);

                    this.cardFocused = cardFocused;
                }

                if (this.cardToolTip.IsActive)
                {
                    Vector2f cardFocusedPosition = this.cardFocused.Position;

                    Vector2f cardPositionInWindow = layer2D.GetPositionInWindow(cardFocusedPosition);

                    if (cardPositionInWindow.Y > this.defaultViewSize.Y / 2)
                    {
                        cardFocusedPosition.Y -= this.cardFocused.Canevas.Height / 2;

                        cardFocusedPosition = this.GetPositionInScene(layer2D.GetPositionInWindow(cardFocusedPosition));

                        cardFocusedPosition.X -= this.cardToolTip.Canevas.Width / 2;
                        cardFocusedPosition.Y -= this.cardToolTip.Canevas.Height;
                    }
                    else
                    {
                        cardFocusedPosition.Y += this.cardFocused.Canevas.Height / 2;

                        cardFocusedPosition = this.GetPositionInScene(layer2D.GetPositionInWindow(cardFocusedPosition));

                        cardFocusedPosition.X -= this.cardToolTip.Canevas.Width / 2;
                    }

                    this.cardToolTip.Position = cardFocusedPosition;
                }
            }
            else
            {
                this.cardToolTip.HideToolTip();

                this.cardFocused = null;
            }

            if (this.domainToolTip.IsActive)
            {
                Vector2f mousePositionInWindow = this.domainLayerFocused.GetPositionInWindow(new Vector2f(this.domainLayerFocused.MousePosition.X, this.domainLayerFocused.MousePosition.Y));
                Vector2f domainTooltipPosition = this.GetPositionInScene(mousePositionInWindow);

                if (mousePositionInWindow.Y > this.defaultViewSize.Y / 2)
                {
                    domainTooltipPosition.Y -= this.domainToolTip.Canevas.Height;
                }
                //domainTooltipPosition.X -= this.domainToolTip.Canevas.Width / 2;

                this.domainToolTip.Position = domainTooltipPosition;

                this.domainToolTip.UpdateGraphics(deltaTime);
            }
        }