public StateBowlerHatReThrow(int itemIndex, BoxingPlayer player, KeyPressed key) : base(player, "BowlerRethrow") { canCatch = true; itemButton = key; }
/// <summary> /// Puts the other player into their Hit state. /// </summary> /// <param name="hitPlayer"></param> public override void HitOtherPlayer(BoxingPlayer hitPlayer) { // Are we at the pull frame? and is the player in front of us? if (player.sprite.FrameIndex > 5 && player.sprite.FrameIndex < 9) //6 || player.sprite.FrameIndex == 7 //|| player.sprite.FrameIndex == 8) { if ((player.direction == -1 && player.position.X > hitPlayer.position.X) ) { hitPlayer.position.X += 10; if (hitPlayer.position.X > player.position.X - 30) hitPlayer.position.X = player.position.X - 30; } if((player.direction == 1 && player.position.X < hitPlayer.position.X)) { hitPlayer.position.X -= 10; if (hitPlayer.position.X < player.position.X + 30) hitPlayer.position.X = player.position.X + 30; } pulledPlayer = hitPlayer; hitPlayer.state.ChangeState(new StateStopped(hitPlayer)); hitPlayer.isCaught = true; // Stun player! //hitPlayer.state.isHit(hitPlayer, new StateCaneHit(hitPlayer), 0); } }
public StateCaneBonk(int itemIndex, BoxingPlayer player, KeyPressed key) : base(player, "CaneBonk") { isAttack = true; holdTimer = holdTime; this.itemButton = key; }
public override void isHit(BoxingPlayer attackingPlayer, State expectedHitState, int damage) { if (!(state == CapeState.travel)) { base.isHit(attackingPlayer, expectedHitState, damage); } }
public override void LoadState(BoxingPlayer player, Dictionary<string, Animation> ATextures) { this.StatePlayer = player; this.PlayerAnimation = ATextures[StateName]; StatePlayer.isAttacking = false; StatePlayer.isHit = false; }
/// <summary> /// Puts the other player into their Hit state. /// </summary> /// <param name="hitPlayer"></param> public override void HitOtherPlayer(BoxingPlayer hitPlayer) { // Are we at the pull frame? and is the player in front of us? if (player.sprite.FrameIndex > 5 && player.sprite.FrameIndex < 9) //6 || player.sprite.FrameIndex == 7 //|| player.sprite.FrameIndex == 8) { if ((player.direction == -1 && player.position.X > hitPlayer.position.X)) { hitPlayer.position.X += 10; if (hitPlayer.position.X > player.position.X - 30) { hitPlayer.position.X = player.position.X - 30; } } if ((player.direction == 1 && player.position.X < hitPlayer.position.X)) { hitPlayer.position.X -= 10; if (hitPlayer.position.X < player.position.X + 30) { hitPlayer.position.X = player.position.X + 30; } } pulledPlayer = hitPlayer; hitPlayer.state.ChangeState(new StateStopped(hitPlayer)); hitPlayer.isCaught = true; // Stun player! //hitPlayer.state.isHit(hitPlayer, new StateCaneHit(hitPlayer), 0); } }
public StateBowlerHatCatch(BoxingPlayer player, BowlerHatInstance hat, State originalState) : base(player, "BowlerCatch") { this.hat = hat; this.originalState = originalState; player.hasThrownBowlerHat = false; }
public override void isHit(BoxingPlayer attackingPlayer, State expectedHitState, int damage) { // Nothing happens! You can't phase me bro! // unless you're shoot'n me! if ((attackingPlayer.state is StateRevolverShoot)) { base.isHit(attackingPlayer, expectedHitState, damage); } // well timed? Duck and weave! else if (dodgeThreshold > 0) { ChangeState(new StateDodge(player)); attackingPlayer.state.wasDodged(); } // just get knocked back a little else if (!(attackingPlayer.state is StateRevolverShoot) && timer <= 0) { if ((player.direction == 1 && player.position.X < attackingPlayer.position.X) || (player.direction == -1 && player.position.X > attackingPlayer.position.X)) { timer = waitTime; player.position.X += attackingPlayer.direction * hitVelocity; // and some chip damage //player.CurrentHealth -= 1; } else { // You're facing the wrong way and get knocked down, homie! base.isHit(attackingPlayer, expectedHitState, damage); } } }
KeyPressed itemButton; // the button mapped to this item public StateCape(int itemIndex, BoxingPlayer player, KeyPressed key) : base(player, "Cape") { this.itemIndex = itemIndex; state = CapeState.draw; this.itemButton = key; }
public StateWalking(BoxingPlayer player, KeyPressed key) : base(player, "Walk") { this.key = key; player.currentHorizontalSpeed = player.direction * walkSpeed; canCombo = true; canCatch = true; }
public StateKnockedDown(BoxingPlayer player, int dir, bool knockback) : base(player, "Down") { if (!knockback) knockbackVelocity = 0; isStopping = false; this.dir = dir; // The direction which they are knocked down. //Debug.WriteLine("Fall direction = " + dir); }
public override void LoadState(BoxingPlayer player, Dictionary<string, Animation> ATextures) { this.StatePlayer = player; this.PlayerAnimation = ATextures[StateName]; StatePlayer.isAttacking = true; // if (StatePlayer.PlayerEffect == SpriteEffects.None) // StatePlayer.Hitbox = new Rectangle((int)StatePlayer.Position.X,(int)StatePlayer.Position.Y,Tools.WIDTH, Tools.HEIGHT); }
public PlayerStatDisplay(SpriteFont font, int player_index, BoxingPlayer player,Input_Handler input, Rectangle bounds, Texture2D background, Texture2D bar) { this.player = player; this.bounds = bounds; this.background = background; this.tBar = bar; this.health = player.MaxHealth; this.stamina = player.MaxStamina; this.input = input; this.isActive = input.isActive; title = "Player " + player_index; //===================Initialize positions==================== int margin = 1; // the whitespace around the entry // Dimensions of the strings int stringHeight = (int)font.MeasureString("S").Y; int stringWidth = (int)font.MeasureString("MMM").X; // Dimensions of the bars int textX = bounds.X + stringWidth / 2; int barHeight = (int)( 1.5f * stringHeight / 3); int barX = bounds.X + (int)(1.25f * stringWidth + 2); // Portions? int vertical_Portion = bounds.Height / 14; int textWidth = bounds.Width / 3; barWidth = bounds.X + bounds.Width - barX - 4; Vector2 start = new Vector2(bounds.X, bounds.Y); // Set position of the Title vTitle = new Vector2(bounds.X + bounds.Width / 2 - font.MeasureString(title).X, bounds.Y); vHealth = new Vector2(textX + margin, start.Y + margin + (1 * (stringHeight) + (1 * 2 * margin))); vStamina = new Vector2(textX + margin, start.Y + margin + (2 * (stringHeight) + (2 * 2 * margin))); rHealth = new Rectangle(barX, (int)start.Y + margin + (1 * (stringHeight) + (1 * 2 * margin)), barWidth, stringHeight); rStamina = new Rectangle(barX, (int)start.Y + margin + (2 * (stringHeight) + (2 * 2 * margin)), barWidth, stringHeight); Debug.WriteLine("rHealth.Y = " + rHealth.Y); rHealth.Width = (int)(barWidth * (player.CurrentHealth / player.MaxHealth)); rStamina.Width = (int)(barWidth * (player.CurrentStamina / player.MaxStamina)); int squarewidth = bounds.Width / 8; // Set position of ability cooldown squares for (int i = 0; i < 4; i++) { rAbilities[i] = new Rectangle(((i + 1) * (bounds.X + bounds.Width) / 5) - squarewidth/2, (int)start.Y + margin + (3 * (stringHeight) + (3 * 2 * margin)), squarewidth, squarewidth); //Debug.WriteLine("Player " + player_index + " square " + (i + 1) + " initialized"); Debug.WriteLine("Player " + player_index + " square. X = " + rAbilities[i].X + "square.Y = " + rAbilities[i].Y); } }
/// <summary> /// If we're hit 5 times by the revolver, we get knocked down! /// </summary> /// <param name="attackingPlayer"></param> public override void isHit(BoxingPlayer attackingPlayer, State expectedHitState, int damage) { if (timer > 0) { hitCounter++; timer = time; player.sprite.FrameIndex = 0; player.CurrentHealth -= damage / 2; } }
public StateBowlerHatThrow(int itemIndex, BoxingPlayer player, KeyPressed key) : base(player, "BowlerThrow") { if (player.hasThrownBowlerHat) noHat = true; //ChangeState(new StateBowlerHatReThrow(itemIndex, player)); // Wait to recieve! holdTimer = MAX_HOLD_TIME; this.itemButton = key; }
public StateRunning(BoxingPlayer player, KeyPressed key) : base(player, "Run") { isStopping = false; this.key = key; player.currentHorizontalSpeed = runSpeed;//player.direction* runSpeed; canCombo = true; canCatch = true; runSpeed *= BoxingPlayer.Scale; }
public override void HandleKeyDownInput(int player_index, KeyPressed key) { if (key == itemButton) // pressing the item button? { if (shootCounter == 0 && (player.sprite.FrameIndex == 4 || player.sprite.FrameIndex == 5)) { player.soundEffects["RevolverShoot"].Play(.5f, 0, 0); // play the sound effect! shootCounter++; BoxingPlayer p = player.BoxingManager.GetPlayerInFront(player, player.position.Y - 7 * player.GetHeight / 9, player.direction); if (p != null && !(p.state is StateKnockedDown)) { p.beingComboedTimer = p.beingComboedCooldown; p.revolverHitCounter++; p.state.isHit(p, new StateRevolverHit(p), damage); /*if(p.state is StateRevolverHit) * { * StateRevolverHit s = (StateRevolverHit)p.state * s.hitCounter = shootCounter; * }*/ } } else if (shootCounter < 5 && (player.sprite.FrameIndex == 8 || player.sprite.FrameIndex == 9)) { player.sprite.FrameIndex = 5; shootCounter++; BoxingPlayer p = player.BoxingManager.GetPlayerInFront(player, player.position.Y - 2 * player.GetHeight / 3, player.direction); if (p != null && !(p.state is StateKnockedDown)) { player.soundEffects["RevolverShoot"].Play(.5f, 0, 0); // play the sound effect! p.state.isHit(player, new StateRevolverHit(p), damage); /*if(p.state is StateRevolverHit) * { * StateRevolverHit s = (StateRevolverHit)p.state * s.hitCounter = shootCounter; * }*/ // reset combo counter p.beingComboedTimer = p.beingComboedCooldown; p.revolverHitCounter++; Debug.WriteLine("Hit " + p.revolverHitCounter + " times!"); if (p.beingComboedTimer > 0 && p.revolverHitCounter >= 5) { p.state.ChangeState(new StateKnockedDown(p, player.direction, true)); //player.CurrentHealth -= damage; } } } } base.HandleKeyDownInput(player_index, key); }
public StateKnockedDown(BoxingPlayer player, int dir, bool knockback) : base(player, "Down") { if (!knockback) { knockbackVelocity = 0; } isStopping = false; this.dir = dir; // The direction which they are knocked down. //Debug.WriteLine("Fall direction = " + dir); }
public override void isHit(BoxingPlayer attackingPlayer, State expectedHitState, int damage) { //If you get jumped on, you get knocked down! if (attackingPlayer.state is StateFall || attackingPlayer.isFalling) { ChangeState(new StateKnockedDown(player, 0, false)); } else if (attackingPlayer.state is StateCaneBonk) { base.isHit(attackingPlayer, new StateKnockedDown(player, 0, false), damage); } }
public StateBowlerHatThrow(int itemIndex, BoxingPlayer player, KeyPressed key) : base(player, "BowlerThrow") { if (player.hasThrownBowlerHat) { noHat = true; } //ChangeState(new StateBowlerHatReThrow(itemIndex, player)); // Wait to recieve! holdTimer = MAX_HOLD_TIME; this.itemButton = key; }
public StateRevolverShoot(int itemIndex, BoxingPlayer player, KeyPressed key) : base(player, "RevolverShoot") { isAttack = false; player.input.OnKeyDown += HandleKeyDownInput; shootCounter = 0; this.itemButton = key; canCatch = true; }
/// <summary> /// Puts the other player into their Hit state. /// </summary> /// <param name="hitPlayer"></param> public override void HitOtherPlayer(BoxingPlayer hitPlayer) { // Are we at the punch frame? and is the player in front of us? if (player.sprite.FrameIndex == 4) { if ((player.direction == -1 && player.position.X > hitPlayer.position.X) || (player.direction == 1 && player.position.X < hitPlayer.position.X)) { hitPlayer.state.isHit(player, new StateHit(hitPlayer), 5); } } }
public StateFall(BoxingPlayer player, bool drop) : base(player, "Jump") { if (drop) { //player.position.Y += 5; player.currentVerticalSpeed = 20; } else { player.sprite.FrameIndex = 5; } isStopping = true; canCatch = true; }
public StateJump(BoxingPlayer player, bool fall) : base(player, "Jump") { isStopping = false; if (!fall) { startPosition = player.levellevel; player.currentVerticalSpeed = -400; } canCatch = true; canCombo = true; }
/// <summary> /// Puts the other player into their Hit state. /// </summary> /// <param name="hitPlayer"></param> public override void HitOtherPlayer(BoxingPlayer hitPlayer) { // Are we at the punch frame? and is the player in front of us? if (player.sprite.FrameIndex == 7) { if ((player.direction == -1 && player.position.X > hitPlayer.position.X) || (player.direction == 1 && player.position.X < hitPlayer.position.X)) { hitPlayer.state.isHit(player, new StateCaneHit(hitPlayer), damage); //Debug.WriteLine("Other player hit!"); } } }
/// <summary> /// If we're hit twice in a row, we get knocked down! /// </summary> /// <param name="attackingPlayer"></param> public override void isHit(BoxingPlayer attackingPlayer, State expectedHitState, int damage) { if (timer <= 0) { ChangeState(new StateKnockedDown(player, attackingPlayer.direction, true)); player.CurrentHealth -= damage; if(attackingPlayer.state is StateCaneBonk) player.soundEffects["CaneHit"].Play(); // play the sound effect! //else //player.soundEffects[" timer = time; } }
/// <summary> /// If we're hit twice in a row, we get knocked down! /// </summary> /// <param name="attackingPlayer"></param> public override void isHit(BoxingPlayer attackingPlayer, State expectedHitState, int damage) { if (timer <= 0) { ChangeState(new StateKnockedDown(player, attackingPlayer.direction, true)); player.CurrentHealth -= damage; if (attackingPlayer.state is StateCaneBonk) { player.soundEffects["CaneHit"].Play(); // play the sound effect! } //else //player.soundEffects[" timer = time; } }
/// <summary> /// Handles any effects to this player. /// </summary> /// <param name="attackingPlayer"></param> public virtual void isHit(BoxingPlayer attackingPlayer, State expectedHitState, int damage) { //Debug.WriteLine("isHit virtual!"); if (attackingPlayer.state.isAttack || attackingPlayer.state is StateRevolverShoot) { player.CurrentHealth -= damage; } if (player.CurrentHealth <= 0) { player.state.ChangeState(new StateKnockedDown(player, attackingPlayer.direction, true)); } else { player.state.ChangeState(expectedHitState); } }
/// <summary> /// If we're hit twice in a row, we get knocked down! /// </summary> /// <param name="attackingPlayer"></param> public override void isHit(BoxingPlayer attackingPlayer, State expectedHitState, int damage) { if (timer <= 0) { // well timed? Duck and weave! if (dodgeTimer > 0) { ChangeState(new StateDodge(player)); attackingPlayer.state.wasDodged(); } else { hitCounter++; PlaySound(player.soundEffects["Hit"]); // play the sound effect! } } if (hitCounter >= 1) { ChangeState(new StateKnockedDown(player, attackingPlayer.direction, true)); player.CurrentHealth -= 20; } }
/// <summary> /// If we're hit twice in a row, we get knocked down! /// </summary> /// <param name="attackingPlayer"></param> public override void isHit(BoxingPlayer attackingPlayer, State expectedHitState, int damage) { if (timer <= 0) { // well timed? Duck and weave! if (dodgeTimer > 0) { ChangeState(new StateDodge(player)); attackingPlayer.state.wasDodged(); } else { hitCounter++; PlaySound(player.soundEffects["Hit"]); // play the sound effect! } } if (hitCounter >= 1) { ChangeState(new StateKnockedDown(player, attackingPlayer.direction,true)); player.CurrentHealth -= 20; } }
public StateHit(BoxingPlayer player) : base(player, "PunchHit") { player.input.OnKeyDown += HandleKeyDownInput; }
/// <summary> /// Handles any effects and damage to the hit player /// </summary> /// <param name="hitPlayer">The player hit by this player</param> public virtual void HitOtherPlayer(BoxingPlayer hitPlayer) { //Debug.WriteLine("Hit Player!!!"); }
public StateCanePull(int itemIndex, BoxingPlayer player) : base(player, "CanePull") { isAttack = true; }
public override void LoadState(BoxingPlayer player, Dictionary <string, Animation> ATextures) { //player.soundEffects["Hit"].Play(); // play the sound effect! base.LoadState(player, ATextures); }
public void addBowlerHat(BoxingPlayer p, float multiplier) { itemInstances.Add(new BowlerHatInstance(p, itemAnims, instanceID++, multiplier)); }
// Apply's settings gathered before the boxing begins. public void ApplySettings(Color[] colors, Item[][] equipment) { //Need to make copies of the textures recolored with the players selected color for(int i = 0; i < 4; i++) { // If the color is transparent, the player isn't playing. if (colors[i] != Color.Transparent) { // The players dictionary of animations Dictionary<string, Animation> coloredAnims = new Dictionary<string, Animation>(); Debug.WriteLine("Number of textures to recolor: " + animTextureTemplates.Length); // loop through each template texture and recolor it for(int j = 0; j < animTextureTemplates.Length; j++) { Debug.WriteLine("index = " + j); Texture2D template = animTextureTemplates[j];// template Texture2D t = new Texture2D(graphicsDevice, template.Width, template.Height); //colored Color[] c = new Color[template.Width * template.Height]; template.GetData(c); int count = 0; // Replace magenta pixels with the color for (int k = 0; k < c.Length; k++) { // This is awesome! if (c[k] == Color.Magenta /* || (c[k].R == 254 && c[k].G == 0 && c[k].B == 254) || (c[k].R == 253 && c[k].G == 0 && c[k].B == 253) || (c[k].R == 252 && c[k].G == 0 && c[k].B == 252) || (c[k].R == 251 && c[k].G == 0 && c[k].B == 251) || (c[k].R == 250 && c[k].G == 0 && c[k].B == 250) */) { count++; c[k] = colors[i]; } } t.SetData(c); // set the data // add it to the available list coloredAnims.Add(animKeys[j], new Animation(t,animFrameTimes[j],animLooping[j],animFrameWidths[j])); } players[i] = new BoxingPlayer(this, i, playerStartPositions[i], coloredAnims, inputs[i], colors[i], blank, healthBarDimensions, level.platforms[level.platforms.Length - 1], equipment[i], soundEffects);// defaultItems, soundEffects); // Figure out the boxing players. } } }
public StatePunch(BoxingPlayer player) : base(player, "Punch") { isAttack = true; }
// Find the first player in front of player public BoxingPlayer GetPlayerInFront(BoxingPlayer p, float y, int direction) { BoxingPlayer f = null; float min = 0; for (int i = 0; i < players.Length; i++) { if (players[i] != null && players[i].playerIndex != p.playerIndex && !players[i].isDead) { if (direction == 1 && players[i].position.X > p.position.X && y > players[i].position.Y - players[i].GetHeight && y < players[i].position.Y) { float d = players[i].position.X - p.position.X; if (min == 0 || d < min) { min = d; f = players[i]; } } else if (direction == -1 && players[i].position.X < p.position.X && y > players[i].position.Y - players[i].GetHeight && y < players[i].position.Y) { float d = p.position.X - players[i].position.X; if (min == 0 || d < min) { min = d; f = players[i]; } } } } return f; }
// if you're knocked down, nothing can hit you public override void isHit(BoxingPlayer attackingPlayer, State expectedHitState, int damage) { }
/// <summary> /// Handles any effects to this player. /// </summary> /// <param name="attackingPlayer"></param> public virtual void isHit(BoxingPlayer attackingPlayer, State expectedHitState, int damage) { //Debug.WriteLine("isHit virtual!"); if (attackingPlayer.state.isAttack || attackingPlayer.state is StateRevolverShoot) player.CurrentHealth -= damage; if (player.CurrentHealth <= 0) player.state.ChangeState(new StateKnockedDown(player, attackingPlayer.direction, true)); else player.state.ChangeState(expectedHitState); }
public StateBlock(BoxingPlayer player) : base(player, "Block") { canCombo = true; canCatch = true; }
public virtual void LoadState(BoxingPlayer player, Dictionary<string, Animation> ATextures) { }
public override void LoadState(BoxingPlayer player, Dictionary<string, Animation> ATextures) { //player.soundEffects["Hit"].Play(); // play the sound effect! base.LoadState(player, ATextures); }
public override void LoadState(BoxingPlayer player, Dictionary <string, Animation> ATextures) { //player.soundEffects["Jump"].Play(); // play the sound effect! player.isAirborn = true; base.LoadState(player, ATextures); }
int count = 0; // how many tugs of the cape? public StateCapeStuck(int itemIndex, BoxingPlayer player) : base(player, "CapeStuck") { state = CapeStuckState.draw; }
public State(BoxingPlayer player, string key) { this.player = player; this.key = key; }