Exemplo n.º 1
0
 private Item getBaseItem(itemType type)
 {
     BaseStats basestat;
     string name;
     switch (type)
     {
         case itemType.Sword:
             name = "Sword";
             basestat = new BaseStats(0, 4, 2);
             break;
         case itemType.Slingshot:
             name = "Slingshot";
             basestat = new BaseStats(0, 2, 1);
             break;
         case itemType.PhysicsTextbook:
             name = "Physics Textbook";
             basestat = new BaseStats(0, 5, 0);
             break;
         case itemType.Pie:
             name = "Pie";
             basestat = new BaseStats(0, 2, 0);
             break;
         default:
             name = "Running Shoes";
             basestat = new BaseStats(0, 0, 5);
             break;
     }
     GamePlayContentManager cm = GamePlayContentManager.GetInstance();
     return new Weapon(null, name, basestat);
 }
        public void SetPlayer(int playerIndex, Character c)
        {
            GamePlayDrawManager drawManager = GamePlayDrawManager.GetInstance();
            GamePlayInputManager inputManager = GamePlayInputManager.GetInstance();
            GamePlayLogicManager logicManager = GamePlayLogicManager.GetInstance();
            GamePlayMapManager mapManager = GamePlayMapManager.GetInstance();
            Random rand = new Random();

            Texture2D playerSprite;
            Stats playerStats;
            GameUIElement playerUI;

            switch (c)
            {
                case Character.BMO:
                    playerSprite = SpriteFlyweightFactory.GetSpriteFlyweight().GetSprite("Entities/Characters/BMOStanding");
                    playerStats = new BaseStats(50, 10, 5);
                    break;
                case Character.NEPTR:
                    playerSprite = SpriteFlyweightFactory.GetSpriteFlyweight().GetSprite("Entities/Characters/NeptrStanding");
                    playerStats = new BaseStats(75, 20, 3);
                    break;
                default:
                    playerSprite = SpriteFlyweightFactory.GetSpriteFlyweight().GetSprite("Entities/Characters/BMOStanding");
                    playerStats = new BaseStats(50, 10, 5);
                    break;

            }

            PlayerIndex pi;
            switch (playerIndex)
            {
                case 1:
                    pi = PlayerIndex.One;
                    playerUI = new GameUIElement(drawManager.UI, "", new Vector2(10, 100));
                    break;
                case 2:
                    pi = PlayerIndex.Two;
                    playerUI = new GameUIElement(drawManager.UI, "", new Vector2(10, 200));
                    break;
                default:
                    pi = PlayerIndex.One;
                    playerUI = new GameUIElement(drawManager.UI, "", new Vector2(10, 100));
                    break;
            }

            Player player = new Player(playerSprite, mapManager.Map.MapData.Spawn + new Vector2(40 * playerIndex, 40 * playerIndex), pi, playerStats, playerUI);
            SetPlayer(playerIndex - 1, player);

            drawManager.UI.AddElementR(playerUI);

            drawManager.Add(player, GamePlayDrawManager.DRAW_LIST_LEVEL.ENTITY);
            inputManager.Add(player);
            logicManager.AddMovable(player);
            logicManager.AddCollidable(player);
            logicManager.AddUpdatable(player);

            //Setting up player specific input
            if (playerIndex == 1)
            {
                //really hacky temporary way of setting player bindings
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_ATTACK] = new PlayerInputBinding(Keys.Space, Buttons.A);
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_UP] = new PlayerInputBinding(Keys.W, Buttons.DPadUp);
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_DOWN] = new PlayerInputBinding(Keys.S, Buttons.DPadDown);
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_LEFT] = new PlayerInputBinding(Keys.A, Buttons.DPadLeft);
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_RIGHT] = new PlayerInputBinding(Keys.D, Buttons.DPadRight);
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_PICKUP_ITEM] = new PlayerInputBinding(Keys.E, Buttons.X);
            }
            else
            {
                //really hacky temporary way of setting player bindings
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_ATTACK] = new PlayerInputBinding(Keys.RightControl, Buttons.A);
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_UP] = new PlayerInputBinding(Keys.Up, Buttons.DPadUp);
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_DOWN] = new PlayerInputBinding(Keys.Down, Buttons.DPadDown);
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_LEFT] = new PlayerInputBinding(Keys.Left, Buttons.DPadLeft);
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_RIGHT] = new PlayerInputBinding(Keys.Right, Buttons.DPadRight);
                player.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_PICKUP_ITEM] = new PlayerInputBinding(Keys.RightShift, Buttons.X);
            }
        }