void OnCollisionEnter(Collision col) { if (col.transform.tag == "Ball") { Ball_Action bAction = col.gameObject.GetComponent <Ball_Action> (); if (bAction.isAttacking && bAction.isAttackerPlayer == true) { float chance = Random.Range(0.0f, 100.0f); if (chance <= 80) { Hp--; print("윽"); if (_hpBar != null) { _hpBar.transform.localPosition = new Vector3(0.1f, 0, 0); } _hpBar.transform.localScale = new Vector3(Hp * 0.2f, 0.2f, 1); } else { PickBall(col.transform); } if (Hp <= 0) { print("으앙죽음ㅋ"); if (_hpBar != null) { _hpBar.transform.localScale = new Vector3(0, 1, 1); } Destroy(this.gameObject); Win.SetActive(true); } } else if (!bAction.isAttacking) { PickBall(col.transform); } } if (col.transform.CompareTag("Wall")) { transform.position -= Sport * Time.deltaTime; Vector3 newDir = Vector3.zero; foreach (ContactPoint point in col.contacts) { newDir += transform.position - point.point; } newDir /= col.contacts.Length; Sport = Sport.magnitude * newDir.normalized; } }
void onTriggerStay(Collider other) { Ball_Action bAction = other.GetComponent <Ball_Action>(); if (!bAction.isAttacking) { print("마이볼"); PickBall(other.transform); enemystate = EnemyState.attack; //Agent.SetDestination(new Vector3()) } }
//IEnumerator Udate() { void OnCollisionEnter(Collision other) { if (other.transform.tag == "Ball") { Ball_Action bAction = other.gameObject.GetComponent <Ball_Action>(); if (bAction.isAttacking && bAction.isAttackerPlayer == false) { Hp--; StartCoroutine(HitProcess(true)); print("플레이어 얻어맞음"); animator.SetTrigger("Damage"); // yield return new WaitForSeconds(1); damaged = true; if (Hp <= 0) { //healthSlider.value = 0; print("플레이어죽음ㅋ"); //Destroy(this.gameObject); Lose.SetActive(true); } } } else if (other.transform.tag == "Hurdle") { rbody.AddExplosionForce(500f, other.contacts[0].point, 10f); Hp--; print("플레이어 얻어맞음"); if (Hp <= 0) { print("플레이어죽음ㅋ"); Lose.SetActive(true); } } else if (other.transform.tag == "Drop") { FallingObject fo = other.gameObject.GetComponent <FallingObject>(); if (fo.falling) { animator.SetBool("Dozed", true); StartCoroutine(HitProcess(false)); } } }
//void md() //{ // SpeedX = transform.position.x; // SpeedZ = transform.position.z; //} IEnumerator CheckEnemyState() { Ball_Action ballAction = Ball.GetComponent <Ball_Action>(); while (isAlive) { yield return(null); if (!ballAction.isAttacking && ballAction.inEnemySide) { print("안전볼 && 적영역"); enemystate = Picked ? EnemyState.attack : EnemyState.move; } else if (!ballAction.isAttacking && !ballAction.inEnemySide) { print("안전볼 && 플레이어영역"); enemystate = EnemyState.idle; } } }