//change the current state to the selected state public void ChangeState(eBossState _newState) { switch (_newState) { case eBossState.Spawn: m_CurrentState = m_StateSpawn; break; case eBossState.CreateMuzzle: m_CurrentState = m_StateCreateMuzzle; break; case eBossState.DeleteMuzzle: m_CurrentState = m_StateDeleteMuzzle; break; case eBossState.Attack: m_CurrentState = m_StateAttack; break; case eBossState.Retreat: m_CurrentState = m_StateRetreat; break; case eBossState.DeleteEntity: m_CurrentState = m_StateDeleteEntity; break; case eBossState.Move: m_CurrentState = m_StateMove; break; } m_CurrentState.Enter(); }
public void ChangeState(eBossState _newState) //change the current state to the selected state { switch (_newState) { case eBossState.Spawn: m_CurrentState = m_StateSpawn; break; case eBossState.ChangeAttack: m_CurrentState = m_StateChangeAttack; break; case eBossState.RandomiseBehaviour: m_CurrentState = m_StateRandomiseBehaviour; break; case eBossState.Attack: m_CurrentState = m_StateAttack; break; case eBossState.Move: m_CurrentState = m_StateMove; break; } Debug.Log(m_CurrentState); m_CurrentState.Enter(); }
//===================================================== private void ExitState(eBossState shieldStateExited) { if (_currentJobs == null || _currentJobs.Count <= 0) { return; } foreach (var job in _currentJobs) { if (job != null) { job.Kill(); } } // Clear jobs list _currentJobs.Clear(); }
public void ChangeState(eBossState _newState) //change the current state to the selected state { switch (_newState) { case eBossState.Spawn: m_CurrentState = m_StateSpawn; break; case eBossState.CreateMuzzle: m_CurrentState = m_StateCreateMuzzle; break; case eBossState.DeleteMuzzle: m_CurrentState = m_StateDeleteMuzzle; break; case eBossState.Attack: m_CurrentState = m_StateAttack; break; case eBossState.Retreat: m_CurrentState = m_StateRetreat; break; case eBossState.DeleteEntity: m_CurrentState = m_StateDeleteEntity; break; case eBossState.Move: m_CurrentState = m_StateMove; break; } m_CurrentState.Enter(); }
//===================================================== #region State Controllers private void EnterState(eBossState bossStateEntered) { switch (bossStateEntered) { case eBossState.INIT: // Delay then IDLE StartCoroutine(Initialising()); break; case eBossState.IDLE: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.cyan; // Assign jobs and update jobs list _currentJobs.Add(new Job(Idling())); // Note: Exiting from state ( -> TELEPORT ) is managed in Update() break; case eBossState.TELEPORT: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.black; // Assign jobs var teleporting = new Job(Teleporting(() => { Debug.Log("Teleported into scene!"); CurrentState = eBossState.SUMMON_GEMS; }), true); // Update jobs list _currentJobs.Add(teleporting); break; case eBossState.SUMMON_GEMS: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.magenta; // Assign jobs var summonGems = new Job(SummoningGems(() => { Debug.Log("Summoned Gems!"); CurrentState = eBossState.SUMMON_ENEMIES; }), true); // Update jobs list _currentJobs.Add(summonGems); break; case eBossState.SUMMON_ENEMIES: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.magenta; // Assign jobs var summonEnemies = new Job(SummoningEnemies(() => { Debug.Log("Summoned Enemies!"); CurrentState = eBossState.ATTACK; }), true); // Update jobs list _currentJobs.Add(summonEnemies); break; case eBossState.ATTACK: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.red; // Assign jobs var attacking = new Job(Attacking(() => { Debug.Log("Attacked complete!"); CurrentState = eBossState.IDLE; _timer = _attackInterval; Debug.Log("_attackInterval: timer: " + _timer); }), true); // Update jobs list _currentJobs.Add(attacking); break; case eBossState.DISABLED: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.white; // Exiting from state (-> RECOVER ) is managed in Update() if (_previousState != eBossState.DISABLED_DAMAGED) { _timer = _disabledInterval; Debug.Log("***_disabledInterval: timer: " + _timer); // Show health bar _healthBar.SetHealthBar(_health / _maxHealth); _healthBar.ShowBubble(); } break; case eBossState.DISABLED_DAMAGED: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.red; Debug.Log("DISABLED_DAMAGED"); // Damaged -> DISABLED StartCoroutine(Interval(0, 0.5f, () => { if (_timer > 0.0f) { CurrentState = eBossState.DISABLED; } })); break; case eBossState.RECOVER: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.white; // Assign jobs var recovering = new Job(Recovering(() => { Debug.Log("Recovered!"); // Hide health bar _healthBar.HideBubble(); CurrentState = eBossState.TELEPORT; }), true); // Update jobs list _currentJobs.Add(recovering); break; case eBossState.DEAD: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.black; _animator.SetTrigger(HashIDs.Dead); // Add penalties to wild magic rate and population (first time awards then default awards thereafter) if (PlayerPrefsWrapper.HasKey("PlayerWinsFirstBossFight") && PlayerPrefsWrapper.GetInt("PlayerWinsFirstBossFight") == 1) { GameDataManager.Instance.AddWildMagicAndPopulation(WildMagicItemsManager.GetWildMagicItem("WM_RATE_BOSS_FIGHT_WIN_DEFAULT")); } else { GameDataManager.Instance.AddWildMagicAndPopulation(WildMagicItemsManager.GetWildMagicItem("WM_RATE_BOSS_FIGHT_WIN_FIRST")); PlayerPrefsWrapper.SetInt("PlayerWinsFirstBossFight", 1); } // Update managers _gridManager.OnBossDeadEvent(); _enemyManager.OnClearEnemiesEvent(true); GameManager.Instance.OnBossDeadEvent(); break; } }