private void OnTriggerEnter(Collider other) { if (other.CompareTag("Enemy")) { ChairsEnemyController enemy = other.GetComponent <ChairsEnemyController>(); DecideStun(enemy); } else if (other.CompareTag("Player")) { ChairsPlayerController enemy = other.GetComponent <ChairsPlayerController>(); DecideStun(enemy); } if (other.CompareTag("Chair")) { ChairsChairController chair = other.GetComponent <ChairsChairController>(); if (!chair.occupied) { this.sat = true; chair.AssignSeat(); ResetAnimation(); } } }
private void EliminatePlayersAndChairs() { int indexToEliminate = -1; for (int i = 0; i < enemiesPlaying.Count; i++) { if (!enemiesPlaying[i].sat) { indexToEliminate = i; } else { enemiesPlaying[i].sat = false; } } ChairsEnemyController enemy = enemiesPlaying[indexToEliminate]; enemy.gameObject.SetActive(false); enemiesPlaying.RemoveAt(indexToEliminate); player.sat = false; for (int i = 0; i < chairsPlaying.Count; i++) { chairsPlaying[i].occupied = false; } indexToEliminate = Random.Range(0, chairsPlaying.Count); ChairsChairController silla = chairsPlaying[indexToEliminate]; silla.gameObject.SetActive(false); chairsPlaying.RemoveAt(indexToEliminate); SetChairs(); }
public void OccupyChair(ChairsChairController chair) { freeChairs.Remove(chair); if (freeChairs.Count == 0) { GameOver(); } }
public void ChooseNewChair() { targetChair = null; for (int i = 0; i < gameController.freeChairs.Count; i++) { if (!gameController.freeChairs[i].GetComponent <ChairsChairController>().occupied) { targetChair = gameController.freeChairs[i]; } } }
public void ResetEnemy() { //agent.enabled = false; agent.Warp(startPosition); transform.rotation = new Quaternion(0, 0, 0, 0); //agent.enabled = true; //enemy.gameObject.SetActive(true); //this.sat = false; this.stunned = false; this.targetChair = null; SetNewTargetChair(); }
private IEnumerator StunMyselfCoroutine() { Debug.Log("Me stuneo " + this.gameObject.name); agent.isStopped = true; ResetAnimation(); yield return(new WaitForSecondsRealtime(stunDuration)); Debug.Log("Me termino el stuneo " + this.gameObject.name); agent.isStopped = false; stunned = false; this.targetChair = null; SetNewTargetChair(); }
public IEnumerator SetNewTargetChairCoroutine() { while (!sat && gameController.freeChairs.Count > 0) { if (!this.stunned) { float maxDistance = float.PositiveInfinity; int selectedIndex = 0; for (int i = 0; i < gameController.freeChairs.Count; i++) { if (!gameController.freeChairs[i].occupied) { NavMeshPath path = new NavMeshPath(); agent.CalculatePath(gameController.freeChairs[i].transform.position, path); float distance = GetPathLength(path);/*= Vector3.Distance(this.transform.position, gameController.freeChairs[i].gameObject.transform.position)*/ if (distance < maxDistance) { selectedIndex = i; maxDistance = distance; } } } if (targetChair == null) { ChairsChairController chair = gameController.freeChairs[selectedIndex]; targetChair = chair; if (!this.stunned) { agent.SetDestination(chair.gameObject.transform.position); Debug.Log("Se setea nuevo destino por silla null"); } } else if (!targetChair.Equals(gameController.freeChairs[selectedIndex])) { ChairsChairController chair = gameController.freeChairs[selectedIndex]; targetChair = chair; if (!this.stunned) { agent.SetDestination(chair.gameObject.transform.position); Debug.Log("Se setea nuevo destino por nueva silla mas cercana"); } } } yield return(new WaitForSecondsRealtime(findNewChairDelay)); } }
public void SetInitialTargetChair() { float maxDistance = float.PositiveInfinity; int selectedIndex = 0; for (int i = 0; i < gameController.freeChairs.Count; i++) { if (!gameController.freeChairs[i].occupied) { float distance = Vector3.Distance(this.transform.position, gameController.freeChairs[i].gameObject.transform.position); if (distance < maxDistance) { selectedIndex = i; maxDistance = distance; } } } targetChair = gameController.freeChairs[selectedIndex]; }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Chair")) { ChairsChairController chair = other.GetComponent <ChairsChairController>(); if (!chair.occupied) { this.sat = true; chair.AssignSeat(); ResetAnim(); AudioManager.instance.PlayOneShot("SFX_campanillas"); } } if (other.CompareTag("Enemy")) { ChairsEnemyController enemy = other.GetComponent <ChairsEnemyController>(); DecideStun(enemy); } }