private void ChangeState(BossState _state) { m_state = _state; m_timeInState = 0.0f; m_stateChanged = true; Debug.Log($"Change State: {m_state.ToString()}"); }
// Update is called once per frame void Update() { if (target != null) { //päivitä tilakone if (!stateUpdates.ContainsKey(bossState)) { Debug.LogError("DragonBossEnemy - No update method defined for state" + bossState.ToString()); } stateUpdate updateFunc = stateUpdates[bossState]; BossState newState = updateFunc(); if (newState != bossState) { Debug.Log("BossState: " + newState.ToString()); if (stateExits.ContainsKey(bossState)) { stateExits[bossState](); } if (stateEntries.ContainsKey(newState)) { stateEntries[newState](); } bossState = newState; } } }
public void ChangeState(BossState newState) { StopCoroutine(bossState.ToString()); bossState = newState; StartCoroutine(bossState.ToString()); }
void Decide() { if (currentCooldown < 0) { BossState randomAttack = (BossState)Random.Range(0, 3); Attack(randomAttack.ToString()); currentCooldown = specialCooldown.Random; } }
private void UpdateBossState() { Debug.Log($"Boss State: {m_state.ToString()}"); m_stateChanged = false; switch (m_state) { case BossState.Roar: RoarState(); break; case BossState.Rest: RestState(); break; case BossState.PounceCharging: PounceChargingState(); break; case BossState.Pouncing: PounceState(); break; case BossState.SpinAttack: SpinAttackState(); break; case BossState.Shotgun: ShotgunState(); break; case BossState.Summon: SummonState(); break; case BossState.Dying: DyingState(); break; default: Debug.LogError("Unknown boss state"); break; } if (!m_stateChanged) { m_timeInState += Time.deltaTime; } }
void FixedUpdate() { if (currentState == BossState.Intro) { if (currIntroTime <= 0) { currentState = BossState.Idle; } currIntroTime -= Time.deltaTime; Debug.Log("Intro"); } else if (currentState == BossState.Idle) { if (currIdleTime <= 0) { currentState = (BossState)UnityEngine.Random.Range(2, (int)BossState.COUNT); Debug.Log("NEW STATE: " + currentState.ToString()); currIdleTime = idleDuration; } else { if (currIdleTime == idleDuration) { anim.SetTrigger("isIdling"); } currIdleTime -= Time.deltaTime; Debug.Log("Idling"); } } else if (currentState == BossState.Patrol) { if (currPatrolIntroTime <= 0) { Patrol(); } else { if (currPatrolIntroTime == patrolIntroDuration) { anim.SetTrigger("isPatrolIntro"); } currPatrolIntroTime -= Time.deltaTime; Debug.Log("Patrol Intro"); } } else if (currentState == BossState.Jump) { if (currJumpIntroTime <= 0) { Jump(); } else { if (currJumpIntroTime == jumpIntroDuration) { anim.SetTrigger("isJumpIntro"); } currJumpIntroTime -= Time.deltaTime; Debug.Log("Jump Intro"); } } }