コード例 #1
0
 private void FireProjectile()
 {
     cursorInWorldPos = cam.ScreenToWorldPoint((Vector2)Input.mousePosition);
     direction        = cursorInWorldPos - (Vector2)transform.position;
     direction.Normalize();
     newProjectile = poolingManager.SpawnFromPool(projectilesPoolTag, transform.position, Quaternion.Euler(0, 0, Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg));
     newProjectile.GetComponent <Rigidbody2D>().velocity = direction * CONST_VALUES.PROJECTILE_SPEED;
     shootingSound.Play(src);
 }
コード例 #2
0
 private void ShootAtTarget()
 {
     shootingSound.Play(src);
     bulletDirection = target.position - transform.position;
     bulletDirection.Normalize();
     newProjectile = poolingManager.SpawnFromPool(projectilesPoolTag, transform.position, Quaternion.Euler(0, 0, Mathf.Atan2(bulletDirection.y, bulletDirection.x) * Mathf.Rad2Deg));
     newProjectile.GetComponent <Rigidbody2D>().velocity = bulletDirection * CONST_VALUES.PROJECTILE_SPEED;
     shootingSound.Play(src);
 }
コード例 #3
0
    private IEnumerator SpawnInterval()
    {
        yield return(waitForIntervalDuration);

        for (int i = 0; i < enemiesPerSpawn; i++)
        {
            newEnemy = poolingManager.SpawnFromPool(desiredEnemy.enemyTag, GetRandomPositionOnCircle() * RADIUS, Quaternion.identity);
            newEnemy.GetComponent <EnemyController>().desiredEnemy = desiredEnemy;
            onEnemySpawned.RaiseEvent();
        }
        yield return(SpawnInterval());
    }
コード例 #4
0
 private void FireProjectile()
 {
     newProjectile = poolingManager.SpawnFromPool(projectilesPoolTag, transform.position, transform.rotation);
     newProjectile.GetComponent <Rigidbody>().velocity = transform.forward * PROJECTILE_SPEED;
 }