public ReuseObject ( GameObject prefab, Vector3 position, Quaternion rotation ) : void | ||
prefab | GameObject | |
position | Vector3 | |
rotation | Quaternion | |
return | void |
public void FireBullet(float angle) { /* * //Debug.Log("Fire"); * //Vector3 eulers = lookRot.eulerAngles; * Quaternion rot = Quaternion.Euler(0, lookRot, 0); * * BulletController temp = Instantiate(tower.bulletPrefab, (Vector3)position + lookRot * firingHarness.transform.position, rot).GetComponent<BulletController>(); * Rigidbody rigidbody = temp.GetComponent<Rigidbody>(); * temp.damage = tower.damage; * * rigidbody.velocity = rot * (Vector2.up * 10);*/ Quaternion rot = Quaternion.Euler(0, angle, 90); //BulletController temp = Instantiate(tower.bulletPrefab, firingHarnesses[currentFiringHarness++].transform.position, Quaternion.Euler(0, angle, 0)).GetComponentInChildren<BulletController>(); GameObject tempParent = PoolManager.ReuseObject(tower.bulletPrefab, firingHarnesses[currentFiringHarness++].transform.position, rot); BulletController temp = tempParent.GetComponentInChildren <BulletController>(); temp.parent = tempParent; Rigidbody tempRbody = temp.GetComponentInChildren <Rigidbody>(); temp.rbody = tempRbody; tempRbody.velocity = Quaternion.Euler(0, angle - 90, 0) * (Vector3.forward * tower.bulletVelocity); temp.tower = this; currentFiringHarness = currentFiringHarness % firingHarnesses.Length; /*if (firingHarnesses.Length >= currentFiringHarness) * currentFiringHarness = 0;*/ if (tower.attackSpeed != 0f) { nextFireTime = Time.time + (1f / tower.attackSpeed); } }
private void Attack() { Vector3 mouseWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition + Vector3.forward * 10f); float angle = AngleBetweenPoints(mouseWorldPosition, transform.position); arrowPool.ReuseObject(transform.localPosition, Quaternion.Euler(-36f, 0f, angle)); audioControl.PlayArrow(); Invoke("ActivateShoot", WeaponCooldownTime); }
public void Spawn() { if (isPooled) { poolManager.ReuseObject(spawnType, transform.position, Quaternion.identity); } else { Instantiate(spawnType, transform.position, Quaternion.identity); } //GameObject obj = Instantiate(spawnType, transform.position, Quaternion.identity); }
private IEnumerator SpawnCoroutine() { isRunning = true; while (runForever || (spawnInstances - numPerSpawn) >= 0) { spawnInstances -= numPerSpawn; for (int i = 0; i < numPerSpawn; i++) { var obj = poolManager.ReuseObject(enemy, GetRandomPoint(minBounds, maxBounds), Quaternion.identity); } yield return(new WaitForSeconds(Random.Range(spawnMinDelay, spawnMaxDelay))); } isRunning = false; }
private void Start() { poolManager = FindObjectOfType <PoolManager>(); //Debug.Log("Spawn"); for (var i = 0; i < spawnObject.Length; i++) { PoolManager.instance.CreatePool(spawnObject[i], objectAmmount[i]); for (var j = 0; j < objectAmmount[i]; j++) { poolManager.ReuseObject(spawnObject[i], PointInArea(), Quaternion.identity); //spawnObject[i].transform.position = PointInArea(); //spawnObject[i].SetActive(true); } //spawnObject[i].name = spawnObject[i].name; //spawnObject[i.transform.SetParent(GameObject.Find("ElementChase").transform.GetChild(0)); } }
private void Update() { moveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")).normalized; var velocity = moveInput * moveSpeed; Vector3 displacement = velocity * Time.deltaTime; Move(displacement); var isFirePressed = Input.GetButton("Jump"); if (isFirePressed && canFire) { canFire = false; var bulletObj = poolManager.ReuseObject(bullet, bulletSpawnPoint.position, Quaternion.identity); var bulletController = bulletObj.GetComponent <BulletController>(); bulletController.speed = bulletSpeed; bulletController.direction = Vector2.up; bulletController.triggerTag = "Enemy"; StartCoroutine(FireCoolDownRoutine()); } }
public void SpanwAtVector(int id, Vector3 position_new) { PM.ReuseObject(StatusAnimationGO[id], position_new, Quaternion.identity); //Instantiate(StatusAnimationGO[id], position_new, Quaternion.identity); }
public void SpawnCastleObstacle() { GameObject obj = poolManager.ReuseObject(castleObstacles[Random.Range(0, castleObstacles.Length)], transform.position, Quaternion.identity); AdjustPos(obj); }
public void ReuseObject(GameObject prefab, Vector3 position, object args = null) { pool.ReuseObject(prefab, position, Quaternion.identity, args); }
public void FireArrow() { poolManager.ReuseObject(arrow, transform.position, Quaternion.identity); }
public void Reuse() { poolManager.ReuseObject(prefab, GetSpawnPosition(), UnityEngine.Random.rotation); }
public void SpawnVillagePlatform(Vector2 r) { GameObject obj = poolManager.ReuseObject(spawnVillagePlatform[Random.Range(0, spawnVillagePlatform.Length)], new Vector3(r.x, r.y, 0f), Quaternion.identity); AdjustPos(obj); }