IEnumerator PowerUpTimer(float _coolDown, AddPowerUp _powerUp) { float currentCD = _coolDown; _powerUp.ApplyPowerUp(); while (currentCD > 0) { yield return(new WaitForSeconds(1f)); currentCD--; } _powerUp.ResetStat(); }
void DoInput() { if (!pc.readInput) { if (inputDelayTimerPlayerOne > 0) { inputDelayTimerPlayerOne -= Time.deltaTime; } if (Input.GetKeyDown(KeyCode.F2)) { for (int i = 0; i < itemInstanceList.Count; i++) { print(itemInstanceList[i].gameObject.name); } } if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown("Bomb" + pc.playerIndex)) { print(soldItems.Count); pc.readInput = true; if (soldItems.Count > 0) { Instantiate(powerUpEffect, pc.transform); } if (soldItems.Count != 0) { for (int i = 0; i < soldItems.Count; i++) { itemList.Remove(itemList[soldItems[i]]); } } foreach (GameObject go in GameObject.FindGameObjectsWithTag("ShopItemUI")) { Destroy(go); } itemInstanceList.Clear(); shopFramePlayerOne.GetComponent <Image>().rectTransform.position = framePosPlayerOne; shopCanvas.SetActive(false); active = false; iconsActive = false; newPosPlayerOne = new Vector3(-524, -422, 0); highLightedItemPlayerOne = 0; soldItems.Clear(); } if (Input.GetAxisRaw("Horizontal1") > 0 && highLightedItemPlayerOne < itemList.Count - 1 && inputDelayTimerPlayerOne <= 0 || Input.GetButtonDown("Right1") && highLightedItemPlayerOne < itemList.Count - 1 && inputDelayTimerPlayerOne <= 0) { highLightedItemPlayerOne++; shopFramePlayerOne.transform.position = ItemSpotsPlayerOne[highLightedItemPlayerOne].GetComponent <RectTransform>().position; inputDelayTimerPlayerOne = inputDelayTimerStart; AudioSource.PlayClipAtPoint(scrollSFX, new Vector3(7, 8, -10), 1.0f); UpdateText(); } else if (Input.GetAxisRaw("Horizontal1") < 0 && highLightedItemPlayerOne > 0 && inputDelayTimerPlayerOne <= 0 || Input.GetButtonDown("Left1") && highLightedItemPlayerOne > 0 && inputDelayTimerPlayerOne <= 0) { highLightedItemPlayerOne--; shopFramePlayerOne.transform.position = ItemSpotsPlayerOne[highLightedItemPlayerOne].GetComponent <RectTransform>().position; inputDelayTimerPlayerOne = inputDelayTimerStart; AudioSource.PlayClipAtPoint(scrollSFX, new Vector3(7, 8, -10), 1.0f); UpdateText(); } else if (Input.GetAxisRaw("Vertical1") > 0 && highLightedItemPlayerOne > 2 && inputDelayTimerPlayerOne <= 0 || Input.GetButtonDown("Up1") && highLightedItemPlayerOne > 2 && inputDelayTimerPlayerOne <= 0) { highLightedItemPlayerOne -= 3; shopFramePlayerOne.transform.position = ItemSpotsPlayerOne[highLightedItemPlayerOne].GetComponent <RectTransform>().position; inputDelayTimerPlayerOne = inputDelayTimerStart; AudioSource.PlayClipAtPoint(scrollSFX, new Vector3(7, 8, -10), 1.0f); UpdateText(); } else if (Input.GetAxisRaw("Vertical1") < 0 && highLightedItemPlayerOne < itemList.Count - 3 && inputDelayTimerPlayerOne <= 0 || Input.GetButtonDown("Down1") && highLightedItemPlayerOne < itemList.Count - 3 && inputDelayTimerPlayerOne <= 0) { highLightedItemPlayerOne += 3; shopFramePlayerOne.transform.position = ItemSpotsPlayerOne[highLightedItemPlayerOne].GetComponent <RectTransform>().position; inputDelayTimerPlayerOne = inputDelayTimerStart; AudioSource.PlayClipAtPoint(scrollSFX, new Vector3(7, 8, -10), 1.0f); UpdateText(); } else if (Input.GetKeyDown(KeyCode.LeftControl) && !itemInstanceList[highLightedItemPlayerOne].GetComponent <ShopItem>().sold || Input.GetButtonDown("Confirm" + pc.playerIndex) && !itemInstanceList[highLightedItemPlayerOne].GetComponent <ShopItem>().sold) { if (itemInstanceList[highLightedItemPlayerOne] != null) { if (pc.money >= itemList[highLightedItemPlayerOne].GetComponent <ShopItem>().itemCost) { soldItems.Add(highLightedItemPlayerOne); //AddScript(itemInstanceList[highLightedItemPlayerOne].gameObject.GetComponent<ShopItem>().itemScript); //Have a look at how to check for certain power-ups. print(itemList[highLightedItemPlayerOne]); AudioSource.PlayClipAtPoint(purchaseAcceptedSFX, new Vector3(7, 8, -10), 1.0f); AddPowerUp.AddPowerUpScript(itemInstanceList[highLightedItemPlayerOne].gameObject.GetComponent <ShopItem>().itemScript, itemList[highLightedItemPlayerOne], pc.gameObject); pc.money -= itemInstanceList[highLightedItemPlayerOne].gameObject.GetComponent <ShopItem>().itemCost; itemInstanceList[highLightedItemPlayerOne].gameObject.GetComponent <Image>().sprite = soldSpr; itemInstanceList[highLightedItemPlayerOne].gameObject.GetComponent <ShopItem>().dialougeText = soldDialouge; itemInstanceList[highLightedItemPlayerOne].gameObject.GetComponent <ShopItem>().itemDescription = soldDescription; moneyTextPlayerOne.text = "Money: " + pc.money.ToString(); itemInstanceList[highLightedItemPlayerOne].GetComponent <ShopItem>().sold = true; dialougeText.text = itemInstanceList[highLightedItemPlayerOne].gameObject.GetComponent <ShopItem>().dialougeText; itemDescriptionTextPlayerOne.text = itemInstanceList[highLightedItemPlayerOne].gameObject.GetComponent <ShopItem>().itemDescription = soldDescription; } else if (pc.money <= itemList[highLightedItemPlayerOne].GetComponent <ShopItem>().itemCost) { AudioSource.PlayClipAtPoint(purchaseDeniedSFX, new Vector3(7, 8, -10), 1.0f); dialougeText.text = "You trying to cheat me you little bastard??? NOT ENOUGH CASH! Comprende?"; } } } } }
void DoInput2() { if (!pc2.readInput) { if (inputDelayTimerPlayerTwo > 0) { inputDelayTimerPlayerTwo -= Time.deltaTime; } //if (Input.GetKeyDown(KeyCode.F2)) //{ // for (int i = 0; i < itemInstanceList.Count; i++) // { // print(itemInstanceList[i].gameObject.name); // } //} if (/*Input.GetKeyDown(KeyCode.Escape) || */ Input.GetButtonDown("Bomb" + pc2.playerIndex)) { //DO THIS FOR BOTH PLAYERS!!!!! pc.readInput = true; pc2.readInput = true; if (soldItems.Count > 0) { Instantiate(powerUpEffect, pc.transform); } if (soldItems2.Count > 0) { Instantiate(powerUpEffect, pc2.transform); } //if (soldItems.Count != 0) //{ // for (int i = 0; i < soldItems.Count; i++) // { // for (int j = 0; j < itemList.Count; j++) // { // if (soldItems[i].name == itemList[j].name) // { // itemList.RemoveAt(j); // } // } // } //} //if (soldItems2.Count != 0) //{ // for (int i = 0; i < itemList2.Count; i++) // { // for (int j = 0; j < soldItems2.Count; j++) // { // if (soldItems2[j].name == itemList2[i].name) // { // itemList2.RemoveAt(i); // } // } // } //} foreach (GameObject go in GameObject.FindGameObjectsWithTag("ShopItemUI")) { Destroy(go); } itemInstanceList.Clear(); itemInstanceList2.Clear(); shopFramePlayerOne.GetComponent <Image>().rectTransform.position = framePosPlayerOne; shopFramePlayerTwo.GetComponent <Image>().rectTransform.position = framePosPlayerTwo; shopCanvas.SetActive(false); active = false; iconsActive = false; newPosPlayerOne = new Vector3(-524, -422, 0); newPosPlayerTwo = new Vector3(-524, -422, 0); highLightedItemPlayerOne = 0; highLightedItemPlayerTwo = 0; soldItems.Clear(); soldItems2.Clear(); } if (Input.GetAxisRaw("Horizontal2") > 0 && highLightedItemPlayerTwo < itemInstanceList2.Count - 1 && inputDelayTimerPlayerTwo <= 0 || Input.GetButtonDown("Right2") && highLightedItemPlayerTwo < itemInstanceList2.Count - 1 && inputDelayTimerPlayerTwo <= 0) { highLightedItemPlayerTwo++; shopFramePlayerTwo.transform.position = ItemSpotsPlayerTwo[highLightedItemPlayerTwo].GetComponent <RectTransform>().position; inputDelayTimerPlayerTwo = inputDelayTimerStart; AudioSource.PlayClipAtPoint(scrollSFX, new Vector3(7, 8, -10), 1.0f); UpdateText(dialougeText, itemNameTextPlayerTwo, itemCostTextPlayerTwo, itemDescriptionTextPlayerTwo, moneyTextPlayerTwo, itemInstanceList2, highLightedItemPlayerTwo); } else if (Input.GetAxisRaw("Horizontal2") < 0 && highLightedItemPlayerTwo > 0 && inputDelayTimerPlayerTwo <= 0 || Input.GetButtonDown("Left2") && highLightedItemPlayerTwo > 0 && inputDelayTimerPlayerTwo <= 0) { highLightedItemPlayerTwo--; shopFramePlayerTwo.transform.position = ItemSpotsPlayerTwo[highLightedItemPlayerTwo].GetComponent <RectTransform>().position; inputDelayTimerPlayerTwo = inputDelayTimerStart; AudioSource.PlayClipAtPoint(scrollSFX, new Vector3(7, 8, -10), 1.0f); UpdateText(dialougeText, itemNameTextPlayerTwo, itemCostTextPlayerTwo, itemDescriptionTextPlayerTwo, moneyTextPlayerTwo, itemInstanceList2, highLightedItemPlayerTwo); } else if (Input.GetAxisRaw("Vertical2") > 0 && highLightedItemPlayerTwo > 2 && inputDelayTimerPlayerTwo <= 0 || Input.GetButtonDown("Up2") && highLightedItemPlayerTwo > 2 && inputDelayTimerPlayerTwo <= 0) { highLightedItemPlayerTwo -= 3; shopFramePlayerTwo.transform.position = ItemSpotsPlayerTwo[highLightedItemPlayerTwo].GetComponent <RectTransform>().position; inputDelayTimerPlayerTwo = inputDelayTimerStart; AudioSource.PlayClipAtPoint(scrollSFX, new Vector3(7, 8, -10), 1.0f); UpdateText(dialougeText, itemNameTextPlayerTwo, itemCostTextPlayerTwo, itemDescriptionTextPlayerTwo, moneyTextPlayerTwo, itemInstanceList2, highLightedItemPlayerTwo); } else if (Input.GetAxisRaw("Vertical2") < 0 && highLightedItemPlayerTwo < itemInstanceList2.Count - 3 && inputDelayTimerPlayerTwo <= 0 || Input.GetButtonDown("Down2") && highLightedItemPlayerTwo < itemInstanceList2.Count - 3 && inputDelayTimerPlayerTwo <= 0) { highLightedItemPlayerTwo += 3; shopFramePlayerTwo.transform.position = ItemSpotsPlayerTwo[highLightedItemPlayerTwo].GetComponent <RectTransform>().position; inputDelayTimerPlayerTwo = inputDelayTimerStart; AudioSource.PlayClipAtPoint(scrollSFX, new Vector3(7, 8, -10), 1.0f); UpdateText(dialougeText, itemNameTextPlayerTwo, itemCostTextPlayerTwo, itemDescriptionTextPlayerTwo, moneyTextPlayerTwo, itemInstanceList2, highLightedItemPlayerTwo); } if (itemInstanceList2.Count != 0) { if (Input.GetKeyDown(KeyCode.RightShift) && !itemInstanceList2[highLightedItemPlayerTwo].GetComponent <ShopItem>().sold || Input.GetButtonDown("Confirm" + pc2.playerIndex) && !itemInstanceList[highLightedItemPlayerTwo].GetComponent <ShopItem>().sold) { if (itemInstanceList2[highLightedItemPlayerTwo] != null) { if (pc2.money >= itemInstanceList2[highLightedItemPlayerTwo].GetComponent <ShopItem>().itemCost) { inputDelayTimerPlayerTwo = inputDelayTimerStart; soldItems2.Add(itemInstanceList2[highLightedItemPlayerTwo]); //AddScript(itemInstanceList[highLightedItemPlayerOne].gameObject.GetComponent<ShopItem>().itemScript); //Have a look at how to check for certain power-ups. print(itemList2[highLightedItemPlayerTwo]); AudioSource.PlayClipAtPoint(purchaseAcceptedSFX, new Vector3(7, 8, -10), 1.0f); AddPowerUp.AddPowerUpScript(itemInstanceList2[highLightedItemPlayerTwo].gameObject.GetComponent <ShopItem>().itemScript, itemInstanceList2[highLightedItemPlayerTwo], pc2.gameObject); for (int i = 0; i < itemList2.Count; i++) { if (itemList2[i].GetComponent <ShopItem>().itemNameText == soldItems2[0].GetComponent <ShopItem>().itemNameText) { itemList2.RemoveAt(i); soldItems2.RemoveAt(0); break; } } pc2.money -= itemInstanceList2[highLightedItemPlayerTwo].gameObject.GetComponent <ShopItem>().itemCost; itemInstanceList2[highLightedItemPlayerTwo].gameObject.GetComponent <Image>().sprite = soldSpr; itemInstanceList2[highLightedItemPlayerTwo].gameObject.GetComponent <ShopItem>().dialougeText = soldDialouge; itemInstanceList2[highLightedItemPlayerTwo].gameObject.GetComponent <ShopItem>().itemDescription = soldDescription; moneyTextPlayerTwo.text = "Money: " + pc2.money.ToString(); itemInstanceList2[highLightedItemPlayerTwo].GetComponent <ShopItem>().sold = true; dialougeText.text = "Score! Another one sold to the SUCKE.. Fine lad!"; itemDescriptionTextPlayerTwo.text = itemInstanceList2[highLightedItemPlayerTwo].gameObject.GetComponent <ShopItem>().itemDescription = soldDescription; itemList2.Remove(itemInstanceList2[highLightedItemPlayerTwo]); } else if (pc2.money <= itemList2[highLightedItemPlayerTwo].GetComponent <ShopItem>().itemCost) { AudioSource.PlayClipAtPoint(purchaseDeniedSFX, new Vector3(7, 8, -10), 1.0f); dialougeText.text = "You trying to cheat me you little bastards??? NOT ENOUGH CASH! Comprende?"; } } } } } }