public void OnTriggerExit2D(Collider2D collision) { string thisGameobjectName; string collisionGameobjectName; //give the value of collision object to the first character only VVV //also all names need to be 1 letter/number with "_Object" thisGameobjectName = gameObject.name.Substring(0, name.IndexOf("_")); collisionGameobjectName = collision.gameObject.name.Substring(0, name.IndexOf("_")); if (gameObject.tag != "SPHolder" && collision.gameObject.tag != "SPHolder") { DropNDrag localDrag2 = collision.GetComponent <DropNDrag>(); if (thisGameobjectName == "P" && collisionGameobjectName != "F") { shopAnim.Play(SHOPIDLE); } if (thisGameobjectName == "V" && collisionGameobjectName != "F" && localDrag2.isDead == true) { shopAnim.Play(SHOPIDLE); } } }
private void Start() { manageHolder = GameObject.FindGameObjectWithTag("Manager"); money = manageHolder.GetComponent <Money>(); kitty = manageHolder.GetComponent <Kitty>(); mainButtonHolder = GameObject.FindGameObjectWithTag("SPHolder"); mainClick = mainButtonHolder.GetComponent <ButtonScript>(); sellHolder = GameObject.FindGameObjectWithTag("PetShop"); sell = sellHolder.GetComponent <DropNDrag>(); scoreHolder = GameObject.FindGameObjectWithTag("Cross"); dontDestroy = scoreHolder.gameObject.GetComponent <DontDestroy>(); }
public void Start() { scaled = transform.Find("HealthBar/FillHold"); kitty = gameObject.GetComponent <Kitty>(); dropNDrag = gameObject.GetComponent <DropNDrag>(); currentFood = 0.5f; StartCoroutine(Scale()); catSprite = transform.Find("CSprite").gameObject; rend = catSprite.GetComponent <SpriteRenderer>(); rend.color = new Color(255f, 255f, 255f, 1f); warnSprite = transform.Find("!").gameObject; warnRend = warnSprite.GetComponent <SpriteRenderer>(); warnRend.color = new Color(255f, 255f, 255f, 0f); switch (gameObject.tag) { case "K1": currentTimer = 0.1f; break; case "K2": currentTimer = 0.17f; break; case "K3": currentTimer = 0.24f; break; case "K4": currentTimer = 0.31f; break; case "K5": currentTimer = 0.38f; break; case "K6": currentTimer = 0.45f; break; case "K7": currentTimer = 0.52f; break; case "K8": currentTimer = 0.59f; break; case "K9": currentTimer = 0f; break; default: Debug.Log("not sure what to do with this right now lol"); break; } }
public void OnTriggerStay2D(Collider2D collision) { string thisGameobjectName; string collisionGameobjectName; //give the value of collision object to the first character only VVV //also all names need to be 1 letter/number with "_Object" thisGameobjectName = gameObject.name.Substring(0, name.IndexOf("_")); collisionGameobjectName = collision.gameObject.name.Substring(0, name.IndexOf("_")); if (gameObject.tag != "SPHolder" && collision.gameObject.tag != "SPHolder") { DropNDrag otherDrag = collision.GetComponent <DropNDrag>(); if (isDead == false && otherDrag.isDead == false) { if (mouseButtonReleased && thisGameobjectName == "1" && thisGameobjectName == collisionGameobjectName && gameObject.GetComponent <DropNDrag>().fix == true) { buttonScript.currentCats--; buttonScript.buttonText.text = buttonScript.currentCats + "/" + buttonScript.maxCats; Instantiate(Resources.Load("2_Object"), transform.position, Quaternion.identity); mouseButtonReleased = false; if (infoMenu.infoCat2 == false) { infoMenu.infoCat2 = true; } Destroy(collision.gameObject); Destroy(gameObject); } else if (mouseButtonReleased && thisGameobjectName == "2" && thisGameobjectName == collisionGameobjectName && gameObject.GetComponent <DropNDrag>().fix == true) { buttonScript.currentCats--; buttonScript.buttonText.text = buttonScript.currentCats + "/" + buttonScript.maxCats; Instantiate(Resources.Load("3_Object"), transform.position, Quaternion.identity); mouseButtonReleased = false; if (infoMenu.infoCat3 == false) { infoMenu.infoCat3 = true; } Destroy(collision.gameObject); Destroy(gameObject); } else if (mouseButtonReleased && thisGameobjectName == "3" && thisGameobjectName == collisionGameobjectName && gameObject.GetComponent <DropNDrag>().fix == true) { buttonScript.currentCats--; buttonScript.buttonText.text = buttonScript.currentCats + "/" + buttonScript.maxCats; Instantiate(Resources.Load("4_Object"), transform.position, Quaternion.identity); mouseButtonReleased = false; if (infoMenu.infoCat4 == false) { infoMenu.infoCat4 = true; } Destroy(collision.gameObject); Destroy(gameObject); } else if (mouseButtonReleased && thisGameobjectName == "4" && thisGameobjectName == collisionGameobjectName && gameObject.GetComponent <DropNDrag>().fix == true) { buttonScript.currentCats--; buttonScript.buttonText.text = buttonScript.currentCats + "/" + buttonScript.maxCats; Instantiate(Resources.Load("5_Object"), transform.position, Quaternion.identity); mouseButtonReleased = false; if (infoMenu.infoCat5 == false) { infoMenu.infoCat5 = true; } Destroy(collision.gameObject); Destroy(gameObject); } else if (mouseButtonReleased && thisGameobjectName == "5" && thisGameobjectName == collisionGameobjectName && gameObject.GetComponent <DropNDrag>().fix == true) { buttonScript.currentCats--; buttonScript.buttonText.text = buttonScript.currentCats + "/" + buttonScript.maxCats; Instantiate(Resources.Load("6_Object"), transform.position, Quaternion.identity); mouseButtonReleased = false; if (infoMenu.infoCat6 == false) { infoMenu.infoCat6 = true; } Destroy(collision.gameObject); Destroy(gameObject); } else if (mouseButtonReleased && thisGameobjectName == "6" && thisGameobjectName == collisionGameobjectName && gameObject.GetComponent <DropNDrag>().fix == true) { buttonScript.currentCats--; buttonScript.buttonText.text = buttonScript.currentCats + "/" + buttonScript.maxCats; Instantiate(Resources.Load("7_Object"), transform.position, Quaternion.identity); mouseButtonReleased = false; if (infoMenu.infoCat7 == false) { infoMenu.infoCat7 = true; } Destroy(collision.gameObject); Destroy(gameObject); } else if (mouseButtonReleased && thisGameobjectName == "7" && thisGameobjectName == collisionGameobjectName && gameObject.GetComponent <DropNDrag>().fix == true) { buttonScript.currentCats--; buttonScript.buttonText.text = buttonScript.currentCats + "/" + buttonScript.maxCats; Instantiate(Resources.Load("8_Object"), transform.position, Quaternion.identity); mouseButtonReleased = false; if (infoMenu.infoCat8 == false) { infoMenu.infoCat8 = true; } Destroy(collision.gameObject); Destroy(gameObject); } else if (mouseButtonReleased && thisGameobjectName == "8" && thisGameobjectName == collisionGameobjectName && gameObject.GetComponent <DropNDrag>().fix == true) { buttonScript.currentCats--; buttonScript.buttonText.text = buttonScript.currentCats + "/" + buttonScript.maxCats; Instantiate(Resources.Load("9_Object"), transform.position, Quaternion.identity); mouseButtonReleased = false; if (infoMenu.infoCat9 == false) { infoMenu.infoCat9 = true; } Destroy(collision.gameObject); Destroy(gameObject); } else if (mouseButtonReleased && collisionGameobjectName == "P") { buttonScript.currentCats--; buttonScript.buttonText.text = buttonScript.currentCats + "/" + buttonScript.maxCats; mouseButtonReleased = false; otherDrag.shopAnim.Play(SHOPIDLE); if (thisGameobjectName == "F") { //sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, 0f); food.transform.position = resetFood.transform.position; } else { if (sellDouble == true) { switch (gameObject.tag) { case "K1": money3.coins += 1; break; case "K2": money3.coins += 16 * 2; break; case "K3": money3.coins += 81 * 2; break; case "K4": money3.coins += 256 * 2; break; case "K5": money3.coins += 625 * 2; break; case "K6": money3.coins += 1296 * 2; break; case "K7": money3.coins += 2400 * 2; break; case "K8": money3.coins += 4850 * 2; break; case "K9": money3.coins += 10000 * 2; break; default: Debug.Log("not sure what to do with this right now lol"); break; } } else { switch (gameObject.tag) { case "K1": money3.coins += 1; break; case "K2": money3.coins += 16; break; case "K3": money3.coins += 81; break; case "K4": money3.coins += 256; break; case "K5": money3.coins += 625; break; case "K6": money3.coins += 1296; break; case "K7": money3.coins += 2400; break; case "K8": money3.coins += 4850; break; case "K9": money3.coins += 10000; break; default: Debug.Log("not sure what to do with this right now lol"); break; } } money3.UpdateCoins(); Destroy(gameObject); } } else if (mouseButtonReleased && thisGameobjectName == "F" && collisionGameobjectName != "P" && collisionGameobjectName != "V") { mouseButtonReleased = false; localHealth = collision.gameObject.GetComponent <Health>(); if (money3.coins >= 100) { localHealth.currentFood = 0.7f; foodSource.PlayOneShot(foodMunch); localHealth.HealFood(); money3.coins -= 100; money3.UpdateCoins(); } } } else { if (mouseButtonReleased && collisionGameobjectName == "V") { mouseButtonReleased = false; if (thisGameobjectName == "F") { sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, 0f); food.transform.position = resetFood.transform.position; } else { localHealth = this.gameObject.GetComponent <Health>(); otherDrag.shopAnim.Play(SHOPIDLE); if (localHealth.scaled.transform.localScale.x <= 0) { if (money3.coins >= 500) { switch (gameObject.tag) { case "K1": Instantiate(Resources.Load("1_Object"), transform.position, Quaternion.identity); break; case "K2": Instantiate(Resources.Load("2_Object"), transform.position, Quaternion.identity); break; case "K3": Instantiate(Resources.Load("3_Object"), transform.position, Quaternion.identity); break; case "K4": Instantiate(Resources.Load("4_Object"), transform.position, Quaternion.identity); break; case "K5": Instantiate(Resources.Load("5_Object"), transform.position, Quaternion.identity); break; case "K6": Instantiate(Resources.Load("6_Object"), transform.position, Quaternion.identity); break; case "K7": Instantiate(Resources.Load("7_Object"), transform.position, Quaternion.identity); break; case "K8": Instantiate(Resources.Load("8_Object"), transform.position, Quaternion.identity); break; default: Debug.Log("not sure what to do with this right now lol"); break; } money3.coins -= 500; money3.UpdateCoins(); Destroy(gameObject); } } } } } } }