/// <summary> /// Finds the player if player is null /// </summary> void FindPlayer() { if(!player) { try { player = GameObject.FindGameObjectWithTag("Player").GetComponent<CrazyBastard>(); } catch(System.Exception) { Debug.LogWarning("Player not found"); } } }
IEnumerator SetUpAnimation() { player = GameObject.FindGameObjectWithTag("Player").GetComponent<CrazyBastard>(); player.EnableMove = false; yield return new WaitForSeconds(.75f); while(crazyGuy.transform.position != transform.position) { crazyGuy.transform.position = Vector3.MoveTowards(crazyGuy.transform.position, transform.position, 2.0f * Time.deltaTime); player.transform.LookAt(playerPosition.transform.position); player.transform.position = Vector3.MoveTowards(player.transform.position, playerPosition.transform.position, 2.5f * Time.deltaTime); yield return null; } yield return new WaitForSeconds(0.5f); animation.Play("GuardCrazyGuy"); yield return new WaitForSeconds(4.0f); Guard.renderer.enabled = true; yield return new WaitForSeconds(17.0f); player.EnableMove = true; crazyGuyRenderer.renderer.enabled = false; Guard.renderer.enabled = false; }
/// <summary> /// Fills the slot with an item /// </summary> public void FillSlot(Item t) { if(!item) { item = t; slotObject.renderer.material.mainTexture = t.renderer.material.mainTexture; t.CurrentSlot = this; player = GameObject.FindGameObjectWithTag("Player").GetComponent<CrazyBastard>(); Debug.Log(slotObject.name + " now contains " + item.gameObject.name); } }
IEnumerator SetUpLevel() { TimeManagment.isTimePaused = true; try { inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>(); if(inventory && inventory.ShowInterface) { inventory.ToggleInterface(); } } catch(System.Exception) { Debug.LogWarning("Cannot find inventory"); } try { player = GameObject.FindGameObjectWithTag("Player").GetComponent<CrazyBastard>(); } catch(System.Exception) { Debug.LogWarning("Cannot find player"); } yield return new WaitForSeconds(0.5f); if(player) player.EnableMove = false; yield return new WaitForSeconds(animation["QuoteAnimation"].length - 1.75f); if(player) player.EnableMove = true; if(Application.loadedLevelName != "EndScreen") { TimeManagment.isTimePaused = false; } }