//IEnumerator UpdatePath() //{ // float refreshRate = .25f; // // while (target != null) // { // Vector3 targetPosition = new Vector3(target.position.x, 0, target.position.z); // // yield return new WaitForSeconds(refreshRate); // } //} IEnumerator AttackTarget(LivingEntityManager target) { if (target != null && (currentState != State.Stunned || currentState != State.Breaked)) { //time += Time.deltaTime; float attackPerSecond = ((100 + agility + attackSpeed) * 0.01f) / 1.7f; float attackTime = 1 / attackPerSecond; if (Time.time >= nextShotTime) { nextShotTime = Time.time + attackTime; GameObject fireProjectile = Instantiate(projectile, spawnPoint.position, Quaternion.identity) as GameObject; //fireProjectile.transform.position = spawnPoint.position; fireProjectile.GetComponent <Shoot>().target = target; fireProjectile.GetComponent <Shoot>().projectileSpeed = projectileSpeed; fireProjectile.GetComponent <Shoot>().damage = baseDamage; fireProjectile.GetComponent <Shoot>().isTroop = true; //Debug.Log(baseDamage); //target.TakePhysicalDamage(baseDamage); //time = 0; } //yield return new WaitForSeconds(attackTime); } if (target == null) { if (transform.GetComponentInChildren <Shoot>()) { transform.GetComponentInChildren <Shoot>().hasTarget = false; } } yield return(null); }
IEnumerator AttackTarget(LivingEntityManager target) { //float time = 0; if (target != null) { //time += Time.deltaTime; //if (Input.GetKeyDown(KeyCode.Space)) //{ // //Debug.Log(target.name); // target.CallStun(1f); //} float attackPerSecond = ((100 + agility + attackSpeed) * 0.01f) / 1.7f; float attackTime = 1 / attackPerSecond; if (Time.time >= nextShotTime) { nextShotTime = Time.time + attackTime; //Debug.Log(baseDamage); target.TakeHit(baseDamage, transform.localEulerAngles, "physical", 0f); if (gameObject.GetComponent <CleaveDamage>()) { gameObject.GetComponent <CleaveDamage>().PerformCleaveAttack(); gameObject.GetComponent <CleaveDamage>().damage = baseDamage; } //time = 0; } //yield return new WaitForSeconds(attackTime); } yield return(null); }
IEnumerator ShowIndication() { isRunning = true; LivingEntityManager hero; while (!Input.GetMouseButtonUp(0)) { if (currentSelection != null) { currentSelection.GetComponentInChildren <MeshRenderer>().material = defaultMat; currentSelection = null; } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, heroMask)) { //Material temp; if (hit.collider.GetComponent <LivingEntityManager>()) { hero = hit.collider.GetComponent <LivingEntityManager>(); //temp = hero.GetComponentInChildren<MeshRenderer>().material; if (hero != this.GetComponent <LivingEntityManager>()) { hero.GetComponentInChildren <MeshRenderer>().material = highlightMat; currentSelection = hero; } //if (Input.GetMouseButtonUp(0)) //{ // //Debug.Log("click"); // hero.GetComponentInChildren<MeshRenderer>().material = wrongHighlighMat; // // //Deploy GOO //} } } yield return(null); isRunning = false; } if (currentSelection != null) { currentSelection.GetComponentInChildren <MeshRenderer>().material = defaultMat; while (Vector3.Distance(transform.position, currentSelection.transform.position) > 8f) { yield return(null); } StartCoroutine(CoolDownStart()); GetComponent <LivingEntityManager>().ChangeMana(-manaConsuption); if (gameObject.GetComponent <PlayerController>().lastAbility.Count < 5) { gameObject.AddComponent <BristleFuryBuff>(); } //else // gameObject.GetComponent<BristleFuryPassive>().StackDebuff(); GameObject goo = Instantiate(gooPrefab, gooSpawnPoint.position, Quaternion.identity) as GameObject; //goo.transform.position = gooSpawnPoint.position; goo.GetComponent <GooProjectile>().target = currentSelection; } else if (currentSelection == null) { if (transform.GetComponentInChildren <GooProjectile>()) { transform.GetComponentInChildren <GooProjectile>().hasTarget = false; } } }
void RemoveFocus() { StopCoroutine(AttackTarget(curruntFocus)); curruntFocus = null; playerMotor.StopFollowingTarget(); }
void SetFocus(LivingEntityManager newFocus) { curruntFocus = newFocus; playerMotor.FollowTarget(newFocus); }
private void Awake() { Instance = this; }
IEnumerator ShowIndication() { LivingEntityManager hero; while (!Input.GetMouseButtonUp(0)) { if (currentSelection != null) { currentSelection.GetComponentInChildren <MeshRenderer>().material = defaultMat; currentSelection = null; } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, heroMask)) { //Material temp; if (hit.collider.GetComponent <LivingEntityManager>()) { hero = hit.collider.GetComponent <LivingEntityManager>(); //temp = hero.GetComponentInChildren<MeshRenderer>().material; if (hero != this.GetComponent <LivingEntityManager>()) { hero.GetComponentInChildren <MeshRenderer>().material = highlightMat; currentSelection = hero; } //if (Input.GetMouseButtonUp(0)) //{ // //Debug.Log("click"); // hero.GetComponentInChildren<MeshRenderer>().material = wrongHighlighMat; // // //Deploy GOO //} } } yield return(null); } if (currentSelection != null) { currentSelection.GetComponentInChildren <MeshRenderer>().material = defaultMat; while (Vector3.Distance(transform.position, currentSelection.transform.position) > 8f) { yield return(null); } StartCoroutine(CoolDownStart()); GetComponent <LivingEntityManager>().ChangeMana(-manaConsuption); //else // gameObject.GetComponent<BristleFuryPassive>().StackDebuff(); GameObject laser = Instantiate(laserPrefab, transform) as GameObject; //goo.transform.position = gooSpawnPoint.position; laser.GetComponent <LaserBeam>().myPos = spawnPos; laser.GetComponent <LaserBeam>().target = currentSelection.transform; // //laser.GetComponent<LineRenderer>().SetPosition(0, spawnPos.position); //laser.GetComponent<LineRenderer>().SetPosition(1, currentSelection.gameObject.GetComponentInChildren<MeshRenderer>().transform.position); yield return(new WaitForSeconds(0.25f)); currentSelection.TakeHit(450f, transform.localEulerAngles, "magical", GetComponent <LivingEntityManager>().spellDamageAmpli); Destroy(laser, 0.5f); } else if (currentSelection == null) { //if (transform.GetComponentInChildren<LaserBeam>()) // transform.GetComponentInChildren<LaserBeam>().hasTarget = false; } }
private void Awake() { allLivingEntities = new List <LivingEntity>(); Instance = this; }