Esempio n. 1
0
        public void CardsButton(object btn)
        {
            ForceEndScene    = true;
            Global.NextScene = "TestmmGame.CardScene";
            Scene otherScene = new CardScene();

            mmGame.Scene = otherScene;
        }
Esempio n. 2
0
        public void Execute()
        {
            var tmpScene = (Scene)Global.CurrentScene;

            if (tmpScene.GetType().Name != "CardScene")
            {
                return;
            }

            MyScene = (CardScene)tmpScene;
            var entities = Context <Default> .AllOf <DragComponent>().GetEntities();

            foreach (var entity in entities)
            {
                //
                // We have a DragDisp entity (holds all cards entities)
                //
                CardPileComponent sc = entity.GetComponent <CardPileComponent>();
                if (sc != null)
                {
                    if (sc.CardsInPile.Count <= 0)
                    {
                        return;                         //no cards to drag
                    }
                }

                var _mouseCollider = entity.GetComponent <BoxCollider>();
                PrevMouse    = CurrentMouse;
                CurrentMouse = Global.GetMousePosition();
                //
                // Current location of the mouse used for the hand icon
                //
                entity.Get <Transform>().Position = CurrentMouse;

                Entity lastCardonStack = sc.CardsInPile.LastOrDefault();
                //
                // Display of stack by fan out direction
                //
                switch (sc.FannedDirection)
                {
                case 0:
                    fanOutDistannce = Vector2.Zero;
                    break;

                case 1:
                    fanOutDistannce = new Vector2(30f, 0);
                    break;

                case 2:
                    fanOutDistannce = new Vector2(-30f, 0);
                    break;

                case 3:
                    fanOutDistannce = new Vector2(0, -30f);
                    break;

                case 4:
                    fanOutDistannce = new Vector2(0, 30f);
                    break;
                }
                //
                // All cards are Entities in this stack
                //
                int ind = 0;                            //cars number in stack
                for (int i = 0; i < sc.CardsInPile.Count; i++)
                {
                    Entity cardEntity = sc.CardsInPile[i];
                    cardEntity.Get <Transform>().Enabled  = true;
                    cardEntity.Get <Transform>().Position = entity.Get <Transform>().Position + fanOutDistannce * ind;
                    //
                    // Get the sprite (face/back)
                    //
                    //cardEntity.GetComponent<Card>().RenderLayer = (ind * 1000);
                    //cardEntity.GetComponent<Card>().RenderLayer = Global.CURSOR_LAYER - ind;
                    cardEntity.GetComponent <Card>().RenderLayer = Global.CURSOR_LAYER - ind;
                    ind += 1;
                }
            }
        }
Esempio n. 3
0
        public void Execute()
        {
            var tmpScene = (Scene)Global.CurrentScene;

            if (tmpScene.GetType().Name != "CardScene")
            {
                return;
            }

            MyScene = (CardScene)tmpScene;
            var entities = Context <Default> .AllOf <MouseComponent>().GetEntities();

            foreach (var mouseEntity in entities)
            {
                mouseEntity.Get <Transform>().Position = Global.GetMousePosition();
                clickTimer += Global.DeltaTime * 1000;
                //if (Raylib.IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
                //{
                //    if (clickTimer < timerDelay)
                //    {
                //        CheckCollisionResults(mouseEntity);
                //        clickTimer = 0;
                //    }
                //}
                if (Raylib.IsMouseButtonReleased(MouseButton.MOUSE_LEFT_BUTTON))
                {
                    if (clickTimer < timerDelay)
                    {
                        clickTimer = 0;             //double click detected
                    }
                    clickTimer = 0;
                    if (Dragging)
                    {
                        Dragging = false;

                        CollisionResult cr;
                        if (!SceneColliderDatabase.CollidedWithBox(mouseEntity, out cr))
                        {
                            return;
                        }

                        Entity collidedEntity = cr.CompEntity;
                        //
                        // Dealt Card is released but was not put on a stack
                        //
                        if (collidedEntity.Tag == 80)
                        {
                            //
                            // Ace pile drop
                            //
                            MyScene.DropCardFromDrag2AceStack(collidedEntity);
                            return;                     //ace pile stack
                        }
                        if ((collidedEntity.Tag >= 1) && (collidedEntity.Tag <= 7))
                        {
                            //
                            // Play pile drop
                            //
                            MyScene.DropCardFromDrag2PlayStack(collidedEntity);
                            return;
                        }
                        //
                        // mouse released but not on Ace or Play area, return card to its place
                        //
                        MyScene.ReturnCardFromDrag2Stack();
                        return;                     //drap disp stack (release of mouse outside of play area)
                    }
                }
                if (Raylib.IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
                {
                    //
                    // if game over, don't allow movement
                    //
                    if (Global.StateOfGame == GameState.Over)
                    {
                        return;
                    }

                    CheckCollisionResults(mouseEntity);
                }
            }
        }