private Fighter GetFighter(Vector2 pos, Texture2D overlay, FighterInput input, bool flip, String type) { switch (type) { case ("wasp"): float speed = .7f; double health = 100; double power = 10; var waspIdle = LoadAnim("waspIdle"); var waspPunch = LoadAnim("waspPunch"); var waspRecoil = LoadAnim("waspRecoil"); List<HitBox.HitBoxFrame> hitFrames = new List<HitBox.HitBoxFrame>(); hitFrames.Add(new HitBox.HitBoxFrame(waspPunch.GetNumFrames() / waspPunch.GetFps(), new Rectangle(waspPunch.GetWidth(), 50, 10, 10), power)); var punch = new HitBox(p1, Load<SoundEffect>("Audio/waspPunch"), hitFrames); //Gets null for p1 return new Fighter(pos, overlay, waspIdle, waspPunch, waspRecoil, input, punch, flip, speed, health, power); case ("beetle"): float speed2 = .4f; double health2 = 100; double power2 = 11; var beetleIdle = LoadAnim("beetleIdle"); var beetlePunch = LoadAnim("beetlePunch"); var beetleRecoil = LoadAnim("beetleRecoil"); List<HitBox.HitBoxFrame> hitFrames2 = new List<HitBox.HitBoxFrame>(); hitFrames2.Add(new HitBox.HitBoxFrame(beetlePunch.GetNumFrames(), new Rectangle(beetlePunch.GetWidth(), 50, 10, 10), power2)); var punch2 = new HitBox(p2, Load<SoundEffect>("Audio/beetlePunch"), hitFrames2); //Gets null for p2, fix is below return new Fighter(pos, overlay, beetleIdle, beetlePunch, beetleRecoil, input, punch2, flip, speed2, health2, power2); } return null; }
public override void OnCollision(GameObject other, Direction dir) { if (other is HitBox && invulnTime <= 0) { HitBox h = (HitBox)other; if (h.parent != this) { Audio.GetInstance().Play(h.GetNoise()); this.Health -= h.GetDamage(); invulnTime = 700; recoilAnim.Reset(); gettingPunched = true; } } if (other is Fighter) { switch (dir) { case Direction.N: Vel = new Vector2(Vel.X, Math.Max(Vel.Y, 0)); // ResetPosY(); break; case Direction.E: Vel = new Vector2(Math.Max(Vel.X, 0), Vel.Y); //ResetPosX(); break; case Direction.S: Vel = new Vector2(Vel.X, Math.Min(Vel.Y, 0)); // ResetPosY(); break; case Direction.W: Vel = new Vector2(Math.Min(Vel.X, 0), Vel.Y); //ResetPosX(); break; } } }
public Fighter(Vector2 pos, Texture2D overlay_, AnimatedTexture2D idleAnim_, AnimatedTexture2D punchAnim_, AnimatedTexture2D recoilAnim_, FighterInput input_, HitBox punch_, bool flip_, float speed_, double health_, double power_) : base(pos) { idleAnim = idleAnim_; punchAnim = punchAnim_; recoilAnim = recoilAnim_; Vector2 ov = getOverlayPos(); overlay = new Image((int) ov.X, (int) ov.Y, overlay_); input = input_; flip = flip_; speed = speed_; Health = health_; Power = power_; punch = punch_; invulnTime = 0; punching = false; gettingPunched = false; punch.parent = this; }
public Fighter(Vector2 pos, Texture2D overlay_, AnimatedTexture2D idleAnim_, AnimatedTexture2D punchAnim_, AnimatedTexture2D recoilAnim_, FighterInput input_, HitBox punch_, bool flip_, float speed_, double health_, double power_) : base(pos) { idleAnim = idleAnim_; punchAnim = punchAnim_; recoilAnim = recoilAnim_; Vector2 ov = getOverlayPos(); overlay = new Image((int)ov.X, (int)ov.Y, overlay_); input = input_; flip = flip_; speed = speed_; Health = health_; Power = power_; punch = punch_; invulnTime = 0; punching = false; gettingPunched = false; punch.parent = this; }