/// <summary>
        /// onSceneUpdate this function handles the logic for the state which should be run durring the update partion of the game.
        /// For example this could be to check for conditions to continue to the next state of the gameplay.
        /// </summary>
        public void onSceneUpdate()
        {
            if (fc.alphaValue <= 0)
            {
                List <IComponent> complist;
                //This is used for changin the currentState
                //SetUpPlayerScene stateTwo = new SetUpPlayerScene();

                //SceneSystem.Instance.setCurrentScene(stateTwo);

                string[] menuItems = { "Start Game", "Options", "About", "End Game" };

                MenuScene menu = new MenuScene(menuItems);
                SceneSystem.Instance.setCurrentScene(menu);

                foreach (int comp in entitiesInState)
                {
                    complist = ComponentManager.Instance.GetAllEntityComponents(comp);
                    foreach (IComponent a in complist)
                    {
                        if (a.GetType() == typeof(DrawableComponent))
                        {
                            DrawableComponent hej = (DrawableComponent)a;
                            hej.visible = false;
                        }
                        if (a.GetType() == typeof(DrawableTextComponent))
                        {
                            DrawableTextComponent hej = (DrawableTextComponent)a;
                            SceneSystem.Instance.clearScene(entitiesInState);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Creates an new Player with Controlls
        /// </summary>
        /// <param name="pixlePer"> True if pixelPerfect shall be used </param>
        /// <param name="GamePade"> True if GamePad the player uses a gamepad </param>
        /// <param name="PadJump"> Key binding to gamePad </param>
        /// <param name="Jump"> key binding to keybord </param>
        /// <param name="position"> Player start Position </param>
        /// <param name="name"> The name off the player</param>
        /// <param name="dir"> The players starting direction</param>
        /// <param name="index">  Playerindex For GamePad </param>
        /// <returns></returns>
        public int CreatePlayer(bool pixlePer, bool GamePade, Buttons PadJump, Keys Jump, Vector2 position, string name, Direction dir, PlayerIndex index, Color colour)
        {
            SpriteEffects     flip;
            GamePadComponent  gam;
            KeyBoardComponent kcb;
            int id = ComponentManager.Instance.CreateID();

            if (dir == Direction.Left)
            {
                flip = SpriteEffects.FlipHorizontally;
            }
            else
            {
                flip = SpriteEffects.None;
            }

            if (GamePade == true)
            {
                gam = new GamePadComponent(index);
                gam.gamepadActions.Add(ActionsEnum.Jump, PadJump);
                ComponentManager.Instance.AddComponentToEntity(id, gam);
            }
            else
            {
                kcb = new KeyBoardComponent();
                kcb.keyBoardActions.Add(ActionsEnum.Jump, Jump);
                ComponentManager.Instance.AddComponentToEntity(id, kcb);
            }
            DirectionComponent          dc   = new DirectionComponent(dir);
            DrawableComponent           comp = new DrawableComponent(Game.Instance.GetContent <Texture2D>("Pic/kanin1"), flip);
            PositionComponent           pos  = new PositionComponent(position);
            VelocityComponent           vel  = new VelocityComponent(new Vector2(200F, 0), 50F);
            JumpComponent               jump = new JumpComponent(300F, 200F);
            CollisionRectangleComponent CRC  = new CollisionRectangleComponent(new Rectangle((int)pos.position.X, (int)pos.position.Y, comp.texture.Width, comp.texture.Height));
            CollisionComponent          CC   = new CollisionComponent(pixlePer);
            PlayerComponent             pc   = new PlayerComponent(name);
            DrawableTextComponent       dtc  = new DrawableTextComponent(name, Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/TestFont"));
            HUDComponent    hudc             = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), new Vector2(pos.position.X, pos.position.Y));
            HUDComponent    hudc2            = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), Vector2.One);
            HealthComponent hc = new HealthComponent(3, false);

            //AnimationComponent ani = new AnimationComponent(100, 114, comp.texture.Width, comp.texture.Height, 0.2);

            comp.colour = colour;

            ComponentManager.Instance.AddComponentToEntity(id, vel);
            ComponentManager.Instance.AddComponentToEntity(id, comp);
            ComponentManager.Instance.AddComponentToEntity(id, pos);
            ComponentManager.Instance.AddComponentToEntity(id, CRC);
            ComponentManager.Instance.AddComponentToEntity(id, CC);
            ComponentManager.Instance.AddComponentToEntity(id, pc);
            ComponentManager.Instance.AddComponentToEntity(id, dtc);
            ComponentManager.Instance.AddComponentToEntity(id, hudc);
            ComponentManager.Instance.AddComponentToEntity(id, hc);
            //ComponentManager.Instance.AddComponentToEntity(id, ani);
            ComponentManager.Instance.AddComponentToEntity(id, dc);
            ComponentManager.Instance.AddComponentToEntity(id, jump);
            return(id);
        }
Esempio n. 3
0
        /// <summary>
        /// onSceneCreated this function is called whenever the current gamestate is changed. This function should contain logic that
        /// needs to be processed before the state is shown for the player. This could be enteties that's not able to be created pre-runtime.
        /// </summary>
        public void onSceneCreated()
        {
            DrawableTextComponent text1 = new DrawableTextComponent("Map:", Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/Menufont"));
            PositionComponent     pos1  = new PositionComponent(new Vector2(0, Game.Instance.GraphicsDevice.Viewport.Height - 80));
            int           id1           = ComponentManager.Instance.CreateID();
            FadeComponent fc2           = new FadeComponent(1, 3);

            ComponentManager.Instance.AddComponentToEntity(id1, text1);
            ComponentManager.Instance.AddComponentToEntity(id1, pos1);
            ComponentManager.Instance.AddComponentToEntity(id1, fc2);
            entitiesInState.Add(id1);

            draw = new DrawableTextComponent("Whiteboard", Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/Menufont"));
            PositionComponent pos2 = new PositionComponent(new Vector2(105, Game.Instance.GraphicsDevice.Viewport.Height - 80));

            kbc1 = new KeyBoardComponent();
            FadeComponent fc = new FadeComponent(1, 3);

            kbc1.keyBoardActions.Add(ActionsEnum.Left, Keys.Right);
            newId = ComponentManager.Instance.CreateID();
            ComponentManager.Instance.AddComponentToEntity(newId, fc);
            ComponentManager.Instance.AddComponentToEntity(newId, draw);
            ComponentManager.Instance.AddComponentToEntity(newId, pos2);
            ComponentManager.Instance.AddComponentToEntity(newId, kbc1);


            DrawableTextComponent text = new DrawableTextComponent("Press Enter To Start", Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/Menufont"));
            PositionComponent     pos  = new PositionComponent(new Vector2(300, 0));
            KeyBoardComponent     kbc  = new KeyBoardComponent();
            FadeComponent         fc3  = new FadeComponent(1, 3);

            kbc.keyBoardActions.Add(ActionsEnum.Enter, Keys.Enter);
            textId = ComponentManager.Instance.CreateID();
            ComponentManager.Instance.AddComponentToEntity(textId, kbc);
            ComponentManager.Instance.AddComponentToEntity(textId, text);
            ComponentManager.Instance.AddComponentToEntity(textId, pos);
            ComponentManager.Instance.AddComponentToEntity(textId, fc3);
            entitiesInState.Add(textId);

            DrawableTextComponent text2 = new DrawableTextComponent("Press Right-Arrow key To Change Map", Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/Menufont"));
            PositionComponent     pos3  = new PositionComponent(new Vector2(180, 50));
            int           textId2       = ComponentManager.Instance.CreateID();
            FadeComponent fc4           = new FadeComponent(1, 3);

            ComponentManager.Instance.AddComponentToEntity(textId2, text2);
            ComponentManager.Instance.AddComponentToEntity(textId2, pos3);
            ComponentManager.Instance.AddComponentToEntity(textId2, fc4);
            entitiesInState.Add(textId2);

            DrawableTextComponent text3 = new DrawableTextComponent("Register Character By pressing a Key", Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/Menufont"));
            PositionComponent     pos4  = new PositionComponent(new Vector2(150, 100));
            FadeComponent         fc5   = new FadeComponent(1, 3);
            int textId3 = ComponentManager.Instance.CreateID();

            ComponentManager.Instance.AddComponentToEntity(textId3, text3);
            ComponentManager.Instance.AddComponentToEntity(textId3, pos4);
            ComponentManager.Instance.AddComponentToEntity(textId3, fc5);
            entitiesInState.Add(textId3);
        }
        /// <summary>
        /// onSceneCreated this function is called whenever the current gamestate is changed. This function should contain logic that
        /// needs to be processed before the state is shown for the player. This could be enteties that's not able to be created pre-runtime.
        /// </summary>
        public void onSceneCreated()
        {
            ChangeCubesSystem ccs = (ChangeCubesSystem)SystemManager.Instance.RetrieveSystem <IUpdate>("ChangeCubesSystem");

            ccs.Respawn(3);
            SpawnPowerUpSystem sps = (SpawnPowerUpSystem)SystemManager.Instance.RetrieveSystem <IUpdate>("SpawnPowerUpSystem");

            sps.Initialize();
            List <int> maps = ComponentManager.Instance.GetAllEntitiesWithComponentType <DrawableTextComponent>();

            if (maps.Count == 1)
            {
                int temp = maps.First();
                DrawableTextComponent draw = ComponentManager.Instance.GetEntityComponent <DrawableTextComponent>(temp);
                switch (draw.text)
                {
                case "Whiteboard":
                    WhiteboardMap();
                    break;

                case "Temp":
                    tempMap();
                    break;

                case "Random":
                    randomMap();
                    break;
                }
            }
            SceneSystem.Instance.clearScene(maps);

            List <int> Players = ComponentManager.Instance.GetAllEntitiesWithComponentType <PlayerComponent>();
            int        i       = 1;

            Random rand = new Random();

            foreach (var play in Players)
            {
                DrawableComponent tempDraw = ComponentManager.Instance.GetEntityComponent <DrawableComponent>(play);
                KeyBoardComponent tempkey  = ComponentManager.Instance.GetEntityComponent <KeyBoardComponent>(play);
                PositionComponent temppos  = ComponentManager.Instance.GetEntityComponent <PositionComponent>(play);
                Keys key;
                tempkey.keyBoardActions.TryGetValue(ActionsEnum.Up, out key);
                entitiesInState.Add(GameEntityFactory.Instance.CreatePlayer(true, false, Buttons.A, key, new Vector2(rand.Next((int)(Game.Instance.GraphicsDevice.Viewport.Width)), rand.Next((int)(Game.Instance.GraphicsDevice.Viewport.Height * 0.6))), "Player " + i, Direction.Right, PlayerIndex.One, tempDraw.colour));
                i++;
                ComponentManager.Instance.RemoveEntity(play);
                //ComponentManager.Instance.RecycleID(play);
            }
            entitiesInState.Add(GameEntityFactory.Instance.CreateAIPlayer(Direction.Right, new Vector2(rand.Next((int)(Game.Instance.GraphicsDevice.Viewport.Width)), rand.Next((int)(Game.Instance.GraphicsDevice.Viewport.Height * 0.8))), true, "AI one", Color.Red));
        }
Esempio n. 5
0
        /// <summary>
        /// onSceneCreated this function is called whenever the current gamestate is changed. This function should contain logic that
        /// needs to be processed before the state is shown for the player. This could be enteties that's not able to be created pre-runtime.
        /// </summary>
        public void onSceneCreated()
        {
            SpriteFont            font1  = Game.Instance.GetContent <SpriteFont>("Fonts/Menufont");
            DrawableTextComponent winner = new DrawableTextComponent("Winner:", Color.Black, font1);
            PositionComponent     pos    = new PositionComponent(new Vector2(Game.Instance.GraphicsDevice.Viewport.Width * 0.5f - ((float)font1.MeasureString("Winner:").X * 0.5f), 0));

            kbc = new KeyBoardComponent();
            int WinnerId = ComponentManager.Instance.CreateID();

            kbc.keyBoardActions.Add(ActionsEnum.Up, Keys.Enter);
            ComponentManager.Instance.AddComponentToEntity(WinnerId, winner);
            ComponentManager.Instance.AddComponentToEntity(WinnerId, kbc);
            ComponentManager.Instance.AddComponentToEntity(WinnerId, pos);
            entitiesInState.Add(WinnerId);

            HealthSystem hs = (HealthSystem)SystemManager.Instance.RetrieveSystem <IUpdate>("HealthSystem");
            int          id = hs.deathList.First();

            hs.deathList.Clear();
            AIComponent ai = new AIComponent();

            ComponentManager.Instance.AddComponentToEntity(id, ai);
            PlayerComponent player = ComponentManager.Instance.GetEntityComponent <PlayerComponent>(id);

            entitiesInState.Add(id);
            SpriteFont            font2         = Game.Instance.GetContent <SpriteFont>("Fonts/Menufont");
            DrawableTextComponent winningPlayer = new DrawableTextComponent(player.playerName, Color.Black, font2);
            PositionComponent     pos2          = new PositionComponent(new Vector2(Game.Instance.GraphicsDevice.Viewport.Width * 0.5f - ((float)font2.MeasureString(player.playerName).X * 0.5f), 50));
            int textId2 = ComponentManager.Instance.CreateID();

            ComponentManager.Instance.AddComponentToEntity(textId2, winningPlayer);
            ComponentManager.Instance.AddComponentToEntity(textId2, pos2);
            entitiesInState.Add(textId2);

            SpriteFont            font3 = Game.Instance.GetContent <SpriteFont>("Fonts/Menufont");
            DrawableTextComponent text  = new DrawableTextComponent("Press enter to return to Main menu", Color.Black, font3);
            PositionComponent     poss  = new PositionComponent(new Vector2(Game.Instance.GraphicsDevice.Viewport.Width * 0.5f - ((float)font3.MeasureString("Press enter to return to Main menu").X * 0.5f), Game.Instance.GraphicsDevice.Viewport.Height - 100));
            int textId = ComponentManager.Instance.CreateID();

            ComponentManager.Instance.AddComponentToEntity(textId, text);
            ComponentManager.Instance.AddComponentToEntity(textId, poss);
            entitiesInState.Add(textId);

            int se = ComponentManager.Instance.CreateID();

            ComponentManager.Instance.AddComponentToEntity(se, new SoundEffectComponent("winner"));
            entitiesInState.Add(se);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="dir"></param>
        /// <param name="position"></param>
        /// <param name="pixlePer"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public int CreateAIPlayer(Direction dir, Vector2 position, bool pixlePer, string name, Color colour)
        {
            SpriteEffects flip;

            if (dir == Direction.Left)
            {
                flip = SpriteEffects.FlipHorizontally;
            }
            else
            {
                flip = SpriteEffects.None;
            }

            DirectionComponent          dc   = new DirectionComponent(dir);
            DrawableComponent           comp = new DrawableComponent(Game.Instance.GetContent <Texture2D>("Pic/Helmutsh"), flip);
            PositionComponent           pos  = new PositionComponent(position);
            VelocityComponent           vel  = new VelocityComponent(new Vector2(200F, 0), 50F);
            JumpComponent               jump = new JumpComponent(300F, 50F);
            CollisionRectangleComponent CRC  = new CollisionRectangleComponent(new Rectangle((int)pos.position.X, (int)pos.position.Y, comp.texture.Width, comp.texture.Height));
            CollisionComponent          CC   = new CollisionComponent(pixlePer);
            DrawableTextComponent       dtc  = new DrawableTextComponent(name, Color.Yellow, Game.Instance.GetContent <SpriteFont>("Fonts/NewTestFont"));
            HUDComponent       hudc          = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), new Vector2(pos.position.X, pos.position.Y));
            HUDComponent       hudc2         = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), Vector2.One);
            HealthComponent    hc            = new HealthComponent(3, false);
            AnimationComponent ani           = new AnimationComponent(75, 75, comp.texture.Width, comp.texture.Height, 0.2);
            AIComponent        ai            = new AIComponent();
            PlayerComponent    play          = new PlayerComponent(name);

            comp.colour = colour;

            int id = ComponentManager.Instance.CreateID();

            ComponentManager.Instance.AddComponentToEntity(id, vel);
            ComponentManager.Instance.AddComponentToEntity(id, comp);
            ComponentManager.Instance.AddComponentToEntity(id, pos);
            ComponentManager.Instance.AddComponentToEntity(id, CRC);
            ComponentManager.Instance.AddComponentToEntity(id, CC);
            ComponentManager.Instance.AddComponentToEntity(id, dtc);
            ComponentManager.Instance.AddComponentToEntity(id, hudc);
            ComponentManager.Instance.AddComponentToEntity(id, hc);
            ComponentManager.Instance.AddComponentToEntity(id, ani);
            ComponentManager.Instance.AddComponentToEntity(id, dc);
            ComponentManager.Instance.AddComponentToEntity(id, jump);
            ComponentManager.Instance.AddComponentToEntity(id, play);
            ComponentManager.Instance.AddComponentToEntity(id, ai);
            return(id);
        }
        /// <summary>
        /// onSceneCreated this function is called whenever the current gamestate is changed. This function should contain logic that
        /// needs to be processed before the state is shown for the player. This could be enteties that's not able to be created pre-runtime.
        /// </summary>
        public void onSceneCreated()
        {
            //add the enteties which should be displayed on the screen when the players choose their caracters. Player enteties is to be created after leaving this state therefore the
            //add entetiestolist - function needs to be called before entering the playing-state

            DrawableTextComponent dtx = new DrawableTextComponent("Flappy Ass, version 1.0 By: PT2", Color.Tomato, Game.Instance.GetContent <SpriteFont>("Fonts/MenuFont"));
            PositionComponent     pc  = new PositionComponent(new Vector2(20, 100));

            fc = new FadeComponent(254, -3);

            int id = ComponentManager.Instance.CreateID();

            ComponentManager.Instance.AddComponentToEntity(id, fc);
            ComponentManager.Instance.AddComponentToEntity(id, dtx);
            ComponentManager.Instance.AddComponentToEntity(id, pc);

            entitiesInState.Add(id);
        }
        /// <summary>
        /// onSceneCreated this function is called whenever the current gamestate is changed. This function should contain logic that
        /// needs to be processed before the state is shown for the player. This could be enteties that's not able to be created pre-runtime.
        /// </summary>
        public void onSceneCreated()
        {
            ScrollingBackgroundSystem temp = (ScrollingBackgroundSystem)SystemManager.Instance.RetrieveSystem <IDraw>("ScrollingBackgroundSystem");

            temp.active = true;
            Dictionary <Vector2, String> menuList = new Dictionary <Vector2, string>();

            int   i    = 0;
            float yvar = this.y;

            foreach (string a in menuItems)
            {
                menuList.Add(new Vector2(this.x, yvar - 200), menuItems[i]);
                yvar += 50;
                i++;
            }
            textcomp = new DrawableTextComponent(menuList, Game.Instance.GetContent <SpriteFont>("Fonts/MenuFont"), Color.Black);
            index    = 0;
            int Id = ComponentManager.Instance.CreateID();

            ComponentManager.Instance.AddComponentToEntity(Id, textcomp);
            entitiesInState.Add(Id);

            Texture2D         arrowPix      = Game.Instance.GetContent <Texture2D>("pic/arrow");
            DrawableComponent arrow         = new DrawableComponent(arrowPix, SpriteEffects.None);
            PositionComponent arrowPos      = new PositionComponent(new Vector2(this.x - 35, this.y - 200));
            MovementComponent arrowMovement = new MovementComponent(new Vector2(x, y));

            arrowId = ComponentManager.Instance.CreateID();
            ComponentManager.Instance.AddComponentToEntity(arrowId, arrow);
            ComponentManager.Instance.AddComponentToEntity(arrowId, arrowPos);
            ComponentManager.Instance.AddComponentToEntity(arrowId, arrowMovement);
            kbcArrow = new KeyBoardComponent();
            kbcArrow.keyBoardActions.Add(ActionsEnum.Down, Keys.Down);
            kbcArrow.keyBoardActions.Add(ActionsEnum.Up, Keys.Up);
            kbcArrow.keyBoardActions.Add(ActionsEnum.Enter, Keys.Enter);


            ComponentManager.Instance.AddComponentToEntity(arrowId, kbcArrow);


            entitiesInState.Add(arrowId);
        }
        /// <summary>
        /// draw is the function which handles the actuall drawing of the text in each loop in the game.
        /// </summary>
        /// <param name="gameTime">Takes a GameTime object which should represent the time since the last time this function was called</param>
        /// <param name="spriteBatch">Takes a SpriteBatch object which is used to draw the textures directly to the screen</param>
        public void draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            List <int> dra = ComponentManager.Instance.GetAllEntitiesWithComponentType <DrawableTextComponent>();

            if (dra != null)
            {
                foreach (var a in dra)
                {
                    DrawableTextComponent d = ComponentManager.Instance.GetEntityComponent <DrawableTextComponent>(a);
                    FadeComponent         f = ComponentManager.Instance.GetEntityComponent <FadeComponent>(a);
                    if (f != null)
                    {
                        f.fadeDelay -= gameTime.ElapsedGameTime.TotalSeconds;
                    }

                    Dictionary <Vector2, string> list = d.GetStringDictiornary();
                    //If there is a StringList then there's multiple lines of text that should be written to the screen.
                    if (list != null)
                    {
                        //For each of the strings in the list write them to the screen, the value key in the dictionary is the
                        //position where the line should be written.
                        foreach (var item in list)
                        {
                            if (f != null)
                            {
                                if (f.fadeDelay <= 0)
                                {
                                    f.fadeDelay = .035;

                                    f.alphaValue += f.fadeIncrement;

                                    if (f.fadeIncrement >= 255 || f.alphaValue <= 0)
                                    {
                                        f.fadeIncrement *= -1;
                                    }
                                }
                                d.textColor = new Color(255, 255, 255, (byte)MathHelper.Clamp(f.alphaValue, 0, 255));
                            }

                            spriteBatch.DrawString(d.font, item.Value, item.Key, d.textColor);
                        }
                    }
                    //There is just one line of text, then just draw it to the screen.
                    else
                    {
                        FadeComponent fc = ComponentManager.Instance.GetEntityComponent <FadeComponent>(a);
                        if (f != null)
                        {
                            f.fadeDelay -= gameTime.ElapsedGameTime.TotalSeconds;
                        }

                        if (fc != null)
                        {
                            if (fc.fadeDelay <= 0)
                            {
                                fc.fadeDelay = .035;

                                fc.alphaValue += f.fadeIncrement;

                                if (fc.fadeIncrement >= 255 || fc.alphaValue <= 0)
                                {
                                    fc.fadeIncrement *= 0;
                                }
                            }
                            d.textColor = new Color(255, 0, 255, (byte)MathHelper.Clamp(fc.alphaValue, 0, 255));
                        }


                        PositionComponent p = ComponentManager.Instance.GetEntityComponent <PositionComponent>(a);
                        if (p != null && d != null && d.visible == true)
                        {
                            spriteBatch.DrawString(d.font, d.text, p.position, d.textColor);
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// onSceneUpdate this function handles the logic for the state which should be run durring the update partion of the game.
        /// For example this could be to check for conditions to continue to the next state of the gameplay.
        /// </summary>
        public void onSceneUpdate()
        {
            Game game = Game.Instance;
            KeyBoardComponent temp = ComponentManager.Instance.GetEntityComponent <KeyBoardComponent>(textId);

            if (kbc1.state[ActionsEnum.Left] == ButtonStates.Pressed)
            {
                map = map + 1;
                if (map > Map.Random)
                {
                    map = Map.Whiteboard;
                }

                switch (map)
                {
                case Map.Whiteboard:
                    draw.text = "Whiteboard";
                    break;

                case Map.Temp:

                    draw.text = "Temp";
                    break;

                case Map.Random:

                    draw.text = "Random";
                    break;
                }
            }
            if (temp.state[ActionsEnum.Enter] == ButtonStates.Pressed)
            {
                if (Players.Count != 0)
                {
                    DrawableTextComponent temp54 = ComponentManager.Instance.GetEntityComponent <DrawableTextComponent>(newId);
                    temp54.visible = false;
                    Players.Clear();
                    SceneSystem.Instance.clearScene(entitiesInState);
                    SceneSystem.Instance.setCurrentScene(new PlayingScene());
                }
            }


            KeyboardState tetet = Keyboard.GetState();
            List <Keys>   key   = tetet.GetPressedKeys().ToList <Keys>();

            if (key.Count != 0)
            {
                if (UnAvailableKeys != null && !UnAvailableKeys.Contains(key[0]))
                {
                    if (Players.Count < 4)
                    {
                        Keys temo = key[0];
                        key.Clear();
                        Dictionary <int, Keys> Dir = new Dictionary <int, Keys>();
                        int tempId = ComponentManager.Instance.CreateID();
                        int count  = Players.Count;
                        Players.Add(tempId);
                        DrawableComponent tempDraw = new DrawableComponent(Game.Instance.GetContent <Texture2D>("Pic/kanin1"), SpriteEffects.None);
                        PositionComponent temppos  = new PositionComponent(new Vector2((Game.Instance.GraphicsDevice.Viewport.Width * 0.25f + 20f) * count, Game.Instance.GraphicsDevice.Viewport.Height * 0.5f));
                        KeyBoardComponent tempkey  = new KeyBoardComponent();
                        PlayerComponent   tempplay = new PlayerComponent();
                        tempkey.keyBoardActions.Add(ActionsEnum.Up, temo);
                        ComponentManager.Instance.AddComponentToEntity(tempId, tempDraw);
                        ComponentManager.Instance.AddComponentToEntity(tempId, temppos);
                        ComponentManager.Instance.AddComponentToEntity(tempId, tempkey);
                        ComponentManager.Instance.AddComponentToEntity(tempId, tempplay);


                        //Keys temp0;
                        //tempkey.keyBoardActions.TryGetValue(ActionsEnum.Up, out temp0);
                        //Console.WriteLine(temp0.ToString());


                        int textId = ComponentManager.Instance.CreateID();
                        DrawableTextComponent tempDrawtext = new DrawableTextComponent(temo.ToString(), Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/MenuFont"));
                        PositionComponent     temptextPos  = new PositionComponent(new Vector2((Game.Instance.GraphicsDevice.Viewport.Width * 0.25f + 20f) * count, Game.Instance.GraphicsDevice.Viewport.Height * 0.5f + 80f));
                        ComponentManager.Instance.AddComponentToEntity(textId, tempDrawtext);
                        ComponentManager.Instance.AddComponentToEntity(textId, temptextPos);
                        entitiesInState.Add(textId);
                        UnAvailableKeys.Add(temo);
                    }
                }
                else if (UnAvailableKeys.Contains(key[0]) && key[0] != Keys.Enter)
                {
                    foreach (var a in Players)
                    {
                        KeyBoardComponent tempa = ComponentManager.Instance.GetEntityComponent <KeyBoardComponent>(a);
                        Keys key2;
                        tempa.keyBoardActions.TryGetValue(ActionsEnum.Up, out key2);
                        if (tempa != null && key2 != Keys.Enter)
                        {
                            if (tempa.state[ActionsEnum.Up] == ButtonStates.Pressed)
                            {
                                DrawableComponent tempura = ComponentManager.Instance.GetEntityComponent <DrawableComponent>(a);
                                Random            rand    = new Random();
                                tempura.colour = new Color(rand.Next(0, 256), rand.Next(0, 256), rand.Next(0, 256));
                            }
                        }
                    }
                }
            }
        }