public CharacterHUD(int x, int y, int width, int height, SSCEnums.PlayerID Player) : base(x, y, width, height, false) { this.background = new AnimatedSprite("Background", new Vector2(x, y), new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("SSCUI", "DialogBox"), new Animation(0, 0, 32, 32)), Color.White); this.playerID = Player; this.showHUD = false; this.heart = new AnimatedSprite("Heart", new Vector2(x + 32, y + 10), new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("SSCUI", "Heart"), new Animation(0, 0, 7, 6), new Dictionary <string, List <Animation> >() { { "Full", new List <Animation>() { new Animation(0, 0, 7, 6) } }, { "Empty", new List <Animation>() { new Animation(7, 0, 7, 6) } } }, "Full"), Color.White); this.heart.animation.playAnimation("Full"); this.playerHealth = SeasideScramble.self.gameFont.ParseString("100", new Vector2(100, this.yPositionOnScreen + 10), Color.White, true, 2f); this.playerHealth.setPosition(new Vector2(this.xPositionOnScreen + 100, this.yPositionOnScreen + 10)); this.showFullHeart = true; this.gun = new AnimatedSprite("Gun", new Vector2(x + 32, y + 50), new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Guns", "BasicGun"), new Animation(0, 0, 16, 16)), Color.White); this.playerAmmo = SeasideScramble.self.gameFont.ParseString("100", new Vector2(100, this.yPositionOnScreen + 50), Color.White, true, 2f); this.playerAmmo.setPosition(new Vector2(this.xPositionOnScreen + 100, this.yPositionOnScreen + 50)); this.clock = new AnimatedSprite("Clock", new Vector2(x + 32, y + 50), new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("SSCUI", "Clock"), new Animation(0, 0, 11, 10)), Color.White); this.reloadTime = SeasideScramble.self.gameFont.ParseString("100", new Vector2(100, this.yPositionOnScreen + 50), Color.White, true, 2f); this.reloadTime.setPosition(new Vector2(this.xPositionOnScreen + 100, this.yPositionOnScreen + 50)); this.targetsHit = new AnimatedSprite("Target", new Vector2(x + 32, y + 100), new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Enemies", "Target"), new Animation(0, 0, 16, 16)), Color.White); this.targetsScoreText = SeasideScramble.self.gameFont.ParseString("000", new Vector2(100, this.yPositionOnScreen + 110), Color.White, true, 2f); this.targetsScoreText.setPosition(new Vector2(this.xPositionOnScreen + 100, this.yPositionOnScreen + 110)); }
/// <summary> /// Iterates the player's color index to get the next possible color. /// </summary> /// <param name="player"></param> /// <param name="amount"></param> private void iteratePlayerColorIndex(SSCEnums.PlayerID player, int amount) { if (this.inputDelays[player] != 0) { return; } this.inputDelays[player] = this.maxInputDelay; while (this.doesAnyOtherPlayerHaveThisColor(player) == true) { if (this.playerColorIndex[player] >= this.possibleColors.Count) { this.playerColorIndex[player] = 0; } else if (this.playerColorIndex[player] < 0) { this.playerColorIndex[player] = this.possibleColors.Count - 1; } else { this.playerColorIndex[player] += amount; } } this.playerColorIndex[player] += amount; if (this.playerColorIndex[player] >= this.possibleColors.Count) { this.playerColorIndex[player] = 0; } else if (this.playerColorIndex[player] < 0) { this.playerColorIndex[player] = this.possibleColors.Count - 1; } this.setPlayerColor(player); }
/// <summary> /// Sets a given player's color. /// </summary> /// <param name="player"></param> private void setPlayerColor(SSCEnums.PlayerID player) { if (SeasideScramble.self.getPlayer(player) == null) { return; } ModCore.log("Player: " + player); ModCore.log("Index: " + this.playerColorIndex[player]); SeasideScramble.self.getPlayer(player).setColor(this.possibleColors[this.playerColorIndex[player]]); if (player == SSCEnums.PlayerID.One) { this.animatedSprites["P1Color"].color = this.possibleColors[this.playerColorIndex[player]]; } if (player == SSCEnums.PlayerID.Two) { this.animatedSprites["P2Color"].color = this.possibleColors[this.playerColorIndex[player]]; } if (player == SSCEnums.PlayerID.Three) { this.animatedSprites["P3Color"].color = this.possibleColors[this.playerColorIndex[player]]; } if (player == SSCEnums.PlayerID.Four) { this.animatedSprites["P4Color"].color = this.possibleColors[this.playerColorIndex[player]]; } }
public SSCPlayer getPlayer(SSCEnums.PlayerID id) { if (this.players.ContainsKey(id)) { return(this.players[id]); } else { return(null); } }
/// <summary> /// Initializes a given character. /// </summary> /// <param name="player"></param> public void initializeCharacter(SSCEnums.PlayerID player) { if (SeasideScramble.self.players.ContainsKey(player)) { return; } else { SeasideScramble.self.players.Add(player, new SSCPlayer(player)); this.iteratePlayerColorIndex(player, 1); } this.setPlayerColor(player); }
/// <summary> /// Receive input from a specific gamepad. /// </summary> /// <param name="state"></param> /// <param name="ID"></param> private void receiveGamepadInput(GamePadState state, SSCEnums.PlayerID ID) { if (state == null) { return; } else { if (this.players.ContainsKey(ID)) { this.players[ID].receiveGamepadInput(state); } } }
/// <summary> /// Checks if a given player has the same color index as another to prevent color duplicates. /// </summary> /// <param name="self"></param> /// <param name="other"></param> /// <returns></returns> private bool doesOtherPlayerHaveThisColor(SSCEnums.PlayerID self, SSCEnums.PlayerID other) { if (SeasideScramble.self.getPlayer(other) == null) { return(false); } if (this.playerColorIndex[self] == this.playerColorIndex[other]) { return(true); } else { return(false); } }
public void receiveGamepadLeftClick(SSCEnums.PlayerID player, int x, int y, bool playSound = true) { if (player == SSCEnums.PlayerID.One) { if (this.buttons["P1NextButton"].containsPoint(x, y)) { this.iteratePlayerColorIndex(player, 1); } if (this.buttons["P1PrevButton"].containsPoint(x, y)) { this.iteratePlayerColorIndex(player, -1); } } if (player == SSCEnums.PlayerID.Two) { if (this.buttons["P2NextButton"].containsPoint(x, y)) { this.iteratePlayerColorIndex(player, 1); } if (this.buttons["P2PrevButton"].containsPoint(x, y)) { this.iteratePlayerColorIndex(player, -1); } } if (player == SSCEnums.PlayerID.Three) { if (this.buttons["P3NextButton"].containsPoint(x, y)) { this.iteratePlayerColorIndex(player, 1); } if (this.buttons["P3PrevButton"].containsPoint(x, y)) { this.iteratePlayerColorIndex(player, -1); } } if (player == SSCEnums.PlayerID.Four) { if (this.buttons["P4NextButton"].containsPoint(x, y)) { this.iteratePlayerColorIndex(player, 1); } if (this.buttons["P4PrevButton"].containsPoint(x, y)) { this.iteratePlayerColorIndex(player, -1); } } }
/// <summary> /// Looks for controller input for swaping character colors. /// </summary> /// <param name="state"></param> /// <param name="player"></param> private void checkForControllerColorSwap(GamePadState state, SSCEnums.PlayerID player) { if (state.IsButtonDown(Buttons.DPadRight)) { this.iteratePlayerColorIndex(player, 1); } else if (state.IsButtonDown(Buttons.DPadLeft)) { this.iteratePlayerColorIndex(player, -1); } if (state.ThumbSticks.Left.X < 0) { this.iteratePlayerColorIndex(player, -1); } else if (state.ThumbSticks.Left.X > 0) { this.iteratePlayerColorIndex(player, 1); } }
/// <summary> /// Checks if any other player has the same color index to prevent color duplicates. /// </summary> /// <param name="self"></param> /// <returns></returns> private bool doesAnyOtherPlayerHaveThisColor(SSCEnums.PlayerID self) { for (int i = 0; i < 4; i++) { SSCEnums.PlayerID other = (SSCEnums.PlayerID)i; if (other == self) { continue; } if (this.doesOtherPlayerHaveThisColor(self, other) == false) { continue; } else { return(true); } } return(false); }
public void receiveGamepadLeftClick(SSCEnums.PlayerID Player, Vector2 position) { this.receiveLeftClick((int)position.X, (int)position.Y); }
public void receiveGamepadLeftClick(SSCEnums.PlayerID player, Vector2 position, bool playSound = true) { this.receiveGamepadLeftClick(player, (int)position.X, (int)position.Y, playSound); }
public void addScore(SSCEnums.PlayerID player, int amount) { this.score[player] += amount; }