From 392e3073cd1c12cae891c0df7009e8f9f208ed20 Mon Sep 17 00:00:00 2001 From: Triceraptodactyl Date: Mon, 23 Apr 2018 23:07:39 +0200 Subject: [PATCH] =?UTF-8?q?BrakeBar=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Prefabs/UI.prefab | 14 ++++----- Assets/Scenes/CodeDEV.unity | 46 ++++++++++++++++++++++++++++ Assets/Scripts/BrakeBarController.cs | 25 ++++++++------- 3 files changed, 67 insertions(+), 18 deletions(-) diff --git a/Assets/Prefabs/UI.prefab b/Assets/Prefabs/UI.prefab index c70b03f..923d280 100644 --- a/Assets/Prefabs/UI.prefab +++ b/Assets/Prefabs/UI.prefab @@ -148,7 +148,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!1 &1738841749900334 GameObject: m_ObjectHideFlags: 0 @@ -906,7 +906,7 @@ MonoBehaviour: notifications: {fileID: 114700265308343224} restartUIPanel: {fileID: 1604998495297016} healthcontroller: {fileID: 114617351635937986} - brakeBarController: {fileID: 0} + brakeBarController: {fileID: 114745107968250074} mainMenuSceneIndex: 0 --- !u!114 &114930219842054174 MonoBehaviour: @@ -1223,7 +1223,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 66.52695, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 1, y: 0.5} --- !u!224 &224218339018349506 @@ -1251,18 +1251,18 @@ RectTransform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1118501802334006} - m_LocalRotation: {x: 0, y: 0, z: 0.76604444, w: 0.64278764} + m_LocalRotation: {x: 0, y: 0, z: 0.7771459, w: 0.62932044} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0.49999988, y: 0.49999988, z: 1} m_Children: [] m_Father: {fileID: 224609935718604692} m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 100} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 102} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -7.3055115, y: -3.7793121} + m_AnchoredPosition: {x: -1.7573471, y: -4.5857997} m_SizeDelta: {x: 100, y: 100} - m_Pivot: {x: 0.05, y: 0.05} + m_Pivot: {x: 0.06394628, y: 0.06415958} --- !u!224 &224484966753135898 RectTransform: m_ObjectHideFlags: 1 diff --git a/Assets/Scenes/CodeDEV.unity b/Assets/Scenes/CodeDEV.unity index a0fed13..c750999 100644 --- a/Assets/Scenes/CodeDEV.unity +++ b/Assets/Scenes/CodeDEV.unity @@ -928,6 +928,12 @@ Prefab: m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: dd625f75dbf83194392a299951cf04fb, type: 2} m_IsPrefabParent: 0 +--- !u!114 &974873814 stripped +MonoBehaviour: + m_PrefabParentObject: {fileID: 114745107968250074, guid: 460d856ea4eb14cedb5fecde1fe6d743, + type: 2} + m_PrefabInternal: {fileID: 1379476068} + m_Script: {fileID: 11500000, guid: d819f21fefea9da4199b468cca99e711, type: 3} --- !u!1 &1028937042 GameObject: m_ObjectHideFlags: 0 @@ -1189,6 +1195,46 @@ Prefab: propertyPath: m_IsActive value: 0 objectReference: {fileID: 0} + - target: {fileID: 224351136746992674, guid: 460d856ea4eb14cedb5fecde1fe6d743, + type: 2} + propertyPath: m_LocalRotation.z + value: 0.7771459 + objectReference: {fileID: 0} + - target: {fileID: 224351136746992674, guid: 460d856ea4eb14cedb5fecde1fe6d743, + type: 2} + propertyPath: m_LocalRotation.w + value: 0.62932044 + objectReference: {fileID: 0} + - target: {fileID: 224351136746992674, guid: 460d856ea4eb14cedb5fecde1fe6d743, + type: 2} + propertyPath: m_LocalEulerAnglesHint.z + value: 102 + objectReference: {fileID: 0} + - target: {fileID: 224351136746992674, guid: 460d856ea4eb14cedb5fecde1fe6d743, + type: 2} + propertyPath: m_AnchoredPosition.x + value: -1.7573471 + objectReference: {fileID: 0} + - target: {fileID: 224351136746992674, guid: 460d856ea4eb14cedb5fecde1fe6d743, + type: 2} + propertyPath: m_AnchoredPosition.y + value: -4.5857997 + objectReference: {fileID: 0} + - target: {fileID: 224351136746992674, guid: 460d856ea4eb14cedb5fecde1fe6d743, + type: 2} + propertyPath: m_Pivot.x + value: 0.06394628 + objectReference: {fileID: 0} + - target: {fileID: 224351136746992674, guid: 460d856ea4eb14cedb5fecde1fe6d743, + type: 2} + propertyPath: m_Pivot.y + value: 0.06415958 + objectReference: {fileID: 0} + - target: {fileID: 114917026543374048, guid: 460d856ea4eb14cedb5fecde1fe6d743, + type: 2} + propertyPath: brakeBarController + value: + objectReference: {fileID: 974873814} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} m_IsPrefabParent: 0 diff --git a/Assets/Scripts/BrakeBarController.cs b/Assets/Scripts/BrakeBarController.cs index 774a104..12c60f8 100644 --- a/Assets/Scripts/BrakeBarController.cs +++ b/Assets/Scripts/BrakeBarController.cs @@ -4,28 +4,31 @@ using UnityEngine; public class BrakeBarController : MonoBehaviour { - float currentRotation; - float maxRotation; + float maxRotation = 129; + float currentRotation = 0; private Player player; // Update is called once per frame void Update() { + float offset = 0; // if player alive and spawned - if ( player != null ) { - UpdatePointer(maxRotation); - } else if (currentRotation != 0) { - //if player dead or not spawned - UpdatePointer(0); + if (player != null) { + offset = CalculateOffset(); } + else { + offset = -currentRotation; + } + currentRotation += offset; + gameObject.transform.Rotate(Vector3.forward, -offset); } - private void UpdatePointer(float brakesLeft) { - float offset = brakesLeft - currentRotation; - gameObject.transform.Rotate(Vector3.forward, offset); - currentRotation += offset; + private float CalculateOffset() { + return (maxRotation * (player.GetComponent().brakeTime / player.GetComponent().maxBrakeTime)) - currentRotation; } public void SetPlayer(Player ply) { player = ply; + maxRotation = 129; + currentRotation = 0; } }