From 07fdedc8529dadd02c0b0940dc38f8a00e93c0a0 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Tue, 19 Dec 2023 16:32:13 +0000
Subject: [PATCH] Added scene fade in/out

---
 Assets/Scripts/PlayerController.cs |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs
index f918a23..8480803 100644
--- a/Assets/Scripts/PlayerController.cs
+++ b/Assets/Scripts/PlayerController.cs
@@ -1,3 +1,4 @@
+using Assets.Scripts.Helpers;
 using System;
 using System.ComponentModel.Design;
 using UnityEngine;
@@ -12,12 +13,12 @@
     private float maxFallSpeedCurrent = 0f;
     Vector2 moveInput;
 
-    Rigidbody2D rb;
+    public Rigidbody2D rb;
     Animator animator;
     Animator animator_rotor;
     public GameObject rotorGO;
     TouchingDirections touchingDirections;
-    Damageable health;
+    public Damageable health;
 
     [SerializeField]
     private bool _isMoving;
@@ -63,7 +64,7 @@
     {
         get
         {
-            return animator.GetBool(AnimationStrings.canMove);
+            return animator.GetBool(AnimationStrings.canMove) && !PauseMenu.GameIsPaused;
         }
     }
 
@@ -76,6 +77,17 @@
         animator_rotor = rotorGO.GetComponent<Animator>();
         touchingDirections = GetComponent<TouchingDirections>();
         health = GetComponent<Damageable>();
+        if (SaveSystem.isGameLoaded)
+        {
+            GameObject uiManager = GameObject.Find("GameManager");
+            uiManager.GetComponent<GameManager>().GameLoaded();
+            SaveData save = SaveSystem.LoadPlayer();
+            health.MaxHealth = save.maxHealth;
+            health.Health = save.health;
+            transform.position = VectorHelper.ConvertToVector3(save.position);
+            rb.velocity = VectorHelper.ConvertToVector2(save.velocity);
+            SaveSystem.isGameLoaded = false;
+        }
     }
 
     private void FixedUpdate()
@@ -159,9 +171,14 @@
         }
     }
 
+    public void TakeDamage(int damage)
+    {
+        health.Hit(damage);
+    }
+
     public void TakeFallDamage(int fallDamage)
     {
-        health.Hit(fallDamage);
+        TakeDamage(fallDamage);
     }
 
     //public void OnRun(InputAction.CallbackContext context)

--
Gitblit v1.9.3