// Use this for initialization void Start() { door = GameObject.FindGameObjectWithTag("Door"); player = GameObject.FindGameObjectWithTag("Player"); LevelSetup.SetUpLevel(1, loadingScreen, slider, progressText, audioSource, musicVolume); Gamemanager.SavePlayer(player.GetComponent <PlayerController>(), Gamemanager.LastLevel); }
private void takeCheckpoint(GameObject cp, int cpIndex) { Gamemanager.LastCheckpointPosition = cp.transform.position; cp.GetComponent <SpriteRenderer>().sprite = checkpointSprites[1]; Gamemanager.CheckPointCounter = cpIndex; Gamemanager.DeathCounter = 0; Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel); }
public static void LoadPlayer(int levelIndex, GameObject[] cps) { GameObject player = GameObject.FindGameObjectWithTag("Player"); PlayerController playerController = player.GetComponent <PlayerController>(); int counter = 0; foreach (GameObject cp in cps) { if (cp.transform.position != Gamemanager.LastCheckpointPosition) { counter++; } else { continue; } if (counter == cps.Length) { Gamemanager.LastCheckpointPosition = cps[0].transform.position; } } if (Gamemanager.HighestLevel < levelIndex) { player.transform.position = cps[0].transform.position; Gamemanager.PlayerHealth = Gamemanager.PlayerMaxHealth; Gamemanager.LastCheckpointPosition = cps[0].transform.position; Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel); } else if (Gamemanager.LastLevel == levelIndex && !Gamemanager.PlayerDead) { Gamemanager.LoadPlayer(levelIndex); player.transform.position = Gamemanager.SavedPlayerPositions[levelIndex]; Gamemanager.PlayerHealth = Gamemanager.PlayerMaxHealth; Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel); Gamemanager.PlayerDead = false; } else if (Gamemanager.PlayerDead) { player.transform.position = Gamemanager.LastCheckpointPosition; Gamemanager.PlayerHealth = Gamemanager.PlayerMaxHealth; Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel); Gamemanager.PlayerDead = false; } else { Gamemanager.LoadPlayer(levelIndex); player.transform.position = Gamemanager.SavedPlayerPositions[levelIndex]; PlayerController.Health = Gamemanager.PlayerHealth; } }
public void DeleteSaves() { SaveSystem.DeleteSaves(); Gamemanager.SavePlayer(); }
public void Exit() { Gamemanager.SavePlayer(); Gamemanager.LoadScene("Start menu"); }
private void CheckPlayerInput() { PlayerPhysics.MoveDirectionX = 0; PlayerPhysics.MoveDirectionY = 0; if (PlayerController.Health > 0 && !PlayerController.CanExit) { PlayerPhysics.MoveDirectionX = Input.GetAxisRaw("Horizontal"); if (Input.GetKeyDown(KeyCode.LeftShift)) { PlayerController.IsDoged = true; } if (Input.GetKeyUp(KeyCode.LeftShift)) { PlayerController.IsDoged = false; } if (Input.GetKeyDown(KeyCode.I)) { powerShot = StartCoroutine(playerController.EmpoweredShot()); } if (Input.GetKeyUp(KeyCode.I) && !FireEmpowered()) { if (powerShot != null) { PlayerController.PowerShot = false; PlayerController.ShotCount = 0; StopCoroutine(powerShot); } StartCoroutine(playerController.Shoot()); } } if (Input.GetKeyDown(KeyCode.Space)) { PlayerPhysics.Jump(); if (PlayerController.CanExit || PlayerController.CanRestart) { playerController.VictoryScreen.SetActive(false); playerController.DeathScreen.SetActive(false); Gamemanager.RestartGame(); } } if (Input.GetKey(KeyCode.Space) && PlayerPhysics.InWater) { PlayerPhysics.Swim(); } if (Input.GetKeyDown(KeyCode.Escape)) { if (PlayerController.CanExit) { playerController.VictoryScreen.SetActive(false); Gamemanager.LastLevel++; Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel); Gamemanager.ExitLevel(); } else if (PlayerController.CanUnpause) { StartCoroutine(playerController.Unpause()); } else if (PlayerController.Health < 1 && PlayerController.CanRestart) { playerController.DeathScreen.SetActive(false); Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel); Gamemanager.ExitLevel(); } else if (PlayerController.Health > 0 && !PlayerController.CanUnpause) { StartCoroutine(playerController.Pause()); } } if (Input.GetKeyDown(KeyCode.S)) { if (PlayerController.CanUnpause) { playerController.PauseScreen.SetActive(false); Audiomanager.StopMusic(); Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel); Gamemanager.ExitLevel(); } } if (Input.GetKeyDown(KeyCode.E)) { Interact = true; } else if (Input.GetKeyUp(KeyCode.E)) { Interact = false; } if (OnLadder) { PlayerPhysics.MoveDirectionY = Input.GetAxisRaw("Vertical"); } }