public void TakeCan(CanScript can) { if (!canMode) { isFull = can.isFull; cans.Remove(can); Destroy(can.gameObject); UnityEngine.Cursor.SetCursor(clawSpray, Vector2.zero, CursorMode.ForceSoftware); canMode = true; } }
void Start() { door.SetActive(false); hasStealthChanged = sightRange; rigidbody2D = GetComponent <Rigidbody2D>(); Player = GameObject.Find("Player"); BoxCollider2D[] bc2d = GetComponents <BoxCollider2D>(); if (bc2d[0].isTrigger) { sightCollider = bc2d[0]; } else { sightCollider = bc2d[1]; } sightCollider.size = new Vector2(sightRange, 6f); isEnraged = false; canScript = GameObject.Find("Canvas").GetComponent <CanScript>(); }
void SpawnCan(int noCans) { RectTransform rt = canArea.GetComponent <RectTransform>(); UnityEngine.Random rnd = new UnityEngine.Random(); Vector3[] v = new Vector3[4]; rt.GetWorldCorners(v); int random1 = UnityEngine.Random.Range(0, noCans); int random2 = UnityEngine.Random.Range(0, noCans); for (int i = 0; i < noCans; i++) { Vector3 spawnPoint = new Vector3(UnityEngine.Random.Range(v[0].x, v[3].x), UnityEngine.Random.Range(v[0].y, v[2].y), 0); CanScript spawnObject = Instantiate(canPrefab, spawnPoint, Quaternion.identity, rt); spawnObject.GetComponent <CanScript>().game = this; if (i == random1 || i == random2) { spawnObject.isFull = true; } cans.Add(spawnObject); } }
void Start() { GameObject.Find("Button").GetComponentInChildren <Text>().text = "Restart"; canScript = GameObject.Find("Canvas").GetComponent <CanScript>(); }