void UpdateState() { Move(); if (m_CurrentTime >= m_TimeBetweenActions) { BossStates action = (BossStates)UnityEngine.Random.Range(0, Enum.GetNames(typeof(BossStates)).Length); switch (action) { case BossStates.ATTACK_1: m_SpaceshipBehaviour.UsePrimaryInventorySlot(FireType.SINUSOIDAL); break; case BossStates.ATTACK_2: m_SpaceshipBehaviour.UsePrimaryInventorySlot(FireType.CIRCLE); break; case BossStates.ATTACK_3: m_InventoryBehaviour.SetSecondarySlot(ItemType.Missile); m_SpaceshipBehaviour.UseSecondaryInventorySlot(); break; case BossStates.INVULNERAVILITY: m_InventoryBehaviour.SetSecondarySlot(ItemType.Invulnerability); m_SpaceshipBehaviour.UseSecondaryInventorySlot(); break; } m_CurrentTime = 0; } if (!m_IsRageMode && m_SpaceshipBehaviour.m_Health <= m_MaxHealth / 2) { EnterRageMode(); } }
void FixedUpdate() { switch (m_CurrentState) { case EnemyStates.IDLE: if (MathUtils.IsPointInsideCameraView(transform.position)) { if (!m_IsStatic) { m_CurrentState = EnemyStates.IMPULSE; } else { m_CurrentState = EnemyStates.WAIT_SHOOT; } } break; case EnemyStates.IMPULSE: Vector2 force = new Vector2(0, m_TargetPosition.y); m_SpaceshipBehaviour.MoveForce(force); if (Vector3.Distance(m_TargetPosition, transform.position) <= m_DistanceAccelerating) { GenerateTargetPosition(); } m_SpaceshipBehaviour.UsePrimaryInventorySlot(FireType.DEFAULT); break; case EnemyStates.WAIT: if (Vector3.Distance(m_TargetPosition, transform.position) <= m_DistanceToChangeDestination) { m_CurrentState = EnemyStates.IMPULSE; } m_SpaceshipBehaviour.UsePrimaryInventorySlot(FireType.DEFAULT); break; case EnemyStates.WAIT_SHOOT: m_SpaceshipBehaviour.UsePrimaryInventorySlot(FireType.DEFAULT); break; } if (Debug.isDebugBuild) { Debug.DrawLine(transform.position, m_TargetPosition, Color.yellow); } }
void Update() { switch (m_CurrentState) { case EnemyStates.IDLE: if (MathUtils.IsPointInsideCameraView(transform.position)) { m_CurrentState = EnemyStates.WAIT_SHOOT; } break; case EnemyStates.WAIT_SHOOT: m_SpaceshipBehaviour.UsePrimaryInventorySlot(FireType.CIRCLE); break; } }
void ProcessInput() { float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); m_MainSpaceshipBehaviour.Move(moveHorizontal, moveVertical); if (Input.GetButton("Fire1")) { m_MainSpaceshipBehaviour.UsePrimaryInventorySlot(FireType.DEFAULT); } if (Input.GetButton("Fire2")) { m_MainSpaceshipBehaviour.UseSecondaryInventorySlot(); } }