Я хочу открыть следующий мир на основе количества звезд. Я хочу знать, как рассчитать звезды в разных сценах. И как сделать пример.
Я получаю 2 звезды на первом уровне. Количество звезд +2. Сейчас я снова играю на первом уровне и собираю 3 звезды. Количество звезд +3: количество звезд достигло 5. Как определить количество звезд уровня ?
На втором уровне я получаю 1 звезду. Количество звезд +1. Сейчас я играю на втором уровне и собираю 2 звезды. Количество звезд +2. Количество звезд было 3.
Теперь я соединяю количество звезд на обоих уровнях и получаю 8, но на самом деле их должно быть 5.
Пожалуйста, помогите мне понять правильный момент.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class CoinScript : MonoBehaviour {
public GameObject star1;
public GameObject star2;
public GameObject star3;
protected string currentLevel;
protected int worldIndex;
protected int levelIndex;
public static bool isLevelComplete ;
// Use this for initialization
void Start () {
isLevelComplete = false;
//get the star images
//disable the image component of all the star images
star1.GetComponent<Image>().enabled = false;
star2.GetComponent<Image>().enabled = false;
star3.GetComponent<Image>().enabled = false;
//save the current level name
currentLevel = Application.loadedLevelName;
ballon_1=0;
scoreCoin = coin_num;
coinscore = GetComponent<Text>();
Panel_youwin.SetActive(false);
Time.timeScale = 1f;
Panel_youlose.SetActive(false);
Time.timeScale = 1f;
}
void Update () {
if (coinscore != null){
coinscore.text = "Score " + scoreCoin;
}
// 3stars if(ballon_1==astx_3&&Health.healthlife==3){
star3.GetComponent<Image>().enabled = true;
UnlockLevels(3);
Panel_youwin.SetActive(true);
Time.timeScale = 0f;
}
// 2stars if(ballon_1==astx_2&&Health.healthlife==2){
star2.GetComponent<Image>().enabled = true;
UnlockLevels(2);
Panel_youwin.SetActive(true);
Time.timeScale = 0f;
}
// 1stars if(ballon_1==astx_1&&Health.healthlife==1){
star1.GetComponent<Image>().enabled = true;
UnlockLevels(1);
Panel_youwin.SetActive(true);
Time.timeScale = 0f;
}
if(Health.healthlife <= 0){
Panel_youlose.SetActive(true);
Time.timeScale = 0f;
}
}
protected void UnlockLevels (int stars){
//set the playerprefs value of next level to 1 to unlock
//also set the playerprefs value of stars to display them on the World levels menu
for(int i = 0; i < LockLevel.worlds; i++){
for(int j = 1; j < LockLevel.levels; j++){
if(currentLevel == "Level"+(i+1).ToString() +"." +j.ToString()){
worldIndex = (i+1);
levelIndex = (j+1);
PlayerPrefs.SetInt("level"+worldIndex.ToString() +":" +levelIndex.ToString(),1);
//check if the current stars value is less than the new value
if(PlayerPrefs.GetInt("level"+worldIndex.ToString() +":" +j.ToString()+"stars")< stars)
//overwrite the stars value with the new value obtained
PlayerPrefs.SetInt("level"+worldIndex.ToString() +":" +j.ToString()+"stars",stars);
}
}
}
}
}
Оборудование для ресторана: новинки профессиональной кухонной техники
Частный дом престарелых в Киеве: комфорт, забота и профессиональный уход
Мне нужно сделать остановку объектов при касанииПри касание значение int = -1
в столбце есть повторяющиеся записинужно найти запись даты(string) с наибольшим количеством