Advertisement
Guest User

while congela unity

a guest
Feb 18th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.36 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class botonseguro : MonoBehaviour
  6. {
  7.     public int x;
  8.     bool botonhasidopulsado = false;
  9.     public bool ganar;
  10.     public void boton1pulsado()
  11.     {
  12.         x = 1;
  13.         botonhasidopulsado = true;
  14.         Debug.Log(x);
  15.         Debug.Log(botonhasidopulsado);
  16.     }
  17.     public void boton2pulsado()
  18.     {
  19.         x = 2;
  20.         botonhasidopulsado = true;
  21.         Debug.Log(x);
  22.         Debug.Log(botonhasidopulsado);
  23.     }
  24.     public void boton3pulsado()
  25.     {
  26.         x = 3;
  27.         botonhasidopulsado = true;
  28.         Debug.Log(x);
  29.         Debug.Log(botonhasidopulsado);
  30.     }
  31.     public void boton4pulsado()
  32.     {
  33.         x = 4;
  34.         botonhasidopulsado = true;
  35.         Debug.Log(x);
  36.         Debug.Log(botonhasidopulsado);
  37.     }
  38.     public void boton6pulsado()
  39.     {
  40.         x = 6;
  41.         botonhasidopulsado = true;
  42.         Debug.Log(x);
  43.         Debug.Log(botonhasidopulsado);
  44.     }
  45.  
  46.     void Start()
  47.     {
  48.         List<int> botonesquehansalido = new List<int>();
  49.         int boton;
  50.         while (ganar)
  51.         {
  52.             boton = UnityEngine.Random.Range(1, 5);
  53.             botonesquehansalido.Add(boton);
  54.  
  55.             foreach (int numero in botonesquehansalido)
  56.             {
  57.                 switch (numero)
  58.                 {
  59.                     case 1:
  60.                         Debug.Log("a1");
  61.                         break;
  62.                     case 2:
  63.                         Debug.Log("a2");
  64.                         break;
  65.                     case 3:
  66.                         Debug.Log("a3");
  67.                         break;
  68.                     case 4:
  69.                         Debug.Log("a4");
  70.                         break;
  71.                 }
  72.             }
  73.             if (botonhasidopulsado == true)
  74.             {
  75.  
  76.                 foreach (int numeroc in botonesquehansalido)
  77.                 {
  78.                     //entrada de tocar, si tocar no es el boton que era, de momento lo hago con x
  79.                     if (x == numeroc)
  80.                     {
  81.                         ganar = true;
  82.                     }
  83.                     else if (x != numeroc)
  84.                     {
  85.                         ganar = false;
  86.                        
  87.                     }
  88.  
  89.                 }
  90.             }
  91.  
  92.         }
  93.  
  94.     }
  95.  
  96.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement