public Player(Texture2D sprite, Vector2 position, PlayerIndex playerNum, Stats entStats, GameUIElement playerUI) : base(sprite, position, entStats) { this.playerNum = playerNum; curState = PlayerState.PLAYER_OTHER; this.playerUI = playerUI; this.testAttack = new SimpleAttack(new Rectangle(0, 0, 32, 16), this, 1.5f, 50); this.playerCenter = new Vector2(sprite.Width / 2, sprite.Height / 2); this.logicManager = GamePlayLogicManager.GetInstance(); this.drawManager = GamePlayDrawManager.GetInstance(); this.playerManager = PlayerManager.GetInstance(); }
public void RemoveElementR(GameUIElement e) { if (elementsRelative.Contains(e)) elementsRelative.Remove(e); }
public void RemoveElementA(GameUIElement e) { if (elementsAbsolute.Contains(e)) elementsAbsolute.Remove(e); }
public void RemoveElement(GameUIElement e) { RemoveElementA(e); RemoveElementR(e); }
public void AddElementR(GameUIElement e) { if (!elementsRelative.Contains(e)) elementsRelative.Add(e); }
public void AddElementA(GameUIElement e) { if (!elementsAbsolute.Contains(e)) elementsAbsolute.Add(e); }
public void setupDefaultPlayers() { GamePlayDrawManager drawManager = GamePlayDrawManager.GetInstance(); GamePlayInputManager inputManager = GamePlayInputManager.GetInstance(); GamePlayLogicManager logicManager = GamePlayLogicManager.GetInstance(); GamePlayMapManager mapManager = GamePlayMapManager.GetInstance(); GameUIElement playerUI = new GameUIElement(drawManager.UI, "", new Vector2(10, 100)); //temporary hacky player loading, hard coded Player player = new Player(SpriteFlyweightFactory.GetSpriteFlyweight().GetSprite("Entities/Characters/BMOStanding"), mapManager.Map.MapData.Spawn, PlayerIndex.One, new BaseStats(10, 10, 5), playerUI); //we're going to be doing these calls a lot - consider factory or facade or similar this.SetPlayer(0, player); drawManager.Add(player, GamePlayDrawManager.DRAW_LIST_LEVEL.ENTITY); inputManager.Add(player); logicManager.AddMovable(player); logicManager.AddCollidable(player); logicManager.AddUpdatable(player); //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); Player player2 = new Player(SpriteFlyweightFactory.GetSpriteFlyweight().GetSprite("Entities/Characters/NeptrStanding"), mapManager.Map.MapData.Spawn + new Vector2(50, 50), PlayerIndex.Two, new BaseStats(15, 12, 4), playerUI); this.SetPlayer(1, player2); drawManager.Add(player2, GamePlayDrawManager.DRAW_LIST_LEVEL.ENTITY); inputManager.Add(player2); logicManager.AddMovable(player2); logicManager.AddCollidable(player2); logicManager.AddUpdatable(player2); //really hacky temporary way of setting player bindings player2.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_ATTACK] = new PlayerInputBinding(Keys.RightControl, Buttons.A); player2.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_UP] = new PlayerInputBinding(Keys.Up, Buttons.DPadUp); player2.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_DOWN] = new PlayerInputBinding(Keys.Down, Buttons.DPadDown); player2.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_LEFT] = new PlayerInputBinding(Keys.Left, Buttons.DPadLeft); player2.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_MOVE_RIGHT] = new PlayerInputBinding(Keys.Right, Buttons.DPadRight); player2.PlayerBindings[(int)Player.PlayerKeyBind.PLAYER_PICKUP_ITEM] = new PlayerInputBinding(Keys.RightShift, Buttons.X); }
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); } }