public IObject getDrops(IEnemy enemy) { Random randomNumber = new Random(); int dropNum = randomNumber.Next(18); int[] rupee = { 1, 3, 6, 7 }; int[] bomb = { 0, 5, 8 }; int[] heart = { 2, 4, 9 }; Rectangle enemyRect = enemy.getDestRect(); Vector2 position = new Vector2(enemyRect.X, enemyRect.Y); Texture2D itemSprites = sprites["itemset"]; IObject drop = null; if (enemy.getHealth() <= 0) { if (rupee.Contains(dropNum)) { drop = new RupeeItem(itemSprites, position); } else if (bomb.Contains(dropNum)) { drop = new BombItem(itemSprites, position); } else if (heart.Contains(dropNum)) { drop = new HeartItem(itemSprites, position); } } return(drop); }
public ISprite CreateBombItem(SpriteBatch spriteBatch, Vector2 startingPos, bool kept, bool resetKept) { IItem add = new BombItem(spriteBatch, textures["bomb"], startingPos, kept, resetKept); RoomItems.Instance.AddItem(add); return(add); }
void CheckCollision(Collider other) { if (!IsOperationable) { return; } ObstacleItem obstacle = other.gameObject.GetComponent <ObstacleItem>(); if (obstacle != null) { if (energySkillCdController.Active) { energySkillCdController.Active = false; } else { GameControl.Instance.GameOver(); } return; } BombItem bombItem = other.gameObject.GetComponent <BombItem>(); if (bombItem != null) { bombItem.Trigger(); return; } bool eat = false; EnergyItem energyItem = other.gameObject.GetComponent <EnergyItem> (); if (energyItem != null) { energyValueController.AddValue(energyItem.Value); eat = true; } MassItem massItem = other.gameObject.GetComponent <MassItem>(); if (massItem != null) { Config config = Config.Instance; if (_massItem.Value >= massItem.Value * config.absorbLimit) { // eat it _massItem.Value += massItem.Value * config.absorbRate; eat = true; } } if (eat) { GameControl.Instance.RemoveItem(other.gameObject); } }
private void AddDroppedItem(Point location) { var rand = _rnd.Next(100); if (rand < 25) { return; // No drop = 25% } IItem item; rand = _rnd.Next(11); switch (rand) { case 0: case 1: case 7: item = new Rupee(location); break; case 2: case 3: case 8: item = new DroppedHeart(location); break; case 4: item = new Rupee5(location); break; case 5: case 9: item = new BombItem(location); break; case 6: item = new Key(location, _room); break; default: item = new Fairy(location); break; } _items.Add(item); }
private void AddDroppedItem(Point location) { var rand = _rnd.Next(100); if (rand < 50) { return; // No drop = 50% } IItem item; rand = _rnd.Next(5); switch (rand) { case 0: item = new Rupee(location); // 1 Rupee = 10% break; case 1: item = new DroppedHeart(location); // Dropped Heart = 10% break; case 2: item = new Rupee5(location); // 5 Rupee = 10% break; case 3: item = new BombItem(location); // Bomb = 10% break; default: item = new Fairy(location); // Fairy = 10% break; } _items.Add(item); }
public UseBombCommand(ILink player, BombItem bomb) { Link = (IPlayer)player; Bomb = bomb; }
void addItem(String line) { String[] split = line.Split(','); IObject item; float x = ((Int32.Parse(split[1]) - 1) * blockBaseDimension * blockSizeMod) + screenX + (2 * blockBaseDimension * blockSizeMod); float y = ((Int32.Parse(split[2]) - 1) * blockBaseDimension * blockSizeMod) + screenY + (2 * blockBaseDimension * blockSizeMod); switch (split[0]) { case "bomb": item = new BombItem(sprites["itemset"], new Vector2(x, y)); break; case "boomerang": item = new BoomerangItem(sprites["itemset"], new Vector2(x, y)); break; case "bow": item = new BowItem(sprites["itemset"], new Vector2(x, y)); break; case "clock": item = new ClockItem(sprites["itemset"], new Vector2(x, y)); break; case "compass": item = new CompassItem(sprites["itemset"], new Vector2(x, y)); break; case "fairy": item = new FairyItem(sprites["itemset"], new Vector2(x, y)); break; case "heart": item = new HeartItem(sprites["itemset"], new Vector2(x, y)); break; case "key": item = new KeyItem(sprites["itemset"], new Vector2(x, y)); break; case "map": item = new MapItem(sprites["itemset"], new Vector2(x, y)); break; case "permanentheart": item = new PermanentHeartItem(sprites["itemset"], new Vector2(x, y)); break; case "rupee": item = new RupeeItem(sprites["itemset"], new Vector2(x, y)); break; case "triforce": item = new TriforceItem(sprites["itemset"], new Vector2(x + 24, y + 8)); break; default: item = null; break; } Items.Add(item); }
public override void UnBoom() { base.UnBoom(); _item = new BombItem(X, Y, _bombNum); }