public void AddState(IStateBase state) { if (!statesList.Contains(state)) { statesList.Add(state); } }
// Use this for initialization void Start() { m_OwnerEnemy = GetComponent <IEnemy>(); NewState = new CStateBossRageAttack(gameObject); m_ThreshholdAmt = m_OwnerEnemy.GetStats().MaxHP *healthCondition / 100; }
public StateMachine(Dictionary <TStateEnum, IStateBase <TStateEnum, TStateData> > states) { Data = default; m_CurrentStateType = default; m_CurrentState = null; m_States = states; }
void Start() { activeSkin01 = title01; activeSkin02 = title02; //checker = "MainMenu"; activeState = new MainMenu(this); }
// Use this for initialization void Start() { activeState = new BeginState(this); Debug.Log("This object is of type: " + activeState); gameDataRef=GetComponent<GameData>(); }
/// <summary> /// Adds a new state to the Dictionary of states of a Gameobject /// </summary> /// <param name="_state">New State to be added into dictionary</param> public void AddState(IStateBase _state) { // _state is null if (_state == null) { DebugLogger.LogWarning <StateMachine>("State to be added is null"); return; } // _state already in dictionary if (m_statesDictionary.ContainsKey(_state.GetStateName)) { DebugLogger.LogWarning <StateMachine>("State has been added before"); return; } // if current state is empty, set new state to be current and next state if (m_currState == null) { m_currState = m_nextState = _state; DebugLogger.Log <StateMachine>("New state added, current state is now " + _state.GetStateName); } // Add new states to Dictionary m_statesDictionary.Add(_state.GetStateName, _state); //DebugLogger.Log<StateMachine>("New state added : " + _state.GetStateName); }
public StateMachine(GameStateBase owner) { m_owner = owner; m_currentState = null; m_previousState = null; m_globalState = null; }
public void SetNextState(string _nextStateID) { if (m_stateMap.ContainsKey(_nextStateID)) { m_nextState = m_stateMap[_nextStateID]; } }
void Start() { //starts BeginState, sets it to active state //passes this script - statemanager - to BeginState so it can use it as reference activeState = new BeginState(this); gameDataRef = GetComponent<GameData>(); }
/// <summary> /// 状态切换 /// </summary> /// <param name="id"></param> public void Change(object id, object changeHandleParam = null) { if (id.Equals(cur_StateID)) { return; } else { //1.退出状态 if (cur_State != null) { cur_State.Exit(); } //2.记录新切换的状态 cur_StateID = id; cur_State = getSate(id); //3.进入新状态 cur_State.Enter(); //4.绑定新状态更新内容 OnUpdateHandle = cur_State.update; OnFixedUpdateHandle = cur_State.fixedUpdate; OnLateUpdateHandle = cur_State.lateUpdate; if (onChangeHandle != null && changeHandleParam != null) { onChangeHandle.Invoke(changeHandleParam); } } }
public void SetActiveState(TStateEnum type) { m_CurrentState?.Stopped(ref Data); m_CurrentState = m_States[type]; var previousState = m_CurrentStateType; m_CurrentStateType = type; m_CurrentState.Started(previousState, ref Data); }
void Start() { cUI = GetComponent <ControllerUI>(); canvas = gameObject.transform.GetChild(0).transform.gameObject; audioManager = gameObject.transform.GetChild(1).GetComponent <AudioManager>(); activeState = new BeginState(this); audioManager.PlaySong("Myspals_introSongStart"); }
void Start() { // initialize state machine and managers activeState = new BeginState(this); galaxyDataRef = GetComponent<GalaxyData>(); // gets the galaxy data script containing the data structure gameDataRef = GetComponent<GlobalGameData>(); // gets global game data (screens, etc) that are used universally Debug.Log("This object is of type: " + activeState); }
void Start() { // initialize state machine and managers activeState = new BeginState(this); galaxyDataRef = GetComponent <GalaxyData>(); // gets the galaxy data script containing the data structure gameDataRef = GetComponent <GlobalGameData>(); // gets global game data (screens, etc) that are used universally Debug.Log("This object is of type: " + activeState); }
void Start () { cUI = GetComponent<ControllerUI>(); canvas = gameObject.transform.GetChild(0).transform.gameObject; audioManager = gameObject.transform.GetChild(1).GetComponent<AudioManager>(); activeState = new BeginState(this); audioManager.PlaySong("Myspals_introSongStart"); }
// Use this for initialization void Start() { //we start the game by calling the BeginState() constructor //this is the syntax for calling a constructor. //the "this" is sending a reference to this object - StateManager that the States use to update managerRef activeState = new BeginState (this); //Debugging if the type is correct for activeState Debug.Log ("What's the type of activeState? " + activeState); }
public bool IsInState(IStateBase t) { if (t == CurrentState) { return(true); } else { return(false); } }
/// <summary> /// 删除一个状态 /// </summary> /// <param name="state"></param> public void Remove(IStateBase state) { if (states.ContainsValue(state)) { states.Remove(state); } else { LogQueue.Add(string.Format("提醒:{0}不存在...", state.ToString())); } }
/// <summary> /// 添加状态 /// </summary> /// <param name="state_id">状态ID</param> /// <param name="state"></param> public virtual void Add(object state_id, IStateBase state) { if (!states.ContainsValue(state)) { states.Add(state_id, state); } else { LogQueue.Add(string.Format("提醒:{0}已存在...", state.ToString())); } }
public void SwapExistingState(IStateBase _newState) { if (m_stateMap.ContainsKey(_newState.StateID)) { m_stateMap[_newState.StateID] = _newState; } else { m_stateMap.Add(_newState.StateID, _newState); } }
/// <summary> /// This is where the updating of changing in states takes place /// </summary> public void Update() { // if next state != current state, change current to be next state if (m_nextState != m_currState) { m_currState.ExitState(); m_currState = m_nextState; m_currState.EnterState(); } // Update the curr state m_currState.UpdateState(); //DebugLogger.Log<StateMachine>("Curr State: " + m_currState + " Next State: " + m_nextState); }
// Update is called once per frame public void Update() { if (m_nextState != m_currState) { m_currState.ExitState(); m_currState = m_nextState; m_currState.EnterState(); } if (m_currState != null) { m_currState.UpdateState(); } }
void Start() { gameStateMachine_Ref = this; if (canvas_Ref == null) { if (transform.GetChild(0).gameObject != null) { canvas_Ref = transform.GetChild(0).gameObject; } else { Debug.Log("GameStateMachine is missing a reference to the Canvas"); } } if (gameState == null) { gameState = new BeginState(this); } if (bordersParent_Ref == null) { if (GameObject.Find("BordersParent") != null) { bordersParent_Ref = GameObject.Find("BordersParent"); } else { Debug.Log("GameStateMachine is missing a reference to BordersParent"); } } if (playerInfoOne_Ref == null) Debug.Log("GameStateMachine is missing a reference to playerOneInfo"); if (playerInfoTwo_Ref == null) Debug.Log("GameStateMachine is missing a reference to playerTwoInfo"); playerOneSpawner_Ref.GetComponent<Spawner>().PlayerParent = playerOneParent_Ref; playerTwoSpawner_Ref.GetComponent<Spawner>().PlayerParent = playerTwoParent_Ref; gameState.ShowIt(); playerOneBlocksCollected = new bool[playerOneSpawner_Ref.GetComponent<Spawner>().groups.Length]; playerTwoBlocksCollected = new bool[playerTwoSpawner_Ref.GetComponent<Spawner>().groups.Length]; if(gamesPlayedBeforeRefill == 0) { gamesPlayedBeforeRefill = 28; } inGameUIManager_Ref.UpdatePlayerStatus(WhoIsInTheLead()); }
public bool CheckNewState(IStateBase newState) { if (newState != ActualState) { Console.WriteLine($"{GetType()} - State: {newState.GetType().Name} entered"); _t.Stop(); ActualState?.Exit(); newState.Enter(); _t.Start(); ActualState = newState; return(true); } return(false); }
/// <summary> /// 通过ID获取一个状态 /// </summary> /// <param name="id"></param> /// <returns></returns> protected virtual IStateBase getSate(object id) { IStateBase _state = default(IStateBase); if (states.ContainsKey(id)) { states.TryGetValue(id, out _state); } else { LogQueue.Add(string.Format("提醒:状态机中并不存在ID为{0}的状态", id.ToString())); } return(_state); }
void Start() { if (gameState == null) { gameState = new SplashScreenState(this); } audioManagerRef = AudioManager.GetInstance(); canvasManagerRef = CanvasManager.GetInstance(); cam = Camera.main; loadManagerRef = new LoadManager(); }
public void ChangeState(IStateBase newState) { if (null == newState) { return; } PreviousState = CurrentState; if (null != CurrentState) { CurrentState.Exit(Owner); } CurrentState = newState; CurrentState.Enter(Owner); }
public void ForceChangeState(StateType nextState, params object[] objs) { if (currentState != null) { currentState.StateEnd(); } currentState = StateFactory.CreateState(nextState); currentStateType = nextState; if (currentState != null) { currentState.StateEnter(objs); } }
public void ProcessAction(IAction action) { bool forceCallStateMethod = false; IStateBase newState = ActualState.ProcessAction(action, ref forceCallStateMethod); if (!CheckNewState(newState)) { if (forceCallStateMethod) { ActualState.ProcessTimerElapsed(); _t.Stop(); _t.Start(); } } }
public void AddState(IStateBase _newState) { if (_newState == null) { return; } if (m_stateMap.ContainsKey(_newState.StateID)) { return; } if (m_currState == null) { m_currState = m_nextState = _newState; } m_stateMap.Add(_newState.StateID, _newState); }
void Start () { //Initialization Debug.Log ("Hello from StateManager"); activeState = new BeginState (this); Debug.Log ("This object is of type: " + activeState); gameDataRef = GetComponent<GameData> (); timeForCoroutine = 5; base_url = "http://titan.csd.auth.gr:8081/api/v1/current?name="; Debug.Log ("url" + base_url); //Load a skin for the buttons skin = Resources.Load ("GUISkin") as GUISkin; audio = GetComponent<AudioSource> (); //if (continueCoroutine) { // StartCoroutine(CallCoroutine(timeForCoroutine)); //} }
public void ChangeState(StateType stateType) { foreach (var item in statesList) { if (item.stateType == stateType) { if (currentState != null && IsCanChange) { currentState.OnExit(); currentState = item; currentState.OnEnter(); } else if (currentState == null) { currentState = item; currentState.OnEnter(); } } } }
void Awake() { if (instanceRef == null) { instanceRef = this; DontDestroyOnLoad (gameOject); } else { DestroyImmediate(gameObject); } void Start () { activeState = new BeginnState(this); } void update() { if (activeState != null) activeState.StateUpdate(); }
public static IStateBase CreateState(StateType stateType) { IStateBase ret = null; switch (stateType) { case StateType.GAME_STATE_LAUNCHER: ret = new GameStateLauncher(); break; case StateType.GAME_STATE_LOGIN: ret = new GameStateLogin(); break; case StateType.GAME_STATE_LOADING: ret = new GameStateLoading(); break; default: ret = null; break; } return(ret); }
void Start() { activeState = new BeginState(this); gameDataRef = GetComponent<GameData>(); }
public void SwitchStates(IStateBase newState) { activeState = newState; }
public void SwitchState(IStateBase newState) { activeState = newState; //StartCoroutine(ChangeLevel()); }
void Start() { activeState = new BeginState(this); //print("This object of type: " + activeState); }
void Start() { activeState = new BeginState(this); // Instantiates BeginState() and assigns it to activeStateDebug.Log("This object is of type: " + activeState); }
// Use this for initialization void Start() { activeState = new ConstruktionState (this); }
public void SwitchState(IStateBase aNewState) { _activeState = aNewState; Debug.Log("Switching State!"); _activeState.Initialize(); }
public void SwitchState(IStateBase newState) { //if the activeState decides it needs to change to another state //this function is called, and the manager updates the activeState reference activeState = newState; }
public void SwitchState(IStateBase newState) { activeState = newState; }
void Start() { // this = manageRef activeState = new BeginState(this); Debug.Log("This object is of type: " + activeState); }
private IStateBase activeState; //reference to activeState #endregion Fields #region Methods //Called from the current state to notify StateManager that a new state is the activeState public void SwitchState( IStateBase newState) { activeState = newState; //change the reference to the current active state }
//Unity-Hook: Called once when a new scene is initiated void Start() { activeState= new BeginState(this); //pass in a reference to this manager Debug.Log ("in stateManager start" + activeState); }
void Start () { activeState = new MenüSate (this); }
void Start() { activeState = new BeginState(this); }
public void SwitchState(IStateBase newState);