// Update is called once per frame void Update() { // 플레이어 위치 Vector3 myPos = this.gameObject.transform.position; // 캐릭터가 목표지점 도착할경우 if (agent.remainingDistance <= 0.0f) { anim.SetBool(hash_run, false); anim.SetBool(hash_attack, false); //anim.Play("Idle01", -1, 0); } // ************************************ MOUSE ************************************ // 마우스 '좌' if (Input.GetMouseButtonDown(0)) { // 애니메이션 실행 anim.Play("Attack01", -1, 1); // 위치 고정 agent.SetDestination(transform.position); is_hit = true; } // 마우스 '우' if (Input.GetMouseButtonDown(1)) { // 스피드에 따른 애니메이션 변화 anim.Play("Run", -1, 0); // ray로 마우스 클릭 위치 판별 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; // 마우스 클릭시 네비매쉬에 클릭 된 것 if (Physics.Raycast(ray, out hit)) { agent.SetDestination(hit.point); } } // ******************************************************************************* // ************************************ SKILL ************************************ // 'Q' if (Input.GetKeyDown(KeyCode.Q)) { anim.Play("Skill01", -1, 1); agent.SetDestination(transform.position); } // 'W' if (Input.GetKeyDown(KeyCode.W)) { anim.Play("Skill02", -1, 1); agent.SetDestination(transform.position); } // 'E' if (Input.GetKeyDown(KeyCode.E)) { Vector3 pos = Input.mousePosition; pos.z = 10; Vector3 target = Camera.main.ScreenToWorldPoint(pos); transform.LookAt(target); anim.Play("Skill04", -1, 1); agent.SetDestination(transform.position); } // 'R' if (Input.GetKeyDown(KeyCode.R)) { //R스킬 누르면 스킬 눌렀을때 마우스 좌표를 fireAreaCtrl 스크립트로 전달 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; anim.Play("Skill03", -1, 1); // 마우스 클릭시 네비매쉬에 클릭 된 것 FireAreaCtrl fc = GetComponent <FireAreaCtrl>(); if (Physics.Raycast(ray, out hit)) { fc.mousePos = hit.point; } agent.SetDestination(transform.position); } // ******************************************************************************* // ************************************ DAMAGE ************************************ if (Input.GetKeyDown(KeyCode.J)) { currHp = 0; } // 사망 시 if (is_Die) { // 애니메이션 실행 //anim.SetBool(hash_run, false); is_Die = false; currHp = 1; anim.Play("Die", -1, 1); // 시간 측정 sw.Start(); } // 부활시간 도달시 if (sw.ElapsedMilliseconds == 10) { // 시간 측정 초기화 sw.Stop(); sw.Reset(); // 부활 is_Die = false; transform.position = new Vector3(0, 0, 0); } // ******************************************************************************* }
void Update() { if (q == true) { qCool += Time.deltaTime; if (qCool >= 4) { qCool = 0; q = false; } } if (w == true) { wCool += Time.deltaTime; if (wCool >= 6) { wCool = 0; w = false; } } if (e == true) { eCool += Time.deltaTime; if (eCool >= 4) { eCool = 0; e = false; } } if (r == true) { rCool += Time.deltaTime; if (rCool >= 4) { rCool = 0; r = false; } } if (pv.isMine) { // 플레이어 위치 Vector3 myPos = this.gameObject.transform.position; // 캐릭터가 목표지점 도착할경우 if (agent.remainingDistance <= 0.0f) { //hitBoxCtrl.GetComponent<BoxCollider>().enabled = false; player.Idle(); //anim.Play("Idle01", -1, 0); } // ************************************ MOUSE ************************************ // 마우스 '좌' if (Input.GetMouseButtonDown(0)) { player.Attack(); agent.SetDestination(transform.position); Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); float midPoint = (transform.position - Camera.main.transform.position).magnitude; transform.LookAt(mouseRay.origin + mouseRay.direction * midPoint); } // 마우스 '우' if (Input.GetMouseButtonDown(1)) { // 스피드에 따른 애니메이션 변화 //anim.Play("Run", -1, 0); if (player.anim.GetBool("is_run") == false) { // hitBoxCtrl.GetComponent<BoxCollider>().enabled = false; player.Run(); } // ray로 마우스 클릭 위치 판별 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; // 마우스 클릭시 네비매쉬에 클릭 된 것 if (Physics.Raycast(ray, out hit)) { agent.SetDestination(hit.point); } } // ******************************************************************************* // ************************************ SKILL ************************************ // 'Q' if (Input.GetKeyDown(KeyCode.Q)) { if (q == false) { Vector3 pos = Input.mousePosition; pos.z = 10; Vector3 target = Camera.main.ScreenToWorldPoint(pos); transform.LookAt(target); player.Skill1(); agent.SetDestination(transform.position); q = true; } } // 'W' if (Input.GetKeyDown(KeyCode.W)) { //anim.Play("Skill02", -1, 1); if (w == false) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; player.Skill2(); LightningCtrl fc = GetComponent <LightningCtrl>(); if (Physics.Raycast(ray, out hit) && GameManager.instance.characterPick == 1) { fc.mousePos = hit.point; } agent.SetDestination(transform.position); w = true; } } // 'E' if (Input.GetKeyDown(KeyCode.E)) { if (e == false) { Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); float midPoint = (transform.position - Camera.main.transform.position).magnitude; if (GameManager.instance.characterPick == 0) { transform.LookAt(mouseRay.origin + mouseRay.direction * midPoint); } if (GameManager.instance.characterPick == 1) { if (player.isOn == false) { player.isOn = true; } else if (player.isOn == true) { player.isOn = false; } } player.Skill4(); //anim.Play("Skill04", -1, 1); agent.SetDestination(transform.position); e = true; } } // 'R' if (Input.GetKeyDown(KeyCode.R)) { //R스킬 누르면 스킬 눌렀을때 마우스 좌표를 fireAreaCtrl 스크립트로 전달 if (r == false) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; //anim.Play("Skill03", -1, 1); player.Skill3(); // 마우스 클릭시 네비매쉬에 클릭 된 것 FireAreaCtrl fc = GetComponent <FireAreaCtrl>(); if (Physics.Raycast(ray, out hit) && GameManager.instance.characterPick == 0) { fc.mousePos = hit.point; } agent.SetDestination(transform.position); r = true; } } // ******************************************************************************* // ************************************ DAMAGE ************************************ if (Input.GetKeyDown(KeyCode.J)) { currHp = 0; } if (currHp == 0) { is_Die = true; } // 사망 시 if (is_Die) { // 애니메이션 실행 //anim.SetBool(hash_run, false); is_Die = false; currHp = 1; player.Die(); //anim.Play("Die", -1, 1); // 시간 측정 sw.Start(); } // 부활시간 도달시 if (sw.ElapsedMilliseconds == 10) { // 시간 측정 초기화 sw.Stop(); sw.Reset(); // 부활 is_Die = false; transform.position = new Vector3(0, 0, 0); } } // ******************************************************************************* }