From 166a9f659d90cfe3e8d975e89d581df6986b13fc Mon Sep 17 00:00:00 2001 From: Jens Pitkanen Date: Sun, 4 Aug 2019 21:38:57 +0300 Subject: [PATCH] Add fun damage --- Assets/Scenes/GameOver.unity | 16 ++++++++-------- Assets/Scenes/Options.unity | 4 ++-- .../Scripts/AI/Behaviours/MeleeAttackFollowed.cs | 8 ++++++++ Assets/Scripts/HUDController.cs | 2 +- Assets/Scripts/PlayerFun.cs | 4 ++++ 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Assets/Scenes/GameOver.unity b/Assets/Scenes/GameOver.unity index 112600d..aa1683b 100644 --- a/Assets/Scenes/GameOver.unity +++ b/Assets/Scenes/GameOver.unity @@ -350,7 +350,7 @@ RectTransform: 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: 0, y: -250} + m_AnchoredPosition: {x: 0, y: -200} m_SizeDelta: {x: 250, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &181126609 @@ -560,7 +560,7 @@ RectTransform: 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: 0, y: -100} + m_AnchoredPosition: {x: 0, y: -70} m_SizeDelta: {x: 600, y: 200} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &317620729 @@ -585,10 +585,10 @@ MonoBehaviour: Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: m_Font: {fileID: 12800000, guid: f3ca06d8c094ade4180b1ebe0cecdf54, type: 3} - m_FontSize: 40 + m_FontSize: 32 m_FontStyle: 0 m_BestFit: 0 - m_MinSize: 4 + m_MinSize: 3 m_MaxSize: 72 m_Alignment: 4 m_AlignByGeometry: 0 @@ -908,7 +908,7 @@ RectTransform: 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: 0, y: -100} + m_AnchoredPosition: {x: 0, y: -70} m_SizeDelta: {x: 700, y: 200} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &783976060 @@ -933,10 +933,10 @@ MonoBehaviour: Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: m_Font: {fileID: 12800000, guid: c2b8548a6d222b44cbdceae5b971a677, type: 3} - m_FontSize: 40 + m_FontSize: 32 m_FontStyle: 0 m_BestFit: 0 - m_MinSize: 4 + m_MinSize: 3 m_MaxSize: 72 m_Alignment: 4 m_AlignByGeometry: 0 @@ -1178,7 +1178,7 @@ RectTransform: 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: 0, y: -250} + m_AnchoredPosition: {x: 0, y: -200} m_SizeDelta: {x: 250, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1382781933 diff --git a/Assets/Scenes/Options.unity b/Assets/Scenes/Options.unity index 7ca2320..fdd09b5 100644 --- a/Assets/Scenes/Options.unity +++ b/Assets/Scenes/Options.unity @@ -456,7 +456,7 @@ RectTransform: 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: 0, y: -250} + m_AnchoredPosition: {x: 0, y: -200} m_SizeDelta: {x: 250, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &570541436 @@ -1219,7 +1219,7 @@ RectTransform: 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: 0, y: -250} + m_AnchoredPosition: {x: 0, y: -200} m_SizeDelta: {x: 250, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &2030313146 diff --git a/Assets/Scripts/AI/Behaviours/MeleeAttackFollowed.cs b/Assets/Scripts/AI/Behaviours/MeleeAttackFollowed.cs index 797fe92..831cca5 100644 --- a/Assets/Scripts/AI/Behaviours/MeleeAttackFollowed.cs +++ b/Assets/Scripts/AI/Behaviours/MeleeAttackFollowed.cs @@ -63,6 +63,7 @@ namespace Saltosion.OneWeapon.AI.Behaviours { AnimatableTransform.position = Vector2.Lerp(Root, Target, AnimationProgress); if (AnimationProgress >= 1.0f) { // Attack hit, deal damage and start return animation + TakeFunDamage(); AttackHit = true; AnimationProgress = 0.0f; } @@ -79,6 +80,13 @@ namespace Saltosion.OneWeapon.AI.Behaviours { return false; } + private void TakeFunDamage() { + PlayerFun Player = Follow.Target.GetComponent(); + if (Player != null) { + Player.TakeDamage(); + } + } + private void OnDrawGizmosSelected() { Gizmos.color = Color.red; Gizmos.DrawWireSphere(transform.position, MeleeRange); diff --git a/Assets/Scripts/HUDController.cs b/Assets/Scripts/HUDController.cs index d3c56d0..f9590d0 100644 --- a/Assets/Scripts/HUDController.cs +++ b/Assets/Scripts/HUDController.cs @@ -55,7 +55,7 @@ namespace Saltosion.OneWeapon { DamageTextFun.color = FunColor; FunTextFun.color = FunColor; - int FunLevelInt = (int)Mathf.Min(Mathf.Floor(FunPercent * 6), 5); + int FunLevelInt = (int)Mathf.Clamp(Mathf.Floor(FunPercent * 6), 0, 5); FunTextGore.text = GoreTexts[FunLevelInt]; FunTextFun.text = FunTexts[FunLevelInt]; diff --git a/Assets/Scripts/PlayerFun.cs b/Assets/Scripts/PlayerFun.cs index fbbb073..d95c010 100644 --- a/Assets/Scripts/PlayerFun.cs +++ b/Assets/Scripts/PlayerFun.cs @@ -53,6 +53,10 @@ namespace Saltosion.OneWeapon { CurrentFun = Mathf.Min(MaxFun, NewFun); } + public void TakeDamage() { + AddFun(-5f); + } + public void ReceiveNewWeapon() { AddFun(WeaponFun); }