public Player createCharacter(String CharacterId, ContentManager content, int playerNumber, ComboManager comboManager, ThrowManager throwManager, SuperManager superManager, ProjectileManager projectileManager) { Player player; int xPosition; int healthBarMargin; Texture2D healthBar = content.Load <Texture2D>("healthBar1"); Texture2D healthOuterBar = content.Load <Texture2D>("HealthBar_empty"); Texture2D specialBar = content.Load <Texture2D>("specialbar2"); Texture2D specialOuterBar = content.Load <Texture2D>("Special_4split_empty"); Direction direction; if (playerNumber == 1) { xPosition = Config.Instance.Player1XPosition; healthBarMargin = ((Config.Instance.ScreenWidth / 2) - 600) / 2; direction = Direction.Right; } else { xPosition = Config.Instance.Player2XPosition; healthBarMargin = (((Config.Instance.ScreenWidth / 2) - 600) / 2) + (Config.Instance.ScreenWidth / 2); direction = Direction.Left; } Gauge HealthBar = new Gauge(healthBar, 20, healthBarMargin, playerNumber, 10, new Rectangle(0, 0, 1276, 150)); HealthBar.OuterBarTexture = healthOuterBar; if (CharacterId.Equals("LongSword")) { player = new LongSwordPlayer(playerNumber, xPosition, Config.Instance.PlayerYHeight, comboManager, throwManager, HealthBar); } else if (CharacterId.Equals("HuntingHorn")) { player = new HuntingHornPlayer(playerNumber, xPosition, Config.Instance.PlayerYHeight + 50, comboManager, throwManager, HealthBar); } else { player = new LongSwordPlayer(playerNumber, xPosition, Config.Instance.PlayerYHeight, comboManager, throwManager, HealthBar); } player.SuperManager = superManager; player.ProjectileManager = projectileManager; player.Sprite.dummyTexture = DummyTexture; player.SpecialBar = new Gauge(specialBar, 675, healthBarMargin + 90, playerNumber, 15, new Rectangle(0, 0, 934, 68)); player.SpecialBar.CurrentAmount = 100; player.SpecialBar.MaxAmount = 100; player.SpecialBar.OuterBarTexture = specialOuterBar; player.Direction = direction; player.setUpGauges(content, healthBarMargin + 90); loadCharacterDataConfigs(CharacterId, player, content); loadParticles(CharacterId, player, content); player.SetUpUniversalAttackMoves(); return(player); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { cam = new Camera2d(Config.Instance.GameWidth, Config.Instance.ScreenWidth, Config.Instance.GameHeight, Config.Instance.ScreenHeight); cam.Pos = new Vector2(512.0f, 360.0f); mainFrame = new Rectangle(-450, 0, 2400, Config.Instance.GameHeight); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); spriteFont = Content.Load <SpriteFont>("testf"); comboManager = new ComboManager(spriteFont); BGMManager bgmManager = new BGMManager(Content); projectileManager = new ProjectileManager(Content); throwManager = new OneButtonThrowManager(); superManager = new BasicSuperManager(cam); menuBg = Content.Load <Texture2D>("bg2"); dummyTexture = new Texture2D(GraphicsDevice, 1, 1); dummyTexture.SetData(new Color[] { Color.White }); testHitbox = new Rectangle(100, 100, 100, 100); testHitInfo = new HitInfo(3, 20, Hitzone.HIGH); testHitInfo.IsHardKnockDown = true; testHitInfo.AirUntechTime = 8000; testHitInfo.AirXVelocity = 80; testHitInfo.AirYVelocity = -100; effect = Content.Load <SoundEffect>("slap_large"); characterSelection = new CharacterSelectList(Content); player1CharacterId = "HuntingHorn"; PlayerFactory playerFactory = new PlayerFactory(); playerFactory.DummyTexture = dummyTexture; player1 = (HuntingHornPlayer)playerFactory.createCharacter(player1CharacterId, Content, 1, comboManager, throwManager, superManager, projectileManager); //player1.Sprite.a roundManager = new RoundManager(player1, player2); animationsList = player1.Sprite.AnimationsList; player1.Sprite.CurrentAnimation = animationsList[index]; player1.Sprite.CurrentAnimation = "hit"; player1.ProjectileA.CurrentAnimation = "note1"; }
public LongSwordPlayer(int playerNumber, int xPosition, int yHeight, ComboManager comboManager, ThrowManager throwManager, Gauge healthBar) : base(playerNumber, xPosition, yHeight, comboManager, throwManager, healthBar) { CurrentHealth = 1000; MaxHealth = 1000; DisplayShadow = false; // D mechanic related moves // SwordLevel = 1; SwordGaugeGains = new Dictionary <String, int>(); MoveCosts = new Dictionary <String, int>(); SwordGaugeGains.Add("aattack", 5); SwordGaugeGains.Add("battack", 10); SwordGaugeGains.Add("cattack", 15); SwordGaugeGains.Add("2aattack", 5); SwordGaugeGains.Add("2battack", 10); SwordGaugeGains.Add("2cattack", 15); SwordGaugeGains.Add("jaattack", 5); SwordGaugeGains.Add("jbattack", 10); SwordGaugeGains.Add("jcattack", 15); // MoveCosts.Add("battack", 10); MoveCosts.Add("backfireball", 0); MoveCosts.Add("rekka", 0); MoveCosts.Add("rekkaB", 0); MoveCosts.Add("rekkaC", 0); Sprite.BoundingBoxHeight = 288; Sprite.BoundingBoxWidth = 90; // Essentially how many rekkas we've done // rekkaLevel = 1; // TODO make these have to be set for every character. // ThrowRange = 200; BackAirDashVel = 8; AirDashVel = 13; BackStepVel = 13; DashVel = 8; BackWalkVel = 3; WalkVel = 4; // projectile = new ProjectileAnimation(texture, X, Y, Width, Height, Frames, columns, frameLength, characterState, timeLength, direction); }
public Player(int playerNumber, int xPosition, int yHeight, ComboManager comboManager, ThrowManager throwManager, Gauge healthBar) { sprite = new SpriteAnimationManager(); PlayerNumber = playerNumber; Position = new Vector2(xPosition, Config.Instance.GroundYHeight - yHeight); startingPosition = new Vector2(xPosition, Config.Instance.GroundYHeight - yHeight); ComboManager = comboManager; ThrowManager = throwManager; specialInputManager = new SpecialInputManager(); SoundManager = new SoundManager(); ControlSetting = new ControlSetting(); InputMoveBuffer = new InputMoveBuffer(); IsPhysical = true; HealthBar = healthBar; }
public HuntingHornPlayer(int playerNumber, int xPosition, int yHeight, ComboManager comboManager, ThrowManager throwManager, Gauge healthBar) : base(playerNumber, xPosition, yHeight, comboManager, throwManager, healthBar) { CurrentHealth = 1000; MaxHealth = 1000; Sprite.BoundingBoxHeight = 288; Sprite.BoundingBoxWidth = 90; // TODO make these have to be set for every character. // ThrowRange = 200; BackAirDashVel = 8; AirDashVel = 13; BackStepVel = 12; DashVel = 11; BackWalkVel = 3; WalkVel = 4; // projectile = new ProjectileAnimation(texture, X, Y, Width, Height, Frames, columns, frameLength, characterState, timeLength, direction); }
public virtual Boolean hitByEnemy(KeyboardState keyState, HitInfo hitInfo, Rectangle collisionZone) { //Check if blocked or not //int hitStun, int blockStun, Hitzone hitzone, float? xVel, float? yVel if (!hitInfo.Unblockable && (Sprite.CurrentMoveAnimation.CharacterState != CharacterState.HIT || Sprite.CurrentAnimation.Contains("block")) && !Sprite.CurrentMoveAnimation.IsAttack && isAttackBlocked(keyState, hitInfo.Hitzone)) { if (Sprite.CurrentMoveAnimation.CharacterState == CharacterState.AIRBORNE) { Sprite.CurrentAnimation = "airblock"; } else if (Sprite.CurrentMoveAnimation.CharacterState == CharacterState.CROUCHING) { Sprite.CurrentAnimation = "crouchblock"; } else { Sprite.CurrentAnimation = "block"; } HitAnimation block = (HitAnimation)Sprite.CurrentMoveAnimation; Console.WriteLine("DID A BLOCK!"); block.reset(); block.HitStunCounter = hitInfo.Blockstun; Console.WriteLine(block.HitStunCounter); ProjectileManager.createHitparticle(collisionZone, HitType.BLOCK); return(false); } else { ProjectileManager.createHitparticle(collisionZone, hitInfo.HitType); // So many different ways to get hit // if (Sprite.CurrentMoveAnimation.CharacterState == CharacterState.CROUCHING) { Sprite.CurrentAnimation = "crouchhit"; } else if (hitInfo.Hitzone == Hitzone.LOW) { Sprite.CurrentAnimation = "lowhit"; } else { Sprite.CurrentAnimation = "hit"; } Sprite.CurrentMoveAnimation.CurrentFrame = Sprite.CurrentMoveAnimation.StartFrame; CurrentHealth -= ComboManager.calculateProratedDamage(hitInfo); if (hitInfo.FreezeOpponent) { Sprite.CurrentAnimation = "freeze"; } else { // Not sure if this a bad idea memory wise // HitAnimation hit = (HitAnimation)Sprite.CurrentMoveAnimation; hit.HitStunCounter = ComboManager.calculateProratedHitStun(hitInfo); hit.reset(); if (CurrentHealth <= 0) { hitInfo = new HitInfo(100, 10, Hitzone.MID); hitInfo.AirXVelocity = 300; hitInfo.AirYVelocity = -100; } if (IsAirborne || hitInfo.ForceAirborne || CurrentHealth <= 0) { untechTime = hitInfo.AirUntechTime; Sprite.CurrentAnimation = "falldown"; Position += new Vector2(0, -10); if (hitInfo.AirXVelocity != null && hitInfo.AirYVelocity != null) { if (directionFacing == Direction.Right) { CurrentVelocity = new Vector2((float)-hitInfo.AirXVelocity, (float)hitInfo.AirYVelocity); } else { CurrentVelocity = new Vector2((float)hitInfo.AirXVelocity, (float)hitInfo.AirYVelocity); } } } else { GivePlayerMomentum(5, 4, false); if (hitInfo.IsHardKnockDown) { // Make em HARD DOWN // Sprite.CurrentAnimation = "knockdown"; } } } ComboManager.registerHit(hitInfo); return(true); } }
public void checkHitOnPlayers(Player player1, Player player2, ComboManager comboManager, RoundManager roundManager, KeyboardState Keyboard, GameState gameState) { for (int i = player1Projectiles.Count - 1; i >= 0; i--) { Projectile projectile = player1Projectiles[i]; if (projectile.Hitbox.Intersects(player2.Sprite.Hurtbox)) { if (projectile.NumOfHits > 0) { Rectangle collisionZone = Rectangle.Intersect(projectile.Hitbox, player2.Sprite.Hurtbox); comboManager.player1LandedHit(player2.CharacterState); Boolean hitEnemy = player2.hitByEnemy(Keyboard, projectile.CurrentProjectile.HitInfo, collisionZone); player1.hitEnemy(hitEnemy); projectile.hitEnemy(); } else { if (!projectile.PlayOnce) { player1Projectiles.RemoveAt(i); } } System.Diagnostics.Debug.WriteLine("We have projectile 1 collision at " + projectile.CurrentProjectile.CurrentFrame); if (player2.CurrentHealth <= 0) { roundManager.roundEnd(1); gameState = GameState.ROUNDEND; } } } for (int j = player2Projectiles.Count - 1; j >= 0; j--) { Projectile projectile = player2Projectiles[j]; if (projectile.Hitbox.Intersects(player1.Sprite.Hurtbox)) { if (projectile.NumOfHits > 0) { Rectangle collisionZone = Rectangle.Intersect(projectile.Hitbox, player1.Sprite.Hurtbox); comboManager.player2LandedHit(player1.CharacterState); Boolean hitEnemy = player1.hitByEnemy(Keyboard, projectile.CurrentProjectile.HitInfo, collisionZone); player2.hitEnemy(hitEnemy); projectile.hitEnemy(); } else { if (!projectile.PlayOnce) { player2Projectiles.RemoveAt(j); } } System.Diagnostics.Debug.WriteLine("We have projectile collision at " + projectile.CurrentProjectile.CurrentFrame); if (player1.CurrentHealth <= 0) { roundManager.roundEnd(2); gameState = GameState.ROUNDEND; } } } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { cam = new Camera2d(Config.Instance.GameWidth, Config.Instance.ScreenWidth, Config.Instance.GameHeight, Config.Instance.ScreenHeight); layers = new List <Layer> { new Layer(cam) { Parallax = new Vector2(0.2f, 1.0f) }, new Layer(cam) { Parallax = new Vector2(0.3f, 1.0f) }, new Layer(cam) { Parallax = new Vector2(0.4f, 1.0f) }, new Layer(cam) { Parallax = new Vector2(0.8f, 1.0f) }, new Layer(cam) { Parallax = new Vector2(1.0f, 1.0f) }, new Layer(cam) { Parallax = new Vector2(1.0f, 1.0f) } }; Texture2D test = Content.Load <Texture2D>("new_groundplane"); layers[0].Sprites.Add(new BackgroundObject { texture = Content.Load <Texture2D>("background"), mainFrame = new Rectangle(-100, 0, 2200, Config.Instance.GameHeight) }); layers[1].Sprites.Add(new BackgroundObject { texture = Content.Load <Texture2D>(@"main_castle"), mainFrame = new Rectangle(-100, 275, 2200, Config.Instance.GameHeight - 300) }); layers[2].Sprites.Add(new BackgroundObject { texture = Content.Load <Texture2D>(@"midground"), mainFrame = new Rectangle(-100, 100, 2200, Config.Instance.GameHeight) }); //layers[3].Sprites.Add(new BackgroundObject { texture = Content.Load<Texture2D>(@"foreground"), mainFrame = new Rectangle(-100, 0, 2200, Config.Instance.GameHeight) }); layers[4].Sprites.Add(new BackgroundObject { texture = Content.Load <Texture2D>(@"new_groundplane"), mainFrame = new Rectangle(500, 0, 2200, Config.Instance.GameHeight) }); //cam.Pos = new Vector2(Config.Instance.GameWidth/2, 360.0f); mainFrame = new Rectangle(-150, -450, 2200, Config.Instance.GameHeight); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); spriteFont = Content.Load <SpriteFont>("slant"); ingameFont = Content.Load <SpriteFont>("arvil"); comboManager = new ComboManager(ingameFont); BGMManager bgmManager = new BGMManager(Content); projectileManager = new ProjectileManager(Content); throwManager = new OneButtonThrowManager(); superManager = new BasicSuperManager(cam); //background = Content.Load<Texture2D>("background"); //background2 = Content.Load<Texture2D>("main_castle"); menuBg = Content.Load <Texture2D>("bg2"); victoryDots = Content.Load <Texture2D>("winDots"); dummyTexture = new Texture2D(GraphicsDevice, 1, 1); dummyTexture.SetData(new Color[] { Color.White }); testHitbox = new Rectangle(100, 100, 100, 100); testHitInfo = new HitInfo(3, 20, Hitzone.HIGH); testHitInfo.IsHardKnockDown = true; testHitInfo.AirUntechTime = 8000; testHitInfo.AirXVelocity = 80; testHitInfo.AirYVelocity = 2; effect = Content.Load <SoundEffect>("hit_3"); hit2 = Content.Load <SoundEffect>("hit_4"); slash = Content.Load <SoundEffect>("stab_1"); slash2 = Content.Load <SoundEffect>("stab_2"); strum = Content.Load <SoundEffect>("strum_1"); //MediaPlayer.Play(bgmManager.getRandomBGM()); //MediaPlayer.Volume = 0.4f; player1Controls.setControl("down", Keys.Down); player1Controls.setControl("right", Keys.Right); player1Controls.setControl("left", Keys.Left); player1Controls.setControl("up", Keys.Up); player1Controls.setControl("a", Keys.A); player1Controls.setControl("b", Keys.S); player1Controls.setControl("c", Keys.D); player1Controls.setControl("d", Keys.Z); player1Controls.setControl("start", Keys.Enter); player2Controls.setControl("down", Keys.K); player2Controls.setControl("right", Keys.L); player2Controls.setControl("left", Keys.J); player2Controls.setControl("up", Keys.I); player2Controls.setControl("a", Keys.F); player2Controls.setControl("b", Keys.G); player2Controls.setControl("c", Keys.H); player2Controls.setControl("d", Keys.V); player2Controls.setControl("start", Keys.End); characterSelection = new CharacterSelectList(Content); gameState = GameState.MAINMENU; player1CharacterId = "LongSword"; player2CharacterId = "HuntingHorn"; pauseMenu = new PauseMenu(spriteFont); pressStart = Content.Load <Texture2D>("press_start"); mainMenu = new MainMenu(spriteFont, pressStart); titleScreen = Content.Load <Texture2D>("Rising_Force_Title"); loadingScreen = Content.Load <Texture2D>("VS_Screen"); demoEndScreen = Content.Load <Texture2D>("thank_you"); player1NamePlate = Content.Load <Texture2D>("Liara_game_text"); player2NamePlate = Content.Load <Texture2D>("Aydin_game_text"); }