UI Manager erweiter // Ammo UI added funktional tüchtig
This commit is contained in:
parent
dd1c87c948
commit
b3d9b99639
@ -294,6 +294,85 @@ BoxCollider:
|
|||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
m_Size: {x: 1, y: 1, z: 1}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &7566297578841152737
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 2355847910073875648}
|
||||||
|
- component: {fileID: 3332157730834607231}
|
||||||
|
- component: {fileID: 1464316800582670505}
|
||||||
|
m_Layer: 10
|
||||||
|
m_Name: Ammo
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &2355847910073875648
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7566297578841152737}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: -0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 8234077612602293382}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchoredPosition: {x: -418, y: -275}
|
||||||
|
m_SizeDelta: {x: 134.5, y: 109.16}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!222 &3332157730834607231
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7566297578841152737}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &1464316800582670505
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7566297578841152737}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_FontData:
|
||||||
|
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
m_FontSize: 46
|
||||||
|
m_FontStyle: 0
|
||||||
|
m_BestFit: 0
|
||||||
|
m_MinSize: 6
|
||||||
|
m_MaxSize: 60
|
||||||
|
m_Alignment: 0
|
||||||
|
m_AlignByGeometry: 0
|
||||||
|
m_RichText: 1
|
||||||
|
m_HorizontalOverflow: 0
|
||||||
|
m_VerticalOverflow: 0
|
||||||
|
m_LineSpacing: 1
|
||||||
|
m_Text: 0
|
||||||
--- !u!1 &8948127678283011642
|
--- !u!1 &8948127678283011642
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -483,6 +562,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_Layer
|
propertyPath: m_Layer
|
||||||
value: 10
|
value: 10
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4766397035718395917, guid: abb3f2146f967be4e9dfd6069915f42c, type: 3}
|
||||||
|
propertyPath: dataBullet
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 11400000, guid: cafd241bae342f446ae8141cc5d72daf, type: 2}
|
||||||
- target: {fileID: 5727695039551963900, guid: abb3f2146f967be4e9dfd6069915f42c, type: 3}
|
- target: {fileID: 5727695039551963900, guid: abb3f2146f967be4e9dfd6069915f42c, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
value: -0
|
value: -0
|
||||||
@ -561,7 +644,10 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects:
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 4822466156586256155, guid: abb3f2146f967be4e9dfd6069915f42c, type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 2355847910073875648}
|
||||||
m_AddedComponents: []
|
m_AddedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: abb3f2146f967be4e9dfd6069915f42c, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: abb3f2146f967be4e9dfd6069915f42c, type: 3}
|
||||||
--- !u!4 &7059315404903924766 stripped
|
--- !u!4 &7059315404903924766 stripped
|
||||||
@ -569,6 +655,11 @@ Transform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 5863193481701293955, guid: abb3f2146f967be4e9dfd6069915f42c, type: 3}
|
m_CorrespondingSourceObject: {fileID: 5863193481701293955, guid: abb3f2146f967be4e9dfd6069915f42c, type: 3}
|
||||||
m_PrefabInstance: {fileID: 3506481795036953501}
|
m_PrefabInstance: {fileID: 3506481795036953501}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!224 &8234077612602293382 stripped
|
||||||
|
RectTransform:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 4822466156586256155, guid: abb3f2146f967be4e9dfd6069915f42c, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 3506481795036953501}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1001 &7466933759953658907
|
--- !u!1001 &7466933759953658907
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
42
Plunderblock/Assets/Scripts/ScriptsKevin/UI_Manager.cs
Normal file
42
Plunderblock/Assets/Scripts/ScriptsKevin/UI_Manager.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ public class WeaponScript : MonoBehaviour
|
|||||||
public GameObject bullet;
|
public GameObject bullet;
|
||||||
|
|
||||||
public DataBullet dataBullet;
|
public DataBullet dataBullet;
|
||||||
|
public UI_Manager uI_Manager;
|
||||||
|
|
||||||
private int ammo;
|
private int ammo;
|
||||||
private bool isReloading = false;
|
private bool isReloading = false;
|
||||||
@ -27,23 +28,23 @@ public class WeaponScript : MonoBehaviour
|
|||||||
time += Time.deltaTime;
|
time += Time.deltaTime;
|
||||||
if(time > reloadTime){
|
if(time > reloadTime){
|
||||||
ammo = dataBullet.ammo;
|
ammo = dataBullet.ammo;
|
||||||
|
uI_Manager.ammoReset();
|
||||||
time = 0;
|
time = 0;
|
||||||
isReloading = false;
|
isReloading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void shoot(){
|
public void shoot(){
|
||||||
if(ammo != 0){
|
if(ammo != 0 && delayOver){
|
||||||
if(delayOver){
|
if(Input.GetKeyDown(KeyCode.Mouse0)){
|
||||||
if(Input.GetKeyDown(KeyCode.Mouse0)){
|
|
||||||
muzzle.gameObject.SetActive(true);
|
muzzle.gameObject.SetActive(true);
|
||||||
//muzzle.Play();
|
//muzzle.Play();
|
||||||
Instantiate(bullet,spawnpoint.transform.position,spawnpoint.transform.rotation);
|
Instantiate(bullet,spawnpoint.transform.position,spawnpoint.transform.rotation);
|
||||||
ammo--;
|
ammo--;
|
||||||
|
uI_Manager.ammoDown();
|
||||||
delay = 0;
|
delay = 0;
|
||||||
delayOver = false;
|
delayOver = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void checkDelay(){
|
public void checkDelay(){
|
||||||
@ -59,6 +60,7 @@ public class WeaponScript : MonoBehaviour
|
|||||||
ammo = dataBullet.ammo;
|
ammo = dataBullet.ammo;
|
||||||
muzzle = GetComponentInChildren<ParticleSystem>();
|
muzzle = GetComponentInChildren<ParticleSystem>();
|
||||||
spawnpoint = GameObject.Find("Player/PlayerView/BulletSpawnpoint");
|
spawnpoint = GameObject.Find("Player/PlayerView/BulletSpawnpoint");
|
||||||
|
uI_Manager = GameObject.FindGameObjectWithTag("Manager").GetComponent<UI_Manager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
public class UI_Manager : MonoBehaviour
|
|
||||||
{
|
|
||||||
private Text anzahlKills;
|
|
||||||
|
|
||||||
private Transform canvas;
|
|
||||||
|
|
||||||
public void killCount(int addedScore){
|
|
||||||
int summe = int.Parse(anzahlKills.text) + addedScore;
|
|
||||||
anzahlKills.text = "" + summe;
|
|
||||||
}
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
canvas = this.gameObject.GetComponentInChildren<Transform>();
|
|
||||||
anzahlKills = canvas.GetComponentInChildren<Text>();
|
|
||||||
anzahlKills.text = "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user