Exemplo n.º 1
0
        private void handleInput()
        {
            // Appui sur espace : ACTION
            var key = Application.InputManager.GetDevice<KeyboardDevice>(SuperCaissiere.Engine.Input.LogicalPlayerIndex.One);

            if (m_scanning && !m_barCodeQte.isActive() && (key.GetState(SuperCaissiere.Engine.Input.MappingButtons.B).IsPressed || key.GetState(SuperCaissiere.Engine.Input.MappingButtons.X).IsPressed))
            {
                m_manualMode = true;
                m_barCodeQte.start();
            }

            if (m_currentClient.Items.Count == 0) //okay on a passé tous les articles
            {
                if (m_textbox == null)
                {
                    if (key.GetState(SuperCaissiere.Engine.Input.MappingButtons.A).IsPressed)
                    {
                        switch (m_diagFSM)
                        {
                            case 0: m_textbox = new TextBox("Sa fera " + m_price + "Euro s'il vous plé", true);
                                Timer.Create(0.02f, true, (t =>
                                {
                                    m_currentClient.Location -= new Vector2(5, 0);
                                    if (m_currentClient.Location.X < 100) t.Stop();
                                }));
                                break;
                            case 1:
                                Application.MagicContentManager.GetSound("fidelite1", "fidelite2", "fidelite3").Play();
                                m_textbox = new TextBox("Vous avez la carte du magazin?", true);
                                break;
                            case 2:
                                Application.MagicContentManager.GetSound("bonne-journee", "aurevoir1", "aurevoir2", "aurevoir3").Play();
                                m_textbox = new TextBox("Ayez une bonne journée", true);
                                break;
                            case 3:
                                m_textbox = new TextBox("Au revoir et a bientot", true);
                                break;
                        }
                        m_diagFSM++;
                    }
                    if (m_diagFSM == 4)
                    {
                        m_diagFSM++;
                        Timer.Create(0.02f, true, (t =>
                        {
                            if (m_currentClient == null) t.Stop();
                            m_currentClient.Location -= new Vector2(5, 0);
                            if (m_currentClient.Location.X < -100)
                            {
                                t.Stop();
                                m_currentClient = null;
                            }
                        }));
                    }
                }

            }
            if (m_scanning)
            {
                //ici on fait tourner les serviettes :3
                m_render.resetRotate();
                if (key.ThumbStickLeft.Y < 0) m_render.rotateX(-0.05f); //up
                if (key.ThumbStickLeft.Y > 0) m_render.rotateX(0.05f); //down
                if (key.ThumbStickLeft.X < 0) m_render.rotateY(-0.05f); //left
                if (key.ThumbStickLeft.X > 0) m_render.rotateY(0.05f);  //right
            }

            if (m_textbox == null && m_scanning) //Malus
                if (key.GetState(SuperCaissiere.Engine.Input.MappingButtons.A).IsPressed)
                {
                    m_hp -= 5;

                    shakeShakeShake();
                }

            // Possible uniquement si on ne fait rien d'autre
            if (key.GetState(SuperCaissiere.Engine.Input.MappingButtons.A).IsDown)
            {
                if (m_currentProduct == null)
                {

                    if (m_currentClient != null)
                    {
                        foreach (Product p in m_currentClient.Items)
                        {
                            p.Location += new Vector2(-2, 0);
                            if (p.Location.X < 450)
                            {
                                m_currentProduct = p;
                                Timer.Create(0.02F, true, (t =>
                                {
                                    m_currentProduct.Location += new Vector2(-5, 0);
                                    if (m_currentProduct.Location.X < 300)
                                    {
                                        t.Stop();
                                        m_render.setModel(m_currentProduct.getModel(), m_currentProduct.getCollider());
                                        m_render.isActive = true;
                                        m_manualMode = false;
                                        m_scanTime = 0;
                                        m_scanning = true;
                                        m_timerScan = 0;
                                    }
                                }));

                            }
                        }
                    }
                }

            }
            //brulage de retine des clients
            if (m_textbox == null && m_currentClient != null)
            {
                var mouse = Application.InputManager.GetDevice<MouseDevice>(SuperCaissiere.Engine.Input.LogicalPlayerIndex.One);
                if (mouse.GetState(SuperCaissiere.Engine.Input.MappingButtons.A).IsPressed)
                {

                    if (m_currentClient.whereIsMyMind().Intersects(new Rectangle((int)mouse.MouseLocation.X, (int)mouse.MouseLocation.Y, 1, 1)))
                    {
                        blinkScan();
                        m_textbox = new TextBox("ARGH ! MES ZYEU ! ! !\n ME MANIFIK ZIEUX ! ! !", false);
                        shakeShakeShake();
                        m_hp -= 5;
                    }
                }

            }
            // Clic sur la souris = SCAN
            if (m_scanning)
            {
                var mouse = Application.InputManager.GetDevice<MouseDevice>(SuperCaissiere.Engine.Input.LogicalPlayerIndex.One);
                bool validate = false;
                if (mouse.GetState(SuperCaissiere.Engine.Input.MappingButtons.A).IsPressed)
                {
                    //blinkScan();
                    if (m_render.isClicked((int)mouse.MouseLocation.X, (int)mouse.MouseLocation.Y))
                    {
                        m_scanTime++;
                        if (m_scanTime > 10)
                        {
                            m_textbox = new TextBox("Caisse centrale dit:\n Ce code bare semble être corrompu, presser \n'Ctrl' pour commuté au mode manuel", true);
                        }
                        if (!m_currentProduct.IsCorrupted) validate = true;
                    }
                }
                else if (m_manualMode && m_barCodeQte.isValidated)
                {
                    validate = true;
                }

                if (validate)
                {
                    Application.MagicContentManager.GetSound("bip1", "bip2").Play();

                    m_scanning = false;
                    displayRank(m_timerScan);
                    m_price += m_currentProduct.Price;
                    Timer.Create(0.02F, true, (t =>
                    {
                        // Déplacement du produit dans le panier final
                        m_currentProduct.Location += new Vector2(-5, 0);
                        if (m_currentProduct.Location.X < -100)
                        {
                            t.Stop();
                            m_basket.AddItem(m_currentProduct);
                            m_currentClient.Items.Dequeue();
                            m_currentProduct = null;
                            m_scanTime = 0;
                        }
                    }));
                    m_render.isActive = false;
                }
            }
        }