From e484685210b4db2ee2ab21e0a71d0fe9043ae81d Mon Sep 17 00:00:00 2001 From: Carson Katri Date: Sun, 13 Jun 2021 09:15:00 -0400 Subject: Add shot indicator --- Assets/Scripts/Controllers/AIController.cs | 2 +- Assets/Scripts/Controllers/Player/PlayerController.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'Assets/Scripts') diff --git a/Assets/Scripts/Controllers/AIController.cs b/Assets/Scripts/Controllers/AIController.cs index 7246023..5a3761c 100644 --- a/Assets/Scripts/Controllers/AIController.cs +++ b/Assets/Scripts/Controllers/AIController.cs @@ -71,7 +71,7 @@ namespace Controllers private static readonly int Running = Animator.StringToHash("Running"); private void FixedUpdate() { - Animator.SetBool(Running, (lastPosition - transform.position).x > 0.025); + Animator.SetBool(Running, (lastPosition - transform.position).x > 0.015); lastPosition = transform.position; } diff --git a/Assets/Scripts/Controllers/Player/PlayerController.cs b/Assets/Scripts/Controllers/Player/PlayerController.cs index 134abdc..e555bec 100644 --- a/Assets/Scripts/Controllers/Player/PlayerController.cs +++ b/Assets/Scripts/Controllers/Player/PlayerController.cs @@ -19,6 +19,9 @@ namespace Controllers.Player [SerializeField] private float maxLegAngle; [SerializeField] private float legSpeed; + [SerializeField] private GameObject progressBarContainer; + [SerializeField] private GameObject progressBar; + public PlayerSegment root => segments[0]; private float ShootStartTime; @@ -102,10 +105,19 @@ namespace Controllers.Player // Try shooting the ball if pressed. if (Input.GetKeyDown(controls.shoot)) + { ShootStartTime = Time.time; + progressBarContainer.SetActive(true); + } + + progressBar.transform.localScale = new Vector3(0.75f * Mathf.Clamp(Time.time - ShootStartTime, 0f, 1f), 0.05f, 1f); + // progressBar.transform.localPosition = new Vector3(0.75f * (1 - Mathf.Clamp(Time.time - ShootStartTime, 0f, 1f)), 0f, 0f); if (Input.GetKeyUp(controls.shoot)) + { game.player.Shoot(segments.Last().transform, Time.time - ShootStartTime); + progressBarContainer.SetActive(false); + } } [Serializable] -- cgit v1.2.3-56-ge451