public void buyShopResultOf(ShopItem shopItem) { float cheeperMultiplier = 1f; if (isCheaper) { cheeperMultiplier = expCheeperShopMultiplier; } switch (shopItem.name) { case "Armor Up": player.GetComponent <Player>().maxHealth += 50; buyShop.GetComponent <Shop>().changePrice(shopItem.name, (int)(shopItem.cost * upgradeAmount * cheeperMultiplier)); break; //set up lazer gun image case "Lazers": player.GetComponent <Player>().weapon = lazerGun.gameObject; buyShop.GetComponent <Shop>().changePrice(shopItem.name, (int)(shopItem.cost * upgradeAmount * cheeperMultiplier)); break; case "Bigger Tank": player.GetComponent <Player>().maxGas += 50; buyShop.GetComponent <Shop>().changePrice(shopItem.name, (int)(shopItem.cost * upgradeAmount * cheeperMultiplier)); break; case "Better Thrusters": player.GetComponent <PlayerController>().maxSpeed += 3; buyShop.GetComponent <Shop>().changePrice(shopItem.name, (int)(shopItem.cost * upgradeAmount * cheeperMultiplier)); break; case "Add Rock Planet": home.GetComponent <Home>().addRockPlanet(); buyShop.GetComponent <Shop>().changePrice(shopItem.name, (int)(shopItem.cost * upgradeAmount * .98f * cheeperMultiplier)); MaxItemsManager.priceOfPlanet = (int)(shopItem.cost * upgradeAmount * .98f * cheeperMultiplier); if (home.GetComponent <Home>().numberOfHomePlanets >= maxHomePlanets) { buyShop.GetComponent <Shop>().RemoveItem(shopItem.name); MaxItemsManager.priceOfPlanet = shopItem.cost; } break; //update to addInventory Slot case "More Inventory": FindObjectOfType <Inventory>().addInventorySlot(); buyShop.GetComponent <Shop>().changePrice(shopItem.name, (int)(shopItem.cost * upgradeAmount * cheeperMultiplier)); if (FindObjectOfType <Inventory>().numberOfInventorySlots == 8) { buyShop.GetComponent <Shop>().RemoveItem(shopItem.name); } break; case "Switch Color": if (whichShipColorBase == playerSprites.Count - 3) { player.GetComponent <SpriteRenderer>().sprite = playerSprites[whichShipLevel]; whichShipColorBase = 0; } else { player.GetComponent <SpriteRenderer>().sprite = playerSprites[whichShipColorBase + 3 + whichShipLevel]; whichShipColorBase += 3; } break; case "Drone": GameObject droneItem = Instantiate(drone); droneItem.transform.position = player.transform.position; break; case "Turret": GameObject turretItem = Instantiate(turret); turretItem.transform.position = player.transform.position; break; case "Decoy": GameObject decoyItem = Instantiate(decoy); decoyItem.transform.position = player.transform.position; break; case "Heal": GameObject healItem = Instantiate(heal); healItem.transform.position = player.transform.position; break; case "Shield": GameObject shieldItem = Instantiate(shield); shieldItem.transform.position = player.transform.position; break; case "Buy Mine": MaxItemsManager.addMine(); mineAmountText.GetComponent <Text>().text = "x" + MaxItemsManager.mineAmount; break; case "Common Crate": GameObject crate = Instantiate(commonCrate); crate.transform.position = crateSpawnPoint.transform.position + new Vector3(0, -10, 0); BM.Broadcast("Your purchased loot crate has been delivered near spawn!"); MaxItemsManager.addLootCrate(); numberOfCommon++; break; case "Rare Crate": GameObject crateRare = Instantiate(rareCrate); crateRare.transform.position = crateSpawnPoint.transform.position + new Vector3(0, -10, 0); BM.Broadcast("Your purchased loot crate has been delivered near spawn!"); MaxItemsManager.addLootCrate(); numberOfRare++; break; case "Legendary Crate": GameObject crateLegendary = Instantiate(legendaryCrate); crateLegendary.transform.position = crateSpawnPoint.transform.position + new Vector3(0, -10, 0); BM.Broadcast("Your purchased loot crate has been delivered near spawn!"); MaxItemsManager.addLootCrate(); numberOfLegendary++; break; //friendly trader shop case "Warp Home Tokens": if (amountOfWarps == 0) { warpHolder.SetActive(true); BM.Broadcast("You can press q to be teleported to home"); } amountOfWarps += 1; warpAmount.text = "x" + amountOfWarps.ToString(); break; case "Buy Gas": player.GetComponent <Player>().gas += player.GetComponent <Player>().maxGas * .1f; if (player.GetComponent <Player>().gas > player.GetComponent <Player>().maxGas) { player.GetComponent <Player>().gas = player.GetComponent <Player>().maxGas; } player.GetComponent <Player>().gasBar.transform.localScale = new Vector3(1 * (player.GetComponent <Player>().gas - player.GetComponent <Player>().maxGas * .1f) / (player.GetComponent <Player>().maxGas - player.GetComponent <Player>().maxGas * .1f), player.GetComponent <Player>().gasBar.transform.localScale.y, player.GetComponent <Player>().gasBar.transform.localScale.z); if (player.GetComponent <Player>().gas <= player.GetComponent <Player>().maxGas * .1f) { player.GetComponent <Player>().gasBarEnd.transform.localScale = new Vector3(-1 * (player.GetComponent <Player>().maxGas * .1f - player.GetComponent <Player>().gas) / (player.GetComponent <Player>().maxGas * .1f), player.GetComponent <Player>().gasBarEnd.transform.localScale.y, player.GetComponent <Player>().gasBarEnd.transform.localScale.z); } break; case "Random Recipe": List <PlanetCombo> randomList = comboList.planetComboList; int randomIndex = Random.Range(0, randomList.Count - 1); PlanetCombo combo = randomList[randomIndex]; int startRandom = randomIndex; while (!alminac.AddEntry(combo.planet.gameObject.GetComponent <SpriteRenderer>().sprite, combo.item1.name, combo.item2.name, combo.item3.name) && !(randomIndex == startRandom - 1)) { randomIndex += 1; combo = randomList[randomIndex]; if (randomIndex == randomList.Count - 1) { randomIndex = -1; } } if (randomIndex == startRandom - 1) { FindObjectOfType <canvas>().friendlyBuyShop.RemoveItem("Random Recipe"); BM.Broadcast("You have bought all of the recipes"); } break; } //buying resources if (listOfResources[0] != null && shopItem.name == listOfResources[0].nameOfResource) { GameObject resourceSpawn = Instantiate(listOfResources[0].gameObject); resourceSpawn.tag = "resource"; resourceSpawn.transform.position = new Vector2(player.transform.position.x, player.transform.position.y); Vector2 velocityDirection = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); while ((velocityDirection.x < .5f && velocityDirection.x > -.5f) && (velocityDirection.y < .5f && velocityDirection.y > -.5f)) { velocityDirection = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); } resourceSpawn.GetComponent <Rigidbody2D>().velocity = velocityDirection; resourceSpawn.GetComponent <Rigidbody2D>().angularVelocity = 720; } else if (listOfResources[1] != null && shopItem.name == listOfResources[1].nameOfResource) { GameObject resourceSpawn = Instantiate(listOfResources[1].gameObject); resourceSpawn.tag = "resource"; resourceSpawn.transform.position = new Vector2(player.transform.position.x, player.transform.position.y); Vector2 velocityDirection = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); while ((velocityDirection.x < .5f && velocityDirection.x > -.5f) && (velocityDirection.y < .5f && velocityDirection.y > -.5f)) { velocityDirection = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); } resourceSpawn.GetComponent <Rigidbody2D>().velocity = velocityDirection; resourceSpawn.GetComponent <Rigidbody2D>().angularVelocity = 720; } else if (listOfResources[2] != null && shopItem.name == listOfResources[2].nameOfResource) { GameObject resourceSpawn = Instantiate(listOfResources[2].gameObject); resourceSpawn.tag = "resource"; resourceSpawn.transform.position = new Vector2(player.transform.position.x, player.transform.position.y); Vector2 velocityDirection = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); while ((velocityDirection.x < .5f && velocityDirection.x > -.5f) && (velocityDirection.y < .5f && velocityDirection.y > -.5f)) { velocityDirection = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); } resourceSpawn.GetComponent <Rigidbody2D>().velocity = velocityDirection; resourceSpawn.GetComponent <Rigidbody2D>().angularVelocity = 720; } }