void Shoot() { Vector3 spawnPos = spawnPoint.position; Quaternion spawnRot = Quaternion.identity; BaseBulletScript bul = Instantiate(bullet, spawnPos, spawnRot).GetComponent <BaseBulletScript>(); bul.Setup(shootVector); isShoot = true; }
void SpawnOneMillionBlueBullets() { RandomSmoothedMovement(100, 2, 120); if (bulletsFired.Length == 0) { bulletsFired = new int[1]; bulletNextFireTime = new float[1]; } if (bulletNextFireTime[0] <= 0) { Transform newBullet = Instantiate(nonData[1].bulletSpawnItems[0], thisTrans.position, new Quaternion(), shmupMaster.bulletContainer).transform; BaseBulletScript newScript = newBullet.GetComponent <BaseBulletScript>(); newScript.ignoreRenderer = false; newScript.framesBetweenBulletReorientation = 1; newScript.turnAtStart = true; newScript.rotationBasedOnParent = false; newScript.spawnDelay = 15; newScript.updateSprites = true; newScript.regularKillzone = true; newScript.movementDirection = MathFunctions.CalculateCircle(bulletsFired[0] * -10); newScript.bulletSpeed = 1f; newScript.turnBullet = true; newScript.turnAfterWait = true; newScript.gradualSpeedChange = true; newScript.timeToSpeedUp = 15; newScript.startingBulletSpeed = 3; newScript.initialMoveDelay = 0; newScript.bulletSprite = (Sprite)nonData[1].misc[0]; bulletsFired[0]++; if (bulletsFired[0] < 1000000000) { bulletNextFireTime[0] += nonData[1].bulletSpawnDelay[0]; } } else { bulletNextFireTime[0] -= gameMaster.timeScale; } }
void ThirdEye() { RandomSmoothedMovement(100, 2, 120); if (bulletsFired.Length == 0) { bulletsFired = new int[1]; bulletNextFireTime = new float[1]; } if (bulletNextFireTime[0] <= 0) { Transform newBullet = Instantiate(nonData[1].bulletSpawnItems[0], thisTrans.position, new Quaternion(), shmupMaster.bulletContainer).transform; BaseBulletScript newScript = newBullet.GetComponent <BaseBulletScript>(); newScript.rotationBasedOnParent = false; newScript.spawnDelay = 15; newScript.updateSprites = true; newScript.regularKillzone = true; int frameDelay = 20; Vector2 directionToPlayer = MathFunctions.FindDirectionToSTGPlayer(thisTrans.position); Vector2 playerMovement = shmupMaster.playerTransform.GetComponent <ShmupChar>().movementVelocity *frameDelay; float angle = Vector2.SignedAngle(directionToPlayer, -playerMovement); float directionToPlayerLength = directionToPlayer.magnitude; float playerMovementLength = playerMovement.magnitude; if (playerMovementLength <= 0) { newScript.bulletSpeed = directionToPlayerLength; newScript.movementDirection = directionToPlayer; } else { newScript.bulletSpeed = Mathf.Sqrt(Mathf.Pow(directionToPlayerLength, 2) + Mathf.Pow(playerMovementLength, 2) - (2 * directionToPlayerLength * playerMovementLength * Mathf.Cos(angle))) / frameDelay; Debug.Log(Mathf.Rad2Deg * Mathf.Asin((Mathf.Sin(Mathf.Deg2Rad * angle) / (newScript.bulletSpeed * frameDelay * 2)) * playerMovementLength)); newScript.movementDirection = MathFunctions.CalculateCircle(MathFunctions.FindAngleToSTGPlayer(thisTrans.position) + (Mathf.Asin((Mathf.Sin(angle) / (newScript.bulletSpeed * frameDelay)) * playerMovementLength))); } newScript.turnBullet = true; newScript.turnAfterWait = true; newScript.gradualSpeedChange = true; newScript.timeToSpeedUp = 15; newScript.startingBulletSpeed = 3; newScript.initialMoveDelay = 0; newScript.bulletSprite = (Sprite)nonData[1].misc[0]; bulletsFired[0]++; if (bulletsFired[0] < 1000000000) { bulletNextFireTime[0] += nonData[1].bulletSpawnDelay[0]; } } else { bulletNextFireTime[0] -= gameMaster.timeScale; } }
public void BulletCollisions() { if (!hitByBullet) { if (invincibilityTime <= 0) { LinkedListNode <EnemyBulletCollider> node = EnemyBulletCollider.colliders.First; EnemyBulletCollider colliderScript = null; float colliderSize; float distance; Vector2 lossyScale; for (int i = 0; i < EnemyBulletCollider.colliders.Count; i++) { if (node == null) { continue; } else { colliderScript = node.Value; if (colliderScript.gameObject.activeInHierarchy) { //colliderSize = colliderScript.hitboxScale * ((Vector2)colliderScript.colliderTransform.lossyScale).magnitude; lossyScale = colliderScript.transform.lossyScale; colliderSize = colliderScript.hitboxScale * (Mathf.Lerp(lossyScale.y, lossyScale.x, Mathf.Abs(MathFunctions.CalculateCircle(MathFunctions.FindAngleToSTGPlayer(colliderScript.transform.position) + (colliderScript.colliderTransform.eulerAngles.z)).x))); distance = Vector2.Distance(colliderScript.colliderTransform.position, thisTrans.position) - colliderSize; if (distance < Mathf.Abs(/*colliderSize + */ (100 * hitboxSpriteRenderer.transform.lossyScale.x))) { /*if (!colliderScript.GetComponentInParent<GrazeScript>().grazed) * { * gameMaster.grazePoints += 1; * gameMaster.score += 500; * AudioSource.PlayClipAtPoint(gameMaster.itemCollectSound, gameMaster.mainCamera.position, GameMasterScript.gameMaster.masterVolume); * colliderScript.GetComponentInParent<GrazeScript>().grazed = true; * ItemDropBase.SpawnItemDrop(ItemDropBase.ItemType.MFOrb, true, Vector2.zero, colliderScript.colliderTransform.position, false); * }*/ if (distance < Mathf.Abs(/*colliderSize + */ colliderSize)) { //HitByBullet(); Debug.Log("Hit by bullet"); BaseBulletScript bulletScript = colliderScript.colliderTransform.GetComponentInParent <BaseBulletScript>(); float multiplier = 1; for (int k = 0; k < gameMaster.playerParty[partyChar].weaknessesAndResistances.Length; k++) { if (gameMaster.playerParty[partyChar].weaknessesAndResistances[k].damageType == bulletScript.damageType) { multiplier = gameMaster.playerParty[partyChar].weaknessesAndResistances[k].damageMultiplier; } } gameMaster.playerParty[partyChar].currentHP -= Mathf.CeilToInt(bulletScript.damage * multiplier * ((shmupManager.captureMode) ? 2 : 1)); if (shmupManager.captureMode) { shmupManager.endSTG = true; } if (colliderScript.GetComponentInParent <BaseBulletScript>() != null) { Destroy(colliderScript.GetComponentInParent <BaseBulletScript>().gameObject); } break; } } } } node = node.Next; } } } }