void Update()
 {
     if (data == null)
     {
         data = SaveLoadSystem.LoadPlayer();
         ReadSaveFile();
     }
 }
    public void OnLoadClicked()
    {
        PlayerData playerData = SaveLoadSystem.LoadPlayer();

        if (playerData != null)
        {
            DataManager.PlayerHealth = playerData.playerHealth;
            DataManager.PlayerName   = playerData.playerName;
            DataManager.PlayerScore  = playerData.playerScore;
            playerHealthTxt.SetText("Health: " + DataManager.PlayerHealth.ToString());
            playerNameTxt.SetText("Name: " + DataManager.PlayerName);
            playerScoreTxt.SetText("Score: " + DataManager.PlayerScore.ToString());
            Debug.Log("Loaded");
        }
    }
 void Start()
 {
     GameCanvs = GetComponent <CanvasUpdater>().GameCanvas.gameObject;
     PopText   = GameCanvs.transform.Find("PopText").GetComponent <Text>();
     WorldName = GameCanvs.transform.Find("WorldName").GetComponent <Text>();
     DegreeT   = GameCanvs.transform.Find("DegreeT").GetComponent <Text>();
     DateText  = GameCanvs.transform.Find("DateText").GetComponent <Text>();
     SpeedText = GameCanvs.transform.Find("SpeedText").GetComponent <Text>();
     if (SaveLoadSystem.HasSaved())
     {
         gameData = SaveLoadSystem.LoadPlayer();
     }
     else
     {
         gameData = new GameData().GameDataNew(GetComponent <SelectButtons>().worldNum);
     }
     worldData = new Finder().WorldFinder(gameData.worldnum);
 }
    public void LoadPlayer()
    {
        PlayerSaveData data = SaveLoadSystem.LoadPlayer();

        if (data != null)
        {
            _level     = data.level;
            _money     = data.money;
            _inventory = new Inventory(data.inventory);
            Vector3 pos;
            pos.x = data.position[0];
            pos.y = data.position[1];
            pos.z = data.position[2];
            transform.position = pos;
        }
        else
        {
            _level     = 1;
            _money     = 0;
            _inventory = new Inventory();
            SavePlayer();
        }
    }
 void Start()
 {
     StartCoroutine(LoadingScene(1));
     saveLoadSystem = transform.GetComponent <SaveLoadSystem>();
     saveLoadSystem.LoadPlayer();
 }
    public override void Update()
    {
        base.Update(); //Our parent update method

        ReadJoystickValues();

        manaUsageCoroutine = PassiveManaUsage(0.05f, 1f);

        //Set up all animator parameters
        animator.SetBool("isWalking", controller.isWalking);
        animator.SetBool("isDescending", controller.isDescending);
        animator.SetBool("isInGround", controller.isInGround);
        animator.SetBool("isAscending", controller.isAscending);
        animator.SetBool("isDashing", controller.isDashing);

        if (GameManager.Instance.currentHealth == 0)
        {
            SaveLoadSystem.LoadPlayer();
        }

        if (GameManager.Instance.currentMana == 0)
        {
            Ascend();
        }

        GetClosestEnemy();

        if (closestObject == null)
        {
            targetNear            = false;
            Magic_Movement.radius = Magic_Movement.defaultRadius;
        }


        //Checking if hiding in the ground
        if (controller.isInGround)
        {
            player_collider.radius = 0.1f;
            player_collider.offset = new Vector2(-0.00999999f, -0.4f);

            if (manaDrop == false)
            {
                StartCoroutine(manaUsageCoroutine);
            }
        }
        else
        {
            player_collider.radius    = 0.32f;
            player_collider.offset    = new Vector2(-0.00999999f, 0.02180004f);
            player_collider.isTrigger = false;
        }

        if (controller.toggleLock)
        {
            if (transform.position.x > closestObject.transform.position.x)
            {
                Flip(-1);
            }
            else if (transform.position.x < closestObject.transform.position.x)
            {
                Flip(1);
            }
        }

        //For our blinking effect
        if (gotHit == true)
        {
            GetHurt(0.15f, 5f);
            renderer.enabled = isRendererEnabled;
        }
        else
        {
            isRendererEnabled = true;
            renderer.enabled  = isRendererEnabled;
        }
    }