Пример #1
0
	protected void Update() 
	{
		if(playerEntity == null || playerMagazine == null || playerStockPile == null)
		{
			playerEntity = EntityUtils.GetEntityWithTag("Player");

			if(playerEntity == null)
			{
				Debug.LogError("No player found");
				return;
			}

			playerEntity.Events.AddListener<ReloadEvent> (onReloadEvent);
			playerMagazine = playerEntity.GetMagazine();
			playerStockPile = playerEntity.GetStockPile();

			if(playerMagazine == null || playerStockPile == null)
			{
				Debug.LogError("No magazine or stockpile found");
				return;
			}
		}

		float currentTime = Time.time;
		int minutes = Mathf.FloorToInt((currentTime - startTime) / 60f);
		int seconds = Mathf.FloorToInt((currentTime - startTime) % 60f);
		text_time.text = "";

		text_time.text += minutes < 10 ? "0" + minutes : minutes.ToString();
		text_time.text += ":";
		text_time.text += seconds < 10 ? "0" + seconds : seconds.ToString();

		text_ammoCurrent.text = "" + playerMagazine.Remaining;
		text_ammoLeft.text = "" + playerStockPile.Remaining;
		text_credits.text = playerCurrency.Amount + " CR";

		if(text_reloadAnim > 0f)
		{
			text_reloadAnim -= Time.deltaTime;
		}

		if((playerMagazine.Remaining < 11) != text_reload.enabled && text_reloadAnim <= 0f)
		{
			StartCoroutine (SwitchReloadText((playerMagazine.Remaining < 11)));
		}
	}