private void Update() { float before = ScoreBar.GetComponent <Image>().fillAmount; ScoreBar.GetComponent <Image>().fillAmount += (score * 1f / threeStar - ScoreBar.GetComponent <Image>().fillAmount) * 0.2f; SpaceShip.GetComponent <RectTransform>().anchoredPosition = new Vector2(ScoreBar.GetComponent <RectTransform>().rect.width *ScoreBar.GetComponent <Image>().fillAmount, 0); if (oneStar * 1f / threeStar < ScoreBar.GetComponent <Image>().fillAmount&& oneStar * 1f / threeStar > before) { Debug.Log("1 sao"); Destroy(Instantiate(StarExplo, new Vector3(OneStarPos.transform.position.x, OneStarPos.transform.position.y + 1f, 0f), Quaternion.identity), 1.5f); GameObject.FindGameObjectWithTag("UI").GetComponentInChildren <starSlider>().tangsao(); } if (twoStar * 1f / threeStar < ScoreBar.GetComponent <Image>().fillAmount&& twoStar * 1f / threeStar > before) { Debug.Log("2 sao"); Destroy(Instantiate(StarExplo, new Vector3(TwoStarPos.transform.position.x, OneStarPos.transform.position.y + 1f, 0f), Quaternion.identity), 1.5f); GameObject.FindGameObjectWithTag("UI").GetComponentInChildren <starSlider>().tangsao(); } if (before < 1 && ScoreBar.GetComponent <Image>().fillAmount == 1) { Debug.Log("3 sao"); Destroy(Instantiate(StarExplo, new Vector3(ThreeStarPos.transform.position.x, OneStarPos.transform.position.y + 1f, 0f), Quaternion.identity), 1.5f); GameObject.FindGameObjectWithTag("UI").GetComponentInChildren <starSlider>().tangsao(); } }
// Use this for initialization void Start() { //Debug.Log(ScoreBar.GetComponent<RectTransform>().rect.width); if (Fade.instance != null) { Fade.instance.FadeOutfc(); } if (gameLimit == GameLimit.Time) { txtGameLimit.GetComponentsInChildren <Text>()[0].text = "Time"; txtGameLimit.GetComponentsInChildren <Text>()[1].text = ValueLimit.ToString(); StartCoroutine(TimeCountDown()); } else { txtGameLimit.GetComponentsInChildren <Text>()[0].text = "Move"; txtGameLimit.GetComponentsInChildren <Text>()[1].text = ValueLimit.ToString(); } foreach (var obj in targetPlanet) { itemTargetPrefab.GetComponent <Image>().sprite = obj.Planet.GetComponent <SpriteRenderer>().sprite; itemTargetPrefab.GetComponentInChildren <Text>().text = "0/" + obj.NumOfTarget.ToString(); obj.ItemTarget = Instantiate(itemTargetPrefab, containerTarget.transform); } ScoreBar.GetComponent <Image>().fillAmount = 0; OneStarPos.GetComponent <RectTransform>().anchoredPosition = new Vector2(ScoreBar.GetComponent <RectTransform>().rect.width *(oneStar * 1f / threeStar), 0); TwoStarPos.GetComponent <RectTransform>().anchoredPosition = new Vector2(ScoreBar.GetComponent <RectTransform>().rect.width *(twoStar * 1f / threeStar), 0); }