void Start() { AfficheScore = GetComponentInChildren <TextMesh>(); AfficheScore.color = Couleur; Gestion = FindObjectOfType <GestionnaireDeJeu>(); OriginalScale = transform.lossyScale.magnitude; cam = GameObject.Find("CameraJeu").GetComponent <Camera>(); rigid = GetComponent <Rigidbody>(); distToGround = GetComponent <Collider>().bounds.extents.y + (.25f * transform.localScale.y); timerTir = 1; if (MesControles is ProfilTactile) { MesControles = gameObject.AddComponent <ProfilTactile>(); Cursor.visible = false; } DebugAndroid.LogSpecific("Player_" + NumPlayer + " spawn", MesControles.ToString()); Line = GetComponentInChildren <LineRenderer>(); Invincible = true; Invoke("RemoveInvincibilite", 2); Invoke("ClignoteInvincible", .05f); Model3D.material.color = Couleur; Invoke("KillInactif", 5); }
// Start is called before the first frame update void Start() { LogSample.gameObject.SetActive(false); AfficherConsole = true; ToggleAfficheConsole(); btn_affiche.onClick.AddListener(ToggleAfficheConsole); InstanceThis = this; }
// Start is called before the first frame update void Start() { Gestion = FindObjectOfType <GestionnaireDeJeu>(); OriginalScale = transform.lossyScale.magnitude; cam = GameObject.Find("CameraJeu").GetComponent <Camera>(); rigid = GetComponent <Rigidbody>(); distToGround = GetComponent <Collider>().bounds.extents.y + (.25f * transform.localScale.y); timerTir = 1; /*MesControles = ProfilControle.GetMyProfil(this); * if (MesControles is ProfilTactile) * { * MesControles = gameObject.AddComponent<ProfilTactile>(); * Cursor.visible = false; * }*/ MesControles = gameObject.AddComponent <BotController>(); DebugAndroid.LogSpecific("Player_" + NumPlayer + " spawn", MesControles.ToString()); Line = GetComponentInChildren <LineRenderer>(); Invincible = true; Invoke("RemoveInvincibilite", 1); InvokeRepeating("ClignoteInvincible", 0, .1f); Model3D.material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); Model3D.material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); Model3D.material.SetInt("_ZWrite", 0); Model3D.material.DisableKeyword("_ALPHATEST_ON"); Model3D.material.DisableKeyword("_ALPHABLEND_ON"); Model3D.material.EnableKeyword("_ALPHAPREMULTIPLY_ON"); Model3D.material.renderQueue = 3000; foreach (Transform tr in GetComponentsInChildren <Transform>()) { tr.gameObject.layer = 11; } Color transparent = Couleur; transparent.a = .5f; Model3D.material.color = transparent; ParticleSystem SpawnParticle = FindObjectOfType <ParticleSystem>(); SpawnParticle.startColor = Couleur; SpawnParticle.Play(); /* Gradient grad = new Gradient(); * grad.colorKeys = new GradientColorKey[2] { new GradientColorKey(Color.red, 0), new GradientColorKey(Color.red, 1) }; * grad.alphaKeys = new GradientAlphaKey[3] { new GradientAlphaKey(.75f,0),new GradientAlphaKey(.75f,.5f), new GradientAlphaKey(0, 1) }; ; * Line.colorGradient = grad;*/ }
public void SaveProfil() { string SaveString = PreWord + ";" + Axe_X + ";" + InvertX.ToString() + ";" + Axe_Y + ";" + InvertY.ToString() + ";" + Axe_X2 + ";" + InvertX2.ToString() + ";" + Axe_Y2 + ";" + InvertY2.ToString() + ";" + Key_Jump + ";" + Key_Shoot; PlayerPrefs.SetString(NomProfil, SaveString); DebugAndroid.Log(NomProfil + '\n' + SaveString); }
// Start is called before the first frame update protected virtual void Start() { Horloge.text = string.Format("{0}:{1:00}", TempsDeJeu / 60, TempsDeJeu % 60); DecompteDebut(); if (SceneDeRetour == "") { btn_rejouer.onClick.AddListener(() => { SceneManager.LoadScene(SceneManager.GetActiveScene().name); }); } else { btn_rejouer.onClick.AddListener(() => { SceneManager.LoadScene(SceneDeRetour); }); } btn_rejouer.gameObject.SetActive(false); Bip = gameObject.AddComponent <AudioSource>(); Bip.clip = Bip1; TotalTempsJeu = TempsDeJeu; originalTime = Time.time + 3; PlayerPrefs.SetString("Clavier/Souris", ";Horizontal;False;Vertical;False;Mouse X;False;Mouse Y;False;space;mouse 0;"); DebugAndroid.Log(GetControllersResume()); if (UtiliséClavierSouris) { NombreJoueur = 1 + Input.GetJoystickNames().Length; Cursor.SetCursor(StyleCurseur, new Vector2(StyleCurseur.width / 2, StyleCurseur.height / 2), CursorMode.ForceSoftware); if (NombreJoueur > 7) { NombreJoueur = 7; } } else { Cursor.visible = false; NombreJoueur = Input.GetJoystickNames().Length; if (NombreJoueur > 6) { NombreJoueur = 6; } } LesSpawn.AddRange(FindObjectsOfType <Spawner>()); Invoke("SpawnAllPlayers", 1.5f); Invoke("Décompte", 1.5f); //SpawnAllPlayers(); int décallage = 0; for (int i = 0; i < NombreJoueur; i++) { if (i >= Input.GetJoystickNames().Length || Input.GetJoystickNames()[i] != "") { Text instance = Instantiate(UiScore.gameObject, canvas.transform).GetComponentInChildren <Text>(); instance.gameObject.transform.parent.position += Vector3.right * 110 * (i - décallage); instance.color = PlayColors[i]; LesAfficheursScore.Add(instance); } else { décallage++; LesAfficheursScore.Add(null); } } UiScore.gameObject.SetActive(false); }
// Update is called once per frame void Update() { SyncMove = true; #region Déplacement if (MesControles.GetX() != 0) { DebugAndroid.LogSpecific("Player_" + NumPlayer + " move", "is moving, speed : " + MesControles.GetX()); float acceleration = 5; if (MesControles.GetX() > 0 == rigid.velocity.x > 0) { acceleration = (Mathf.Abs(MesControles.GetX() * 5) - Mathf.Abs(rigid.velocity.x)); if (acceleration < 0) { acceleration = 0; } } acceleration = MesControles.GetX() * acceleration; /*if (MesControles.GetX() > 0) * { * if (rigid.velocity.x > 5) * acceleration = 0; * else * acceleration = 5 - rigid.velocity.x; * } * else * { * if (rigid.velocity.x < -5) * acceleration = 0; * else * acceleration = -5 - rigid.velocity.x; * }*/ if (isGrounded()) { rigid.velocity += Vector3.right * acceleration * Time.deltaTime * 5; } else { rigid.velocity += Vector3.right * acceleration * Time.deltaTime * 3; } } else { DebugAndroid.LogSpecific("Player_" + NumPlayer + " move", "is stopped"); if (isGrounded()) { rigid.velocity -= Vector3.right * rigid.velocity.x * 10 * Time.deltaTime; } } #endregion ////////// #region Saut if (MesControles.GetJump() && isGrounded() && canJump) { rigid.velocity += Vector3.up * 7.5f; canJump = false; Invoke("ResetCanJump", .2f); } #endregion ////////// #region Orientation Bazooka if (MesControles.NomProfil == "Clavier/Souris") { Vector3 point = cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -cam.transform.localPosition.z)); DirectionTir = point - transform.position; } else if (MesControles is ProfilTactile) { ProfilTactile MyCont = (ProfilTactile)MesControles; Vector2 position = MyCont.ShotPosition; Vector3 point = cam.ScreenToWorldPoint(new Vector3(position.x, position.y, -cam.transform.localPosition.z)); DirectionTir = point - transform.position; } else { DirectionTir += (MesControles.GetX2() * Vector3.right + MesControles.GetY2() * Vector3.up) * 2000 * Time.deltaTime; } DirectionTir.Normalize(); //Bazooka.localEulerAngles = Vector3.right * Mathf.Atan2(DirectionTir.x, DirectionTir.y) * Mathf.Rad2Deg; //Animation if (isGrounded()) { float speed = DirectionTir.x * rigid.velocity.x; anim.SetBool("Flying", false); if (Mathf.Abs(speed) < .1f) { anim.SetBool("Stop", true); anim.speed = 1; } else { anim.SetBool("Stop", false); anim.SetBool("MarcheDroite", speed > 0); anim.speed = Mathf.Abs(rigid.velocity.x); } } else { anim.SetBool("Flying", true); anim.speed = 1; } Line.SetPosition(1, new Vector3(0, DirectionTir.y, DirectionTir.x)); Line.SetPosition(2, new Vector3(0, DirectionTir.y * 1.15f, DirectionTir.x * 1.15f)); body.localEulerAngles = new Vector3(0, -90 * DirectionTir.x + 90, 0); Spine1.localEulerAngles = Spine2.localEulerAngles = new Vector3(-25 * DirectionTir.y + 15, 0, 0); #endregion ////////// #region Tir timerTir += Time.deltaTime; if (MesControles.GetShoot() && timerTir >= 1) { timerTir = 0; GameObject instance = Instantiate(Rocket, new Vector3(Bazooka.position.x, Bazooka.position.y, transform.position.z), Quaternion.Euler(DirectionTir)); instance.GetComponent <Rocket>().SetSpeed(DirectionTir, 15f, this); } #endregion }