void AttackState() // Attacks enemey { if (lookAt != null) { //attack, probably will just shoot something rn if (!tele.isDone && !isAttacking) { tele.AttackRange(attackRange, attackProjector, 2, false); isAttacking = true; } if (tele.isDone && !isWaiting) { StartCoroutine(WaitForDelay()); } if (!isStationary && lookAt != null) { agent.destination = lookAt.transform.position; float dist = Vector3.Distance(transform.position, lookAt.transform.position); if (dist < attackRangeFromEnemy) { agent.isStopped = true; } else { agent.isStopped = false; } } EnemyOutOfRange(); } else if (lookAt != null && lookAt.GetComponent <EnemyInformation>().PlayerHealth < 0 || lookAt == null) { CheckIfInEnemyIsInRange(); } }
void AttackState() { if (!delayForAttack) { //attack, probably will just shoot something rn if (!tele.isDone && !isAttacking) { tele.AttackRange(range, projector, 2, false); isAttacking = true; } if (tele.isDone && isAttacking) { if (isMelee) { Slash(); } else if (isRanged) { Fire(); } isAttacking = false; StartCoroutine(Wait(1f)); } else if (isRefreshed) { isAttacking = false; isRefreshed = false; } } //Damage damage = new Damage(); }
// Update is called once per frame void Update() { if (telegrams.isWaiting) { button.GetComponent <SkillBar>().isClicked = false; } isPressed = button.GetComponent <SkillBar>().isClicked; if (Input.GetKeyDown(KeyBinds.Instance.Ability4) && !telegrams.isWaiting || isPressed) { button.GetComponent <SkillBar>().isWaiting = false; GameObject[] temp = GameObject.FindGameObjectsWithTag("Button"); for (int i = 0; i < temp.Length; i++) { if (!temp[i].GetComponent <SkillBar>().isInstantAbility) { temp[i].GetComponent <SkillBar>().isClicked = false; // temp[i].GetComponent<SkillBar>().canAttack = false; } } button.GetComponent <SkillBar>().DurationTime(duration + 0.1f, false, 0); telegrams.AttackRange(range, projector, duration, false); hasAttacked = false; isFinished = true; StartCoroutine(StopAttacking()); isPressed = false; } if (bulletInst) { //GameObject temp = GameObject.Find("Blast(Clone)"); //Change it to a for loop, check all of the objects at once GameObject[] bullets = GameObject.FindGameObjectsWithTag("Bullet"); for (int i = 0; i < bullets.Length; i++) { float dist = Vector3.Distance(bullets[i].transform.position, player.transform.position); if (dist > range * Scalar.rangeScalar) { Destroy(bullets[i]); } } } if (isFinished && !isWait) { //Without an amount it just shoots them StartCoroutine(Wait()); } }
// Update is called once per frame void Update() { if (telegrams.isWaiting) { button.GetComponent <SkillBar>().isClicked = false; } isPressed = button.GetComponent <SkillBar>().isClicked; if (Input.GetKeyDown(KeyBinds.Instance.Ability2) && !telegrams.isWaiting || isPressed && !telegrams.isWaiting) { // the damage for this attack is based on intellect and mastery + the main stat of your character. button.GetComponent <SkillBar>().isWaiting = false; GameObject[] temp = GameObject.FindGameObjectsWithTag("Button"); for (int i = 0; i < temp.Length; i++) { if (!temp[i].GetComponent <SkillBar>().isInstantAbility) { temp[i].GetComponent <SkillBar>().isClicked = false; //temp[i].GetComponent<SkillBar>().canAttack = false; } } button.GetComponent <SkillBar>().DurationTime(duration, false, 0); telegrams.AttackRange(range, projector, duration, false); hasAttacked = false; isPressed = false; } if (bulletInst) { //GameObject temp = GameObject.Find("Blast(Clone)"); float dist = bulletInst.transform.position.magnitude - player.transform.position.magnitude; if (dist > range * Scalar.rangeScalar) { Destroy(bulletInst); } } if (telegrams.isDone && !hasAttacked) { //Without an amount it just shoots them Fire(); } }
public void Update() { // cap the sword at 90, once it reaches 90, make it so it it reverts back and waits for a certain command to be true; if (!isSet) { //key = action.skill[0].key; //isSet = true; } if (teleGrams.isWaiting) { button.GetComponent <SkillBar>().isClicked = false; } isPressed = button.GetComponent <SkillBar>().isClicked; if (Input.GetKeyDown(KeyBinds.Instance.Abilitiy1) && !teleGrams.isWaiting || isPressed && !teleGrams.isWaiting) //Input.GetKeyDown(key) || // Basically the telegrams { button.GetComponent <SkillBar>().isWaiting = false; GameObject[] temp = GameObject.FindGameObjectsWithTag("Button"); for (int i = 0; i < temp.Length; i++) { if (!temp[i].GetComponent <SkillBar>().isInstantAbility) { temp[i].GetComponent <SkillBar>().isClicked = false; // temp[i].GetComponent<SkillBar>().canAttack = false; } } button.GetComponent <SkillBar>().DurationTime(duration, false, 0); //GameInformation.PlayerEnergy -= GameInformation.playerMoveTwo.AbilityCost; //Debug.Log(GameInformation.PlayerEnergy); isClicked = true; // swordSwing.Play(); smooth = 10; teleGrams.AttackRange(range, projector, duration, false); hasAttacked = false; //will change this to be the range, every attack will have this //StartCoroutine(DisableProjector()); isPressed = false; } if (swordInsti) { //GameObject temp = GameObject.Find("Bullet(Clone)"); float dist = swordInsti.transform.position.magnitude - player.transform.position.magnitude; if (dist > range * Scalar.rangeScalar) { Destroy(swordInsti); } } if (ZoomedIn == true) { transform.Rotate(Vector3.forward * smooth); } if (transform.eulerAngles.z >= 90) { // Debug.Log("Passed 90"); ZoomedIn = false; ZoomedBack = true; } if (ZoomedBack) { // Debug.Log("Going Back"); transform.Rotate((Vector3.back * rotationSpeed) * Time.deltaTime); } if (transform.eulerAngles.z <= 3) { //Debug.Log("Passed 0"); ZoomedBack = false; ZoomedIn = false; int tempzero = 0; smooth = tempzero; } if (transform.eulerAngles.z > 350) { // Debug.Log("Passed 0"); ZoomedBack = false; ZoomedIn = false; int tempzero = 0; smooth = tempzero; } if (teleGrams.isDone && !hasAttacked) { //Without an amount it just shoots them Slash(); } }