protected override void Initialize() { base.Initialize(); gameOverlay = new GameOverlay(textureHandler); gameOverlay.Initialize(); tileMap = new TileMap(textureHandler.tileMapTexture); camera = new Camera(GraphicsDevice.Viewport, tileMap); sceneObjectHandler = new SceneObjectHandler(tileMap); player = new Player(textureHandler.playerTexture, tileMap, sceneObjectHandler, gameOverlay); enemies = new List <Enemy>(); List <Vector2> enemySpawns = tileMap.GetEnemySpawns(); foreach (Vector2 pos in enemySpawns) { enemies.Add(new Enemy(pos, textureHandler.enemyTexture, tileMap)); } sceneObjectHandler.AddObject(new Pickup_Ranged(tileMap.GetPXPosition(new Vector2(3, 3)), textureHandler.gunTexture, textureHandler.bulletTexture, textureHandler.tempGun, 20.0f, 20.0f, 6)); sceneObjectHandler.AddObject(new Pickup_Melee(tileMap.GetPXPosition(new Vector2(5, 3)), textureHandler.healthTexture, textureHandler.swordTexture, 20.0f, 15f, Pickup_Melee.AttackType.SWING)); sceneObjectHandler.AddObject(new Pickup_Melee(tileMap.GetPXPosition(new Vector2(5, 5)), textureHandler.no_imageTexture, textureHandler.swordTexture, 20.0f, 15f, Pickup_Melee.AttackType.STAB)); sceneObjectHandler.AddObject(new StatBoost(tileMap.GetPXPosition(new Vector2(7, 3)), textureHandler.speedTexture, 1.5f, StatBoost.StatType.SPEED)); }
public void PickupItem(Item item) { Type itemType = item.GetType(); Item oldItem = null; if (itemType == typeof(Pickup_Melee) && heldItemManager.meleeHandler.GetCurrentItem() != null) { oldItem = heldItemManager.meleeHandler.GetCurrentItem(); } else if (itemType == typeof(Pickup_Ranged) && heldItemManager.rangedHandler.GetCurrentItem() != null) { oldItem = heldItemManager.rangedHandler.GetCurrentItem(); } objectHandler.RemoveObject(item); if (oldItem != null) { oldItem.SetXPosition(item.GetPosition().X); oldItem.SetYPosition(item.GetPosition().Y); oldItem.UpdateCollisionBounds(); objectHandler.AddObject(oldItem); } //pickup new heldItemManager.PickupItem(item); overlay.UpdateWeaponDisplay(this); if (itemType == typeof(StatBoost)) { StatBoost.StatType type = ((StatBoost)item).GetStatType(); if (type == StatBoost.StatType.SPEED) { speedMultiplier += ((StatBoost)item).GetStatChange(); } } }