// Use this for initialization void Start() { mode_jeu = PlayerPrefs.GetInt("mode_jeu", mode_jeu); if (PlayerPrefs.HasKey("mode_jeu")) { mode_jeu = PlayerPrefs.GetInt("mode_jeu", mode_jeu); } else { PlayerPrefs.SetInt("mode_jeu", mode_jeu); } vie_restante = vaisseau.GetComponent <vie>(); mort = new string[vvv.Length, 3]; all_vaisseaux = new vie[vvv.Length]; for (int i = 0; i < vvv.Length; i++) { all_vaisseaux[i] = vvv[i].GetComponent <vie>(); if (all_vaisseaux[i] == null) { all_vaisseaux[i] = vvv[i].GetComponentInChildren <vie>(); } } }
void Awake() { camera.enabled = networkView.isMine; //vie_restante = vaisseau.GetComponents<vie>()[0]; vie_restante = vaisseau.GetComponent <vie>(); }
void nouveau_joueur() { Vector3 pos = Vector3.zero; System.Random rnd = new System.Random(); pos.Set(rnd.Next(-100, 100), rnd.Next(-10, 50), rnd.Next(-100, 100)); //pos.Set(50, 0, 0); //Debug.Log(Network.peerType); switch (choix) { case 1: vaisseau_multi = (GameObject)Network.Instantiate(vaisseau1_multi, pos, Quaternion.AngleAxis(0, Vector3.left), 0); break; case 2: vaisseau_multi = (GameObject)Network.Instantiate(vaisseau2_multi, pos, Quaternion.AngleAxis(0, Vector3.left), 0); break; case 3: vaisseau_multi = (GameObject)Network.Instantiate(vaisseau3_multi, pos, Quaternion.AngleAxis(0, Vector3.left), 0); break; } vie life = vaisseau_multi.GetComponent <vie>(); if (life == null) { life = vaisseau_multi.GetComponentInChildren <vie>(); } life.name = this.name; life.all_spaceships = this.all_spaceships; life.global_cam = this.camera; this.camera.enabled = false; int i = 0; while (i < all_spaceships.Length && all_spaceships[i] != null) { i++; } //Debug.Log(i); if (i < all_spaceships.Length) { all_spaceships[i] = vaisseau_multi; Camera first = all_spaceships[i].GetComponentInChildren <Camera>(); controlcameramulti firstcontrol = first.GetComponent <controlcameramulti>(); firstcontrol.vvv = this.all_spaceships; } //vaisseau.camera.enabled = true; }
void OnGUI() { //Debug.Log ("test pv :" + life); try { Player = GameObject.Find("IL EST BEAU LE VAISSEAU OUI OUI"); } catch { Player = GameObject.Find("vaisseau1"); } vie bob = Player.GetComponent <vie>(); life_gui.text = bob.VAFANCULO().ToString(); if (bob.VAFANCULO() < 1) { life_gui.text = ""; } }
void OnGUI() { //Debug.Log ("test pv :" + life); try { thePlayer = GameObject.Find("le him is le player 2"); } catch { thePlayer = GameObject.Find("vaisseau2"); } vie bob = thePlayer.GetComponent <vie>(); life_gui.text = bob.VAFANCULO().ToString(); if (bob.VAFANCULO() < 1) { life_gui.text = ""; } }
// Use this for initialization void Start() { VI = otherObject.GetComponent <vie>(); cpl = otherObject.GetComponent <controlplayer>(); }
// Update is called once per frame void Update() { if ((limite_temps - Convert.ToInt32(Time.time - startTime)) < 1) { GameObject steveGameObject; try { stop = 1 / stop; try { steveGameObject = set.all_spaceships[0]; /*Debug.Log("Propre"); */ } catch { steveGameObject = GameObject.Find("IL EST BEAU LE VAISSEAU OUI OUI"); } /*Debug.Log("pdnt");*/ AudioSource shut = steveGameObject.GetComponent <AudioSource>(); //Debug.Log("avant"); if (shut == null) { shut = steveGameObject.GetComponentInChildren <AudioSource>(); } //Debug.Log("apres"); shut.audio.clip = endgame_sound; shut.PlayOneShot(endgame_sound); //Debug.Log("debug son"); stop--; } catch { } try { foreach (var item in set.all_spaceships) { item.GetComponent <controlcamera>(); } } catch { /*Debug.Log("non");*/ } vie john = GameObject.Find("IL EST BEAU LE VAISSEAU OUI OUI").GetComponent <vie>(); john.gameover("GAME DRAW"); //GameObject vaisseau = set.all_spaceships[0]; /* int stockage = -100; * int index = 0; * bool egalite = false; * for (int i = 0; i < set.all_spaceships.Length; i++) * { * vie life = set.all_spaceships[i].GetComponent<vie>(); * if(life == null) * { * life = set.all_spaceships[i].GetComponentInChildren<vie>(); * } * * try * { * set.all_spaceships[i].GetComponent<controlplayer>().enabled = false; * } * catch * { * set.all_spaceships[i].GetComponentInChildren<controlplayer>().enabled = false; * } * * if (life.frag_limite >= stockage) * { * if (life.frag_limite == stockage) * { * egalite = true; * } * else * { * egalite = false; * stockage = life.frag_limite; * index = i; * } * } * } * * if (!egalite) * { * try * { * set.all_spaceships[index].GetComponent<vie>().gameover(set.all_spaceships[index].GetComponent<vie>().name + " WIN"); * } * catch * { * set.all_spaceships[index].GetComponentInChildren<vie>().gameover(set.all_spaceships[index].GetComponentInChildren<vie>().name + " WIN"); * } * } * else * { * try * { * set.all_spaceships[0].GetComponent<vie>().gameover("GAME DRAW"); * } * catch * { * set.all_spaceships[index].GetComponentInChildren<vie>().gameover("GAME DRAW"); * } * } */ } }
// Use this for initialization void Start() { #region PlayerPrefs Options volume = PlayerPrefs.GetFloat("Volume", volume); if (PlayerPrefs.HasKey("Volume")) { AudioListener.volume = PlayerPrefs.GetFloat("Volume"); } else { PlayerPrefs.SetFloat("Volume", volume); } son = PlayerPrefs.GetInt("son", son); if (PlayerPrefs.HasKey("son")) { son = PlayerPrefs.GetInt("son", son); switch (son) { case 0: AudioSettings.speakerMode = AudioSpeakerMode.Mono; break; case 1: AudioSettings.speakerMode = AudioSpeakerMode.Stereo; break; case 2: AudioSettings.speakerMode = AudioSpeakerMode.Quad; break; case 3: AudioSettings.speakerMode = AudioSpeakerMode.Surround; break; case 4: AudioSettings.speakerMode = AudioSpeakerMode.Mode5point1; break; case 5: AudioSettings.speakerMode = AudioSpeakerMode.Mode7point1; break; } } else { PlayerPrefs.SetInt("son", son); } qualite_image = PlayerPrefs.GetInt("qualite_image", qualite_image); if (PlayerPrefs.HasKey("qualite_image")) { qualite_image = PlayerPrefs.GetInt("qualite_image", qualite_image); QualitySettings.SetQualityLevel(qualite_image); } else { PlayerPrefs.SetInt("qualite_image", qualite_image); } aliasing = PlayerPrefs.GetInt("aliasing", aliasing); if (PlayerPrefs.HasKey("aliasing")) { aliasing = PlayerPrefs.GetInt("aliasing", aliasing); switch (aliasing) { case 0: QualitySettings.antiAliasing = 0; break; case 1: QualitySettings.antiAliasing = 2; break; case 2: QualitySettings.antiAliasing = 4; break; case 3: QualitySettings.antiAliasing = 8; break; } } else { PlayerPrefs.SetInt("aliasing", aliasing); } anisotropic = PlayerPrefs.GetInt("anisotropic", anisotropic); if (PlayerPrefs.HasKey("anisotropic")) { qualite_image = PlayerPrefs.GetInt("anisotropic", anisotropic); switch (anisotropic) { case 0: QualitySettings.anisotropicFiltering = AnisotropicFiltering.Disable; break; case 1: QualitySettings.anisotropicFiltering = AnisotropicFiltering.Enable; break; case 2: QualitySettings.anisotropicFiltering = AnisotropicFiltering.ForceEnable; break; } } else { PlayerPrefs.SetInt("anisotropic", anisotropic); } #endregion if (mode_jeu == 1) { #region setup un joueur nb_joueur = PlayerPrefs.GetInt("nb_ia", nb_joueur); if (PlayerPrefs.HasKey("nb_ia")) { nb_joueur = PlayerPrefs.GetInt("nb_ia", nb_joueur); } else { PlayerPrefs.SetInt("nb_ia", nb_joueur); } nb_joueur++; all_spaceships = new GameObject[nb_joueur]; choix = PlayerPrefs.GetInt("player", choix); if (PlayerPrefs.HasKey("player")) { choix = PlayerPrefs.GetInt("player", choix); } else { PlayerPrefs.SetInt("player", choix); } System.Random rnd = new System.Random(); Vector3 pos = Vector3.zero; pos.Set(rnd.Next(-100, 100), rnd.Next(-10, 50), rnd.Next(-100, 100)); //joueur switch (choix) { case 1: all_spaceships[0] = Instantiate(vaisseau1, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; case 2: all_spaceships[0] = Instantiate(vaisseau2, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; case 3: all_spaceships[0] = Instantiate(vaisseau3, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; default: all_spaceships[0] = Instantiate(vaisseau1, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; } //IAs for (int i = 1; i < nb_joueur; i++) { pos = Vector3.zero; pos.Set(rnd.Next(-100, 100), rnd.Next(-10, 50), rnd.Next(-100, 100)); try { switch (rnd.Next(0, 3)) { case 0: all_spaceships[i] = Instantiate(IA1, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; case 1: all_spaceships[i] = Instantiate(IA2, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; case 2: all_spaceships[i] = Instantiate(IA3, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; default: all_spaceships[i] = Instantiate(IA1, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; } } catch { } } Camera first = all_spaceships[0].GetComponentInChildren <Camera>(); controlcamera firstcontrol = first.GetComponent <controlcamera>(); firstcontrol.vvv = this.all_spaceships; for (int i = 0; i < all_spaceships.Length; i++) { vie life = all_spaceships[i].GetComponent <vie>(); if (life == null) { life = all_spaceships[i].GetComponentInChildren <vie>(); } life.global_cam = this.camera; life.all_spaceships = this.all_spaceships; if (i == 0) { life.name = "player"; } else { life.name = "computer " + i; } } #endregion } else if (mode_jeu == 2) { #region ecran splite nb_joueur = PlayerPrefs.GetInt("nb_ia", nb_joueur); if (PlayerPrefs.HasKey("nb_ia")) { nb_joueur = PlayerPrefs.GetInt("nb_ia", nb_joueur); } else { PlayerPrefs.SetInt("nb_ia", nb_joueur); } nb_joueur += 2; //aDebug.Log("nb joueur " + nb_joueur); all_spaceships = new GameObject[nb_joueur]; choix = PlayerPrefs.GetInt("player", choix); if (PlayerPrefs.HasKey("player")) { choix = PlayerPrefs.GetInt("player", choix); } else { PlayerPrefs.SetInt("player", choix); } System.Random rnd = new System.Random(); Vector3 pos = Vector3.zero; pos.Set(rnd.Next(-100, 100), rnd.Next(-10, 50), rnd.Next(-100, 100)); //joueur switch (choix) { case 1: all_spaceships[0] = Instantiate(vaisseau1, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; all_spaceships[1] = Instantiate(vaisseau1, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; case 2: all_spaceships[0] = Instantiate(vaisseau2, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; all_spaceships[1] = Instantiate(vaisseau2, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; case 3: all_spaceships[0] = Instantiate(vaisseau3, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; all_spaceships[1] = Instantiate(vaisseau3, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; default: all_spaceships[0] = Instantiate(vaisseau1, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; all_spaceships[1] = Instantiate(vaisseau1, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; } //IAs for (int i = 2; i < nb_joueur; i++) { pos = Vector3.zero; pos.Set(rnd.Next(-100, 50), rnd.Next(-10, 50), rnd.Next(-100, 100)); switch (rnd.Next(0, 3)) { case 0: all_spaceships[i] = Instantiate(IA1, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; case 1: all_spaceships[i] = Instantiate(IA2, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; case 2: all_spaceships[i] = Instantiate(IA3, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; default: all_spaceships[i] = Instantiate(IA1, pos, Quaternion.AngleAxis(0, Vector3.left)) as GameObject; break; } } Camera first = all_spaceships[0].GetComponentInChildren <Camera>(); first.rect = new Rect(0, 0, 1f, 0.5f); controlcamera firstcontrol = first.GetComponent <controlcamera>(); firstcontrol.vvv = this.all_spaceships; inputs toucheplayer1 = all_spaceships[0].GetComponentInChildren <inputs>(); toucheplayer1.i = 1; Camera second = all_spaceships[1].GetComponentInChildren <Camera>(); second.rect = new Rect(0, 0.5f, 1f, 0.5f); second.GetComponent <AudioListener>().enabled = false; controlcamera secondcontrol = second.GetComponent <controlcamera>(); secondcontrol.vvv = this.all_spaceships; inputs toucheplayer2 = all_spaceships[1].GetComponentInChildren <inputs>(); toucheplayer2.i = 2; for (int i = 0; i < all_spaceships.Length; i++) { vie life = all_spaceships[i].GetComponent <vie>(); if (life == null) { life = all_spaceships[i].GetComponentInChildren <vie>(); } life.global_cam = this.camera; life.all_spaceships = this.all_spaceships; if (i <= 1) { life.name = "player " + (i + 1); } else { life.name = "computer " + (i - 1); } } #endregion } else if (mode_jeu == 3) { #region multijoueur menu = 0; choix = PlayerPrefs.GetInt("player", choix); if (PlayerPrefs.HasKey("player")) { choix = PlayerPrefs.GetInt("player", choix); } else { PlayerPrefs.SetInt("player", choix); } #endregion } }