void Update() { foreach (GameObject i in Items) { SpriteRenderer sRend = i.GetComponent <SpriteRenderer>(); if (i.name == "Waiter Bundle" && !sRend.enabled) { GameObject j = GameObject.Find("Jawsh"); JawshMovement jMove = j.GetComponent <JawshMovement>(); jMove.hasWaiterDisguise = true; } //UI Check GameObject checkWaiterBundle = GameObject.Find("Waiter Bundle"); Item itemScript1 = checkWaiterBundle.GetComponent <Item>(); if (itemScript1.isPickedUp) { UIWaiterBundle.GetComponent <Image>().overrideSprite = SpriteWaiterBundle; } GameObject checkFlowers = GameObject.Find("Flowers"); Item itemScript2 = checkFlowers.GetComponent <Item>(); if (itemScript2.isPickedUp) { UIFlowers.GetComponent <Image>().overrideSprite = SpriteFlowers; } GameObject checkChampagne = GameObject.Find("Champagne"); Item itemScript3 = checkChampagne.GetComponent <Item>(); if (itemScript3.isPickedUp) { UIChampagne.GetComponent <Image>().overrideSprite = SpriteChampagne; } GameObject checkRing = GameObject.Find("Ring"); Item itemScript4 = checkRing.GetComponent <Item>(); if (itemScript4.isPickedUp) { UIRing.GetComponent <Image>().overrideSprite = SpriteRing; } } foreach (GameObject i in FakeProposalItems) { GameObject checkItem = GameObject.Find(i.name); Item itemScript = checkItem.GetComponent <Item>(); //Debug.Log(itemScript.isPickedUp); if (!itemScript.isPickedUp) { allPickedUpFP = false; //Debug.Log("Nay!"); } } if (allPickedUpFP) { GameObject t = GameObject.Find("Todd"); NPC tAct = t.GetComponent <NPC>(); tAct.FakeProposalReady = true; GameObject l = GameObject.Find("Linda"); NPC lAct = l.GetComponent <NPC>(); lAct.FakeProposalReady = true; //Debug.Log("yay!"); } else if (!allPickedUpFP) { allPickedUpFP = true; } foreach (GameObject n in OperationCheatNPCs) { NPC npcScript = n.GetComponent <NPC>(); if (n.tag == "youngBoy" && !npcScript.yBTalked) { //Debug.Log("a"); bothTalkedTo = false; } if (n.tag == "marriedLady" && !npcScript.mLTalked) { //Debug.Log("b"); bothTalkedTo = false; } } //Debug.Log(bothTalkedTo); if (bothTalkedTo) { NPC npcScript = OperationCheatNPCs[0].GetComponent <NPC>(); //Debug.Log("here?"); npcScript.triggered = true; Item iScript = OperationCheatItems[0].GetComponent <Item>(); iScript.isVisible = true; if (!iScript.isPickedUp) { SpriteRenderer sr = OperationCheatItems[0].GetComponent <SpriteRenderer>(); sr.enabled = true; } } bothTalkedTo = true; foreach (GameObject i in OperationCheatItems) { GameObject checkItem = GameObject.Find(i.name); Item itemScript = checkItem.GetComponent <Item>(); //Debug.Log(itemScript.isPickedUp); if (!itemScript.isPickedUp) { allPickedUpOC = false; //Debug.Log("Nay!"); } } if (allPickedUpOC) { foreach (GameObject npc in OperationCheatNPCs) { NPC_Interaction nInt = npc.GetComponent <NPC_Interaction>(); nInt.triggered = true; } } else if (!allPickedUpOC) { allPickedUpOC = true; } }
void Update() { if (winScreen.enabled && Input.GetKeyDown(KeyCode.Space)) { SceneManager.LoadScene("Background 1"); } if (isInRange && Input.GetKeyDown(KeyCode.Space) && !FakeProposalReady) { textbox.enabled = true; text.enabled = true; int rand = Random.Range(0, barks.Length); text.text = barks[rand]; Invoke("ClearText", 5); if (tag == "youngBoy" && rand == yBTalkNum && !yBTalked) { yBTalked = true; } if (tag == "marriedLady" && rand == mLTalkNum && !mLTalked) { mLTalked = true; } } GameObject j = GameObject.Find("Jawsh"); JawshMovement jMove = j.GetComponent <JawshMovement>(); if (isInRange && jMove.isDisguisedAsWaiter && Input.GetKeyDown(KeyCode.Space) && (tag == "Todd" || tag == "Linda") && FakeProposalReady) { triggered = true; if (tag == "Todd") { GameObject other = GameObject.Find("Linda"); NPC nScript = other.GetComponent <NPC>(); nScript.triggered = true; } if (tag == "Linda") { GameObject other = GameObject.Find("Todd"); NPC nScript = other.GetComponent <NPC>(); nScript.triggered = true; } StartCoroutine("BreakUp"); } if (target != position && !triggered) { anim.CrossFade(animations[1], 0); position = gameObject.transform.position; float step = Time.deltaTime * speed; if (position2.x - gameObject.transform.position.x > 0) { sr.flipX = true; } else { sr.flipX = false; } transform.position = Vector2.MoveTowards(transform.position, target, step); } else if (!triggered) { //anim.CrossFade(animations[1], 0); StartCoroutine("MoveManager"); } if (triggered) { StopCoroutine("MoveManager"); if (index < destinations.Length) { position = gameObject.transform.position; if (destinations[index] != position) { anim.CrossFade(animations[1], 0); float step = Time.deltaTime * speed; transform.position = Vector2.MoveTowards(transform.position, destinations[index], step); if (destinations[index].x - position.x > 0) { sr.flipX = false; } else { sr.flipX = true; } } else { index++; if (index >= destinations.Length) { anim.CrossFade(animations[0], 0); position = transform.position; //Debug.Log(target.x - position.x); StartCoroutine("MoveDestManager"); } } } } }