//Awake is always called before any Start functions (called zero) void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; // Get different component managers nivelesManager = GetComponent <NivelesManager>(); uiManager = GetComponent <UIManager>(); sceneTransitions = GetComponent <SceneTransitions>(); tutorialScript = GetComponent <Tutorial>(); //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); //Call the InitGame function to initialize the game InitGame(); } else if (instance != this) //If instance already exists and it's not this: { DestroyImmediate(gameObject); //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. } // Get actual scene name currentScene = SceneManager.GetActiveScene(); }
public void Actualizar() { if (Vida == 0) { _estadoVivo = false; NivelesManager.Perdiste(); } else { Entrada(); Dibujar(); } //Actualizo las armas activas. if (CuchillosEnUso.Count > 0) { for (int i = 0; i < CuchillosEnUso.Count; i++) { CuchillosEnUso[i].Actualizar(); } } SetearLimites(); if (Colisiona()) { //ObtenerDatosColision(e1); Vida -= 1; X = 100; Y = 100; } }
static void Main(string[] args) { Engine.Initialize("A ver q onda"); //Cuando comienza el juego, empieza en el menu principal. Luego entra en el GameLoop NivelesManager.AccederMenu(); pj = new Personaje(100F, 500F); while (true) { Engine.Clear(); NivelesManager.EjecutarNivelActual(); if (Jugando) { if (Engine.GetKey(Keys.Q)) { MenuManager.GuardarPartida(); } } Engine.Show(); } }
public void Entrada() { if (Engine.GetKey(Keys.LEFT) && (X - PersonajeIzquierda.Width / 2) > 45) { X -= _velocidad; _derecha = false; } else if (Engine.GetKey(Keys.RIGHT) && (X + PersonajeIzquierda.Width / 2) < 750) { X += _velocidad; _derecha = true; } if (Engine.GetKey(Keys.UP)) { if (Y - EscalaY > 40) { Y -= _velocidad; } } else if (Engine.GetKey(Keys.DOWN)) { if (Y + EscalaY < 565) { Y += _velocidad; } } if (Engine.GetKey(Keys.S)) { LanzarCuchillo(); } //Menu if (Engine.GetKey(Keys.Z)) { NivelesManager.AccederMenu(); } }