//初期化 protected override void Start() { base.Start(); sr = GetComponent <SpriteRenderer>(); time = 0; eState = FinalBossState.Normal; }
public void ManageTransitionPhase2(GameTime gameTime) { if (isFlipped) { GameManager.Instantiate(flipScreenAttack, new Vector2(0, 0)); isFlipped = false; } finalBossState = FinalBossState.Phase2; }
//待機 private void Stay() { time += Time.deltaTime; if (time > attackTime) { eState = FinalBossState.Return; time = 0; } }
private int attackNowNumber; //現在の攻撃回数 //攻撃 private void Attack() { time += Time.deltaTime; if (time > attackTime) { foreach (var _shot in firstShot) { var shotInstance = Instantiate(_shot.bulletBase, transform.position + new Vector3(_shot.position.x, _shot.position.y, 0), Quaternion.identity); } time = 0; attackNowNumber++; if (attackNowNumber > attackRandomNum) { eState = FinalBossState.Stay; } } }
//地面へ戻る private void Return() { if (time == 0) { randomXGroundPos = Random.Range(groundXMin, groundXMax); moveVelocity = new Vector3(randomXGroundPos, groundPosition, 0) - transform.position; moveVelocity /= moveTime; } if (time + Time.deltaTime > moveTime) { sr.sprite = Base_Sprite; transform.position = new Vector3(randomXGroundPos, groundPosition, 0); eState = FinalBossState.Normal; time = 0; } else { time += Time.deltaTime; transform.position += new Vector3(moveVelocity.x, moveVelocity.y, 0) * Time.deltaTime; } }
//上空への移動 private void Move() { if (time == 0) { sr.sprite = Stand_Sprite; moveVelocity = new Vector3(movePosition.x, movePosition.y, 0) - transform.position; moveVelocity /= moveTime; } if (time + Time.deltaTime > moveTime) { transform.position = movePosition; eState = FinalBossState.Attack; time = 0; attackRandomNum = Random.Range(4, 6); attackNowNumber = 0; } else { time += Time.deltaTime; transform.position += new Vector3(moveVelocity.x, moveVelocity.y, 0) * Time.deltaTime; } }
private void Normal(float distance) { //初期化 if (time == 0) { homingAttackNowTime = 0; shortAttackNowTime = 0; } time += Time.deltaTime; homingAttackNowTime += Time.deltaTime; if (shortAttackInstance == null) { sr.sprite = Base_Sprite; shortAttackNowTime += Time.deltaTime; } if (time > normalTime) { eState = FinalBossState.Move; time = 0; } NormalMove(distance, moveSpeed); if (normalShotTiming < homingAttackNowTime) { foreach (var _shot in normalShot) { var shotInstance = Instantiate(_shot.bulletBase, transform.position + new Vector3(_shot.position.x, _shot.position.y, 0), Quaternion.identity); } homingAttackNowTime = 0; } if (shortAttackTime < shortAttackNowTime) { sr.sprite = Attack_Sprite; shortAttackInstance = Instantiate(shortAttack.bulletBase, Vector3.zero, Quaternion.identity); shortAttackInstance.transform.parent = transform; shortAttackInstance.transform.localPosition = new Vector3(shortAttack.position.x, shortAttack.position.y, 0); shortAttackNowTime = 0; } }
public void ManagePhase1(GameTime gameTime) { if (gameTime.TotalGameTime.TotalMilliseconds >= lastTriangleAttackTime + triangleAttackCooldown) { TriangleAttack(); lastTriangleAttackTime = gameTime.TotalGameTime.TotalMilliseconds; } if ((float)health / totalHealth <= .6f) { if (gameTime.TotalGameTime.TotalMilliseconds >= flipGameScreenLastAttackTime + flipGameScreenAttackCooldown) { GameManager.Instantiate(flipScreenAttack, new Vector2(0, 0)); flipGameScreenLastAttackTime = gameTime.TotalGameTime.TotalMilliseconds; isFlipped ^= true; } if ((float)health / totalHealth <= .4f) { finalBossState = FinalBossState.TransitionPhase2; } } }
public override void Initialize(GameObject owner) { base.Initialize(owner); transform = (Transform)GetComponent <Transform>(); renderer = (SpriteRenderer)GetComponent <SpriteRenderer>(); bossOutline = new Vector2[] { new Vector2(3, 43) * renderer.Sprite.Scale, new Vector2(128, 255) * renderer.Sprite.Scale, new Vector2(253, 43) * renderer.Sprite.Scale }; phaseOneProjectile = GameManager.GetPrefab("BlueProjectile"); flipScreenAttack = GameManager.GetPrefab("FlipGameScreen"); bulletRainProjectile = GameManager.GetPrefab("PurpleDiamondProjectile"); bulletFanProjectile = GameManager.GetPrefab("GreySquareProjectile"); health = totalHealth = 10; finalBossState = FinalBossState.TransitionPhase1; }
public void ManageTransitionPhase1(GameTime gameTime) { finalBossState = FinalBossState.Phase1; }