public void SetCharacteristics(float velocity, ProjectileDirection direction, float lifeTime) { this.velocity = velocity; this.direction = direction; lifetimeComponent = new LifetimeComponent(lifeTime); }
public SpawnProjectileSignal(Vector3 position, float velocity, ProjectileDirection direction, float lifeTime) { this.position = position; this.velocity = velocity; this.direction = direction; this.lifeTime = lifeTime; }
public ShootingParameters(float projectileVelocity, float minShotsInterval, Transform spawn, ProjectileDirection direction, float lifeTime) { this.projectileVelocity = projectileVelocity; this.minShotsInterval = minShotsInterval; this.spawn = spawn; this.direction = direction; this.lifeTime = lifeTime; }
private void SpawnProjectile(Vector2 position, ProjectileDirection direction) { GameObject projectile = Instantiate(projectilePrefab, position, Quaternion.identity); ProjectileController projectileController = projectile.GetComponent <ProjectileController>(); projectileController.Direction = direction; _timeBetweenShots = startTimeBetweenShots; }
public static Vector3 Direction2Vector(ProjectileDirection direction) { switch (direction) { case ProjectileDirection.Up: return(new Vector3(0.0f, 1.0f, 0.0f)); case ProjectileDirection.Down: return(new Vector3(0.0f, -1.0f, 0.0f)); case ProjectileDirection.Left: return(new Vector3(-1.0f, 0.0f, 0.0f)); case ProjectileDirection.Right: return(new Vector3(1.0f, 0.0f, 0.0f)); default: return(Vector3.zero); } }
/// <summary> /// Fires one of the projectiles in the pool /// </summary> /// <param name="position">starting position of the projectile</param> /// <param name="direction">starting move direction of the projectile</param> public void FireProjectile(Vector3 position, ProjectileDirection direction) { //loop through pool until valid object is found for (int p = 0; p < poolSize; p++) { poolIndex = (poolIndex + 1) % poolSize; //valid objeect found or last search item (insures fireing) if (!projPool[poolIndex].Active || p == poolSize - 1) { //start the projectile at location projPool[poolIndex].Direction = direction; projPool[poolIndex].transform.position = position; projPool[poolIndex].gameObject.SetActive(true); //create a burst at the fire location BurstParticles(position); break; } } }
// ==================================================== private IEnumerator FireCoroutine(Vector2 direction) { direction.Normalize(); if (currentProjectile != null) { yield break; } if (nextFireTime > MinigameTimeManager.instance.time) { yield break; } nextFireTime = MinigameTimeManager.instance.time + attackDelay; isAttacking = true; ProjectileDirection projectileDirection = ProjectileDirection.FORWARD; if (direction == Vector2.zero) { direction = Vector3.right * Mathf.Sign(transform.localScale.x); projectileDirection = ProjectileDirection.FORWARD; } if (isGrabbingToWall) { //TODO: check direction = Vector3.right * Mathf.Sign(transform.localScale.x); projectileDirection = ProjectileDirection.FORWARD; } else { float oldHorizontalDir = Mathf.Sign(transform.localScale.x); direction.x *= oldHorizontalDir; /*float maxValue = float.MinValue; * foreach( ProjectileDirection key in directionsCache.Keys ) { * float value = Vector2.Dot( direction, directionsCache[key] ); * if( value < maxValue ) { * continue; * } * maxValue = value; * projectileDirection = key; * }*/ if (direction.y > 0.4f) { projectileDirection = ProjectileDirection.UP; } else if (direction.y < -0.4f) { projectileDirection = ProjectileDirection.DOWN; } direction = directionsCache[projectileDirection]; // return to old direction direction.x *= oldHorizontalDir; } SoundManager.instance.PlaySound(SoundManager.SoundType.Throw); currentProjectile = Instantiate <ProjectileController>(projectilePrefab); foreach (ProjectileSpawnPointInfo info in projectileSpawnPointInfos) { if (info.direction == projectileDirection) { currentProjectile.transform.position = info.spawnPoint.position; currentProjectile.transform.right = direction; } } shootVfxAnimator.SetTrigger("shootTrigger"); currentProjectile.Configure(direction, this); isAttacking = false; }