private void Awake() { if (pausar == null) { pausar = this; DontDestroyOnLoad(this.gameObject); } else { Destroy(this.gameObject); } }
void Start() { GameObject objetoFade = GameObject.Find("Fade"); if (objetoFade) { fade = objetoFade.GetComponent <SpriteRenderer>(); } pausar = GetComponent <Pausar>(); audioSource = GetComponent <AudioSource>(); if (SceneManager.GetActiveScene().buildIndex == 0) { CarregarCena("início"); } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.W)) { mov.Up(Player, speed); Player.Image = up; } if ((e.KeyCode == Keys.Down) || (e.KeyCode == Keys.S)) { mov.Down(Player, speed); Player.Image = down; } if ((e.KeyCode == Keys.Right) || (e.KeyCode == Keys.D)) { mov.Rigth(Player, speed); Player.Image = rigth; } if ((e.KeyCode == Keys.Left) || (e.KeyCode == Keys.A)) { mov.Left(Player, speed); Player.Image = left; } if (e.KeyCode == Keys.Escape) { Pausar pause = new Pausar(menu, timer3); } if (pictureBox1.Image != podre && pictureBox2.Image != podre && pictureBox3.Image != podre && pictureBox4.Image != podre && pictureBox5.Image != podre && pictureBox6.Image != podre && pictureBox7.Image != podre && pictureBox8.Image != podre && pictureBox9.Image != podre && pictureBox10.Image != podre && pictureBox11.Image != podre) { GerarColisao(); lb_score.Text = $"Score: {colisao.x.ToString()}"; } }