public override void attack(WeaponController weaponController, float attackRate, bool isNewAttack, Vector2 aiInput) { if (!isAttacking && isReady) { Vector2 rockPos = new Vector2(weaponController.transform.position.x, weaponController.transform.position.y); if (aiInput.Equals(Vector2.zero)) { return; } Vector2 lookAtDir = aiInput.normalized; GameObject rockWall = MonoBehaviour.Instantiate(weaponController.associatedPrefab, rockPos + (aiInput.normalized * wallDist), new Quaternion(0, 0, 0, 0)) as GameObject; rockWall.transform.Rotate(Vector3.forward, (180.0f / Mathf.PI) * Mathf.Atan2(lookAtDir.y, lookAtDir.x)); MonoBehaviour.Destroy(rockWall, coolDownTime); // Start cooldown if (coolDownCorout != null) { weaponController.StopCoroutine(coolDownCorout); } coolDownCorout = weaponController.StartCoroutine(coolDown()); } }
public override void attack(WeaponController weaponController, float attackRate, bool isNewAttack, Vector2 aiInput) { if (!isAttacking) { Vector3 explVel; if (aiInput.x == 0 && aiInput.y == 0) { explVel = lastExplVel; } else { lastExplVel = explVel = new Vector3(aiInput.x, aiInput.y, -upForce); } Rigidbody bomb = (MonoBehaviour.Instantiate(weaponController.associatedPrefab, weaponController.owner.hand.position + Vector3.back, Quaternion.identity) as GameObject).GetComponent<Rigidbody>(); bomb.AddForce(explVel * throwSpeed * Time.deltaTime); MonoBehaviour.Destroy(bomb.gameObject, 2f); // Play bomb time cooldown if (curCooldown != null) { weaponController.StopCoroutine(curCooldown); } curCooldown = weaponController.StartCoroutine(bombCooldown()); } }