private void OnSceneLoaded(Scene aScene, LoadSceneMode aMode) { AHS = GameObject.Find("AssetHolder").GetComponent <AssetHolderScript>(); knife = GameObject.Find("Environment/Knife"); envT = GameObject.Find("Environment").transform; knives = 6; knifeReady = true; AHS.levelText.text = level.ToString(); AHS.applesText.text = apples.ToString(); //The higher level is - the more knives need to beat level; knives += level / 3; //Every 3rd level is a boss level, otherwise ordinary level if ((float)level / 3 == level / 3) { bossLevel = true; knives += 2; bossHealth = (float)knives / AHS.bossSprites.Length; //Knife hits need to change boss sprite bossCurrentSprite = 0; target = Instantiate(AHS.bossTargetPrefabs[0], new Vector2(0, 2.1f), Quaternion.identity, envT); } else { bossLevel = false; target = Instantiate(AHS.ordinaryTargetPrefabs[0], new Vector2(0, 2.1f), Quaternion.identity, envT); } //Set knife skin currentSkin = PlayerPrefs.GetInt("knifeSkin", 1) - 1; knife.GetComponentInChildren <SpriteRenderer>().sprite = AHS.knifeSkins[currentSkin]; AHS.knivesObject.GetComponentInChildren <Image>().sprite = AHS.knifeSkins[currentSkin]; //Set random target rotation targetRotationSpeed = Random.Range(3f, 4f); if (Random.Range(0, 2) == 0) { rotationDirecton = -1; } else { rotationDirecton = 1; } //Set knives quantity in UI GameObject _knife = AHS.knivesObject.GetComponentInChildren <Image>().gameObject; knivesList.Clear(); knivesList.Add(_knife); for (int i = 1; i <= knives; i++) { GameObject obj = Instantiate(_knife, AHS.knivesObject.transform); obj.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, i * 75); knivesList.Add(obj); } //Spawn random apples and knives in the target allSpawnedObjectsList.Clear(); spawnedApplesList.Clear(); spawnedKnivesList.Clear(); if (Random.value <= chanceToAppear.chance) { SpawnObject(AHS.applePrefab); } for (int i = 0; i < Random.Range(1, 4); i++) { SpawnObject(knife); } cor = StartCoroutine(RotationSpeedChange()); StartCoroutine(SceneFadeOut(false, 2)); }
private void Awake() { GMS = GameObject.Find("GameManager").GetComponent <GameManagerScript>(); AHS = GameObject.Find("AssetHolder").GetComponent <AssetHolderScript>(); }