// TICK() GETS CALLED EVERY UPDATE FRAME. public override Type Tick() { // ALL CONDITIONS HERE TO CHANGE FROM IDLE STATE TO ANOTHER ACTION STATE. // special case for boss functionality. if (_obj._Boss == true) { _default = false; // if player is in "15f" range of the boss, bossphase should start. if (Vector3.Distance(_obj.transform.position, GameManager.player_position) < 9f) { GameManager.Instance.ForCoroutine(_obj.BossPhase()); // Call coroutine from manager, passing this _obj own boss phase. //Debug.Log("WHEN DID THIS HAPPEN?!?!"); _state = 1; // set _state to 1, to activate first boss State } } else if (_default == true) { GameManager.Instance.ForCoroutine(IdleWait()); // if not a boss, continue normally with simple idle timer } // idle state, does nothing // _state = 2, waits for x seconds then starts to wander. Can choose and add cases here to change. Also need to change _state as well in IdleWait() switch (_state) { // _state==0 for null state case 0: return(null); // continue in this state. // _state==1 for boss state case 1: Debug.Log("Should be boss now!"); GameManager.Instance.stopCoroutines(); // incase any running coroutine f***s anything up return(typeof(ChaseState)); // force the chase state for boss phase. case 2: Debug.Log("Should stay idle till now! NOW WANDER!"); GameManager.Instance.stopCoroutines(); if (_obj.wander == true) { return(typeof(WanderState)); } else { return(null); } case 3: Debug.Log("Should stay idle till now! NOW STEALTH!"); GameManager.Instance.stopCoroutines(); return(typeof(StealthState)); //add more cases for different _states below here // case 4: // return default: return(null); } }
// TICK() GETS CALLED EVERY UPDATE FRAME. public override Type Tick() { // ALL CONDITIONS HERE TO CHANGE FROM IDLE STATE TO ANOTHER ACTION STATE. // special case for boss functionality. if (_obj._Boss == true) { _default = false; // if player is in "15f" range of the boss, bossphase should start. if (Vector3.Distance(_obj.transform.position, GameManager.player_obj.transform.position) < 6f) { GameManager.Instance.ForCoroutine(_obj.BossPhase()); // Call coroutine from manager, passing this _obj own boss phase. Debug.Log("WHEN DID THIS HAPPEN?!?!"); _state = 1; // set _state to 1, to activate first boss State } } else if (_default == true) { GameManager.Instance.ForCoroutine(IdleWait()); // if not a boss, continue normally with simple idle timer } // idle state, does nothing // _state is 2 waits for 4 seconds then starts to wander. Can choose and add cases here to change. Also need to change _state as well in IdleWait() switch (_state) { // _state==0 for default state case 0: break; // _state==1 for boss state case 1: Debug.Log("Should be boss now!"); //break; // return(typeof(ChaseState)); case 2: Debug.Log("Should stay idle till now!"); //break; // return(typeof(WanderState)); // case 2: // return // case 3: // return default: break; } return(null); }