public void AddItem(Block Item) { GameSounds.PlayPickSound(); if (Item is MoneySafeKey) { MoneySafeKey doorKey = Item as MoneySafeKey; MoneySafeKey clone = (doorKey.Clone()) as MoneySafeKey; Key = clone; } if (Item is Coin) { Coin coin = Item as Coin; Coin clone = (coin.Clone()) as Coin; AllCoins.Add(clone); } if (Item is Potion) { Potion potion = Item as Potion; Potion clone = (potion.Clone()) as Potion; Potion = clone; } if (Item is MoneySafe) { MoneySafe moneySafe = Item as MoneySafe; MyDiamonds += moneySafe.NumberOfDiamonds; } }
public bool HasWorkingKey(MoneySafe moneySafe) { if (Key != null && Key.MoneySafeID.Equals(moneySafe.KeyID)) { return(true); } return(false); }
private void CreatePickables(ContentManager contentManager) { Texture2D tempTexture = contentManager.Load <Texture2D>("Pickable1"); for (int x = 0; x < MapWidth; x++) { for (int y = 0; y < LevelHeight; y++) { int BLOCK_ID = PickablesArray[y, x]; string ID_STRING = Convert.ToString(BLOCK_ID); if (ID_STRING != "0") { tempTexture = contentManager.Load <Texture2D>("Pickable" + ID_STRING); } const int marginBottom = 10; int maginLeft = (150 - tempTexture.Width) / 2; float xPos = (x * 150) + maginLeft; float yPos = (y * SpaceBetweenPlatforms) - tempTexture.Height - marginBottom; Vector2 tempVector = Factory.CreateVector(xPos, yPos); Rectangle tempCollisonRectangle = Factory.CreateRectangle((int)tempVector.X, (int)tempVector.Y, tempTexture.Width, tempTexture.Height); Sprite tempSprite = Factory.CreateSprite(tempTexture, 1, tempVector); switch (PickablesArray[y, x]) { case 1: MoneySafeKey tempMoneySafeKey = WorldFactory.CreateKey(tempSprite, tempCollisonRectangle, MoneySafeIndentifiers[totalKeys]); AllPickables.Add(tempMoneySafeKey as Block); totalKeys++; break; case 2: Coin tempCoin = WorldFactory.CreateCoin(tempSprite, tempCollisonRectangle); AllPickables.Add(tempCoin); break; case 3: Potion tempPotion = WorldFactory.CreatePotion(tempSprite, tempCollisonRectangle); AllPickables.Add(tempPotion); break; case 4: MoneySafe tempMoneySafe = WorldFactory.CreateSafe(tempSprite, tempCollisonRectangle, MoneySafeIndentifiers[totalMoneySafes]); AllPickables.Add(tempMoneySafe); totalMoneySafes++; break; default: break; } } } }