// Start is called before the first frame update void Start() { rope_system = GameObject.Find("Rope_System").GetComponent <Rope_System>(); blink = GetComponent <Blinking_Effect>(); players = Camera.main.GetComponent <GameManager>().players_Movement; ropeSystemGetChild = rope_system.gameObject; cameraTransform = Camera.main.GetComponent <Transform>(); moneyDrop = GetComponent <moneyDrop>(); foreach (Transform child in transform) { if (child.name != "CleanCollision" && child.name != "TP_points") { list_trig.Add(child.GetComponent <encer_trig>()); } } num_triggered = 8; timerCut_TOT = 0.7f; animator = GetComponent <Animator>(); curr_delay_tp = delay_tp; targets.Clear(); targets.Add(rope_system.get_points()[0].transform); targets.Add(rope_system.get_points()[rope_system.NumPoints - 1].transform); foreach (GameObject point in tp_points) { tp_points_positions.Add(point.transform.position); } }
// Update is called once per frame void FixedUpdate() { if (target != null) { if (GetDistance(target) < detectionDistance) { Follow(); //animator.SetBool("running", true); } else { //animator.SetBool("running", false); } } if (target == null) { foreach (GameObject Obj in GameObject.FindGameObjectsWithTag("player")) { allPlayers.Add(Obj); } if (rope_system.get_points().Count > 0) { target = rope_system.get_points()[rope_system.NumPoints / 2].gameObject; } } if (dead) { transform.localScale = Vector3.Lerp(transform.localScale, Vector3.zero, 0.8f * Time.fixedDeltaTime); transform.position = Vector3.Lerp(transform.position, trou.transform.position, 2f * Time.fixedDeltaTime); //transform.rotation = Quaternion.Lerp(transform.rotation, new Quaternion(0,0, Random.Range(30,600),0),Time.fixedDeltaTime * 0.01f); } }
// Resets the position of the chain public void Reset_Chain() { int Nump = rope.NumPoints; Vector3 Delta = rope.get_points()[Nump - 1].transform.position - rope.get_points()[0].transform.position; for (int ParticleIndex = 0; ParticleIndex < Nump; ParticleIndex++) { float Alpha = (float)ParticleIndex / (float)(Nump - 1); Vector3 InitializePosition = rope.get_points()[0].transform.position + (Alpha * Delta); rope.get_points()[ParticleIndex].transform.position = InitializePosition; } }
private void Update() { if (init_IA.target == null && rope_system != null) { for (int i = 0; i < players.players_Movement.Count; i++) { init_IA.allPlayers.Add(players.players_Movement[i].gameObject); } if (rope_system.get_points().Count > 0) { init_IA.target = rope_system.get_points()[rope_system.NumPoints / 2].gameObject; } } }
public void change_NumPoints() { int New_NumPoints = Mathf.RoundToInt(slider_rope_l.value); if (New_NumPoints != rope_system.NumPoints) { int dif_NumPoint = New_NumPoints - rope_system.NumPoints; if (dif_NumPoint > 0) { for (int x = 0; x < dif_NumPoint; x++) { Rope_Point particle = Instantiate(rope_system.PrefabPoint, Vector3.zero, Quaternion.identity); Vector3 InitializePosition = rope_system.get_points()[rope_system.NumPoints - 1].transform.position; particle.transform.position = InitializePosition; particle.transform.parent = rope_system.transform; particle.transform.tag = "rope"; particle.name = "Point_" + (rope_system.NumPoints + x).ToString(); particle.gameObject.layer = 9; if ((rope_system.NumPoints + x) % 2 == 0) { particle.GetComponent <SpriteRenderer>().enabled = false; } rope_system.get_points().Add(particle); } rope_system.NumPoints = rope_system.NumPoints + dif_NumPoint; } else { for (int x = 0; x < -dif_NumPoint; x++) { Rope_Point rp = rope_system.get_points()[rope_system.NumPoints - 1 - x]; rope_system.get_points().RemoveAt(rope_system.NumPoints - 1 - x); Destroy(rp.gameObject); } rope_system.NumPoints = rope_system.NumPoints + dif_NumPoint; } } }
// Update is called once per frame void FixedUpdate() { if (delay_spawn > 0) { delay_spawn -= Time.deltaTime; } else { if (target != null) { if (GetDistance(target) < detectionDistance) { Follow(); } if (anim_atack) { timer += Time.deltaTime; //animator.SetBool("attack", true); if (timer > timer_BeforeAttack) { if (attack) { Camera.main.GetComponent <God_Mode>().Hit_verification("PlayerUndefined", transform.position, "AI_collant"); } timer = 0; anim_atack = false; //animator.SetBool("attack", false); enemySpeed = oldSpeed; } } else { timer = 0; } //Look at the Target /*if (!dead) * { * transform.LookAt(target.transform.position); * transform.Rotate(new Vector2(0, 90)); * transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, 0); * }*/ } } if (/*transform.parent.GetComponent<Rooms>().stayedRoom && */ target == null) { foreach (GameObject Obj in GameObject.FindGameObjectsWithTag("player")) { allPlayers.Add(Obj); } target = rope_system.get_points()[rope_system.NumPoints / 2].gameObject; } }
public void Falling(Player_Movement player) { if (player.transform.localScale.x > 0) { player.transform.localScale = new Vector3(player.transform.localScale.x - Time.deltaTime * scale_speed, player.transform.localScale.y - Time.deltaTime * scale_speed, player.transform.localScale.z); player.transform.Rotate(0, 0, spin_speed); } else { Vector3 pos_torespawn = Find_bestRespawnPoint(player); int Nump = rope.NumPoints; if (player.name == "PlayerOne") { rope.get_points()[0].transform.position = pos_torespawn; player.transform.localScale = new Vector3(1, 1, 1); godMode_Hole1.Hit_verification("PlayerOne", player.transform.position, "Fall Damage"); playerone_falling = false; delay_tmp = 0; } else { rope.get_points()[Nump - 1].transform.position = pos_torespawn; player.transform.localScale = new Vector3(1.2f, 1.2f, 1); godMode_Hole2.Hit_verification("PlayerTwo", player.transform.position, "Fall Damage"); playertwo_falling = false; delay_tmp_two = 0; } Reset_Chain(); player.transform.rotation = Quaternion.Euler(0, 0, 0); playerone.Allow_Moving(); playertwo.Allow_Moving(); } }
public void Start() { if (Load.load) { PlayerData data = SaveSystem.LoadPlayer(); Vector3 position; position.x = data.position[0]; position.y = data.position[1]; position.z = data.position[2]; transform.position = position; rope.transform.position = position; rope.get_points()[0].transform.position = position; rope.get_points()[rope.NumPoints - 1].transform.position = position; Vector3 Delta = rope.get_points()[rope.NumPoints - 1].transform.position - rope.get_points()[0].transform.position; for (int ParticleIndex = 0; ParticleIndex < rope.NumPoints; ParticleIndex++) { float Alpha = (float)ParticleIndex / (float)(rope.NumPoints - 1); Vector3 InitializePosition = rope.get_points()[0].transform.position + (Alpha * Delta); rope.get_points()[ParticleIndex].transform.position = InitializePosition; } Load.load = false; } //Application.targetFrameRate = 300; //MUSIC AkSoundEngine.PostEvent("play_music", Camera.main.gameObject); AkSoundEngine.PostEvent("play_amb", Camera.main.gameObject); //Update UI Update_shieldDisyplay(); Update_liveDisplay(); Update_UI_money(); active_Scene = SceneManager.GetActiveScene().name; }
private void Update() { if (canShoot) { StartCoroutine(SpriteInstanciation(0.05f)); } //MINI MAP if (miniMap.GetBool("Open")) { timer += Time.deltaTime; } if (miniMap.GetBool("Open") && miniMap.GetBool("Close")) { timer = 0; } //Reset God Mode timer if (god_ModeAction.godMode == false) { god_ModeAction.timerTotGodMode = god_ModeAction.oldValueTimerGod; } //UI control with the controller if (manager.life <= 0) { pause.cheatModeButton.SetActive(false); } /* * if (ReInput.controllers.joystickCount > 0 && !pause.cheatMode.activeSelf && !modo_solo) * { * Cursor.visible = false; * Cursor.lockState = CursorLockMode.Locked; * } * else * { * Cursor.visible = true; * Cursor.lockState = CursorLockMode.None; * }*/ if (rew_player.GetButtonDown("PanicHealth")) { if (manager.life > 0) { manager.life = manager.max_Life; manager.Update_liveDisplay(); } } if (rew_player.GetButtonDown("Pause") && !modo_solo) { if (manager.life > 0) { if (pause.menu.activeSelf) { pause.cheatModeButton.SetActive(true); pause.menu.SetActive(false); Time.timeScale = 1; } else { pause.cheatModeButton.SetActive(false); pause.menu.SetActive(true); Time.timeScale = 0; } } } if (rew_player.GetButtonDown("CheatMode")) { if (!miniMap.GetBool("Open")) { miniMap.SetBool("Open", true); } if (!miniMap.GetBool("Close") && timer >= timerMiniMap) { timer = 0; miniMap.SetBool("Close", true); } } if (rew_player.GetButtonDown("Panic")) { if (panicEscape.enabled) { for (int i = 0; i < manager.players_Movement.Count; i++) { manager.players_Movement[i].Stop_Moving(); } panicEscape.mashingCanvas.SetActive(true); } } ///////// HIT SYSTEM - A CLEAN //////////////// if (testVibrationHitRope) { joysticVibrationMan.Vibrate_Control_Kill(); camera_ShakeMan.start_Shake_Kill(0.2f); timerRope += Time.deltaTime; if (timerRope > timerTot_RopeHitVibrate) { testVibrationHitRope = false; god_ModeAction.godMode = false; timerRope = 0; } } if (!testVibrationHitRope || joysticVibrationMan.alreadyVibrated) { joysticVibrationMan.Vibrate_Control(); } if (startBlinking) { joysticVibrationMan.alreadyVibrated = false; joysticVibrationMan.Vibrate_Control_Hit(); camera_ShakeMan.start_Shake_Hit(0.3f); blinking_Effect.SpriteBlinkingEffect(); } ///////////////////////// //Set the position of the Sprite to the extrems of the chains if (PlayerNum == Enum_PlayerNum.PlayerOne && rope_system.get_points().Count > 0) { transform.position = rope_system.get_points()[0].transform.position + new Vector3(0, -y_offset, 0);; } else if (PlayerNum == Enum_PlayerNum.PlayerTwo && rope_system.get_points().Count > 0) { transform.position = rope_system.get_points()[rope_system.NumPoints - 1].transform.position + new Vector3(0, -y_offset, 0);;; } // Dash timer if (dash_tmp > 0) { dash_tmp -= Time.deltaTime; } else { dash_tmp = 0; } //Geting the direction of the movement and detecting if the player started a dash if (modo_solo) { if (PlayerNum == Enum_PlayerNum.PlayerOne) { if (can_move) { movementX = rew_player.GetAxis("MoveHorizontal_p1"); movementY = rew_player.GetAxis("MoveVertical_p1"); } if (rew_player.GetButtonDown("Dash_p1") && dash_tmp <= 0 && new Vector2(movementX, movementY) != Vector2.zero) { Start_Dash(); Physics2D.IgnoreLayerCollision(19, 21); } } else if (PlayerNum == Enum_PlayerNum.PlayerTwo) { if (can_move) { movementX = rew_player.GetAxis("MoveHorizontal_p2"); movementY = rew_player.GetAxis("MoveVertical_p2"); } if (rew_player.GetButtonDown("Dash_p2") && dash_tmp <= 0 && new Vector2(movementX, movementY) != Vector2.zero) { Start_Dash(); //To cros the "Holes" Physics2D.IgnoreLayerCollision(20, 21); } } } else { if (can_move) { movementX = rew_player.GetAxis("MoveHorizontal"); movementY = rew_player.GetAxis("MoveVertical"); } if (rew_player.GetButtonDown("Dash") && dash_tmp <= 0 && new Vector2(movementX, movementY) != Vector2.zero) { Start_Dash(); if (PlayerNum == Enum_PlayerNum.PlayerOne) { Physics2D.IgnoreLayerCollision(19, 21); } else if (PlayerNum == Enum_PlayerNum.PlayerTwo) { Physics2D.IgnoreLayerCollision(20, 21); } } } //Sprite Fliping if (movementX > 0) { gameObject.GetComponent <SpriteRenderer>().flipX = false; } else if (movementX < 0) { gameObject.GetComponent <SpriteRenderer>().flipX = true; } Set_inputs_Animation(); // If Player dont move, play idle anim idle_anim(); Move(movementX, movementY); }