PBG2H23ABR_PBG2H23AKL_PMC_P.../Plunderblock/Assets/Scripts/ScriptsKevin/UI_Manager.cs

43 lines
1.1 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class UI_Manager : MonoBehaviour
{
private Text[] textFelder;
private Transform canvas;
private int maxAmmo;
public DataBullet dataBullet;
public void killCount(int addedScore){
int summe = int.Parse(textFelder[0].text) + addedScore;
textFelder[0].text = "" + summe;
}
public void ammoDown(){
String[] stringparts = textFelder[1].text.Split('/');
int aktuellAmmo = int.Parse(stringparts[0]);
textFelder[1].text = aktuellAmmo - 1 + "/" + maxAmmo;
}
public void ammoReset(){
textFelder[1].text = maxAmmo + "/" + maxAmmo;
}
void Start()
{
maxAmmo = dataBullet.ammo;
canvas = this.gameObject.GetComponentInChildren<Transform>();
textFelder = canvas.GetComponentsInChildren<Text>();
textFelder[0].text = "0";
ammoReset();
}
// Update is called once per frame
void Update()
{
}
}