private void Start() { rb = gameObject.GetComponent <Rigidbody>(); floatingName.text = tankName; tankSide = TankSides.Enemy; patrolling = GetComponent <PatrollingState>(); attacking = GetComponent <AttackingState>(); currentState = patrolling; SetNewCoordinates(); }
/// <summary> /// Change the current state to the assigned new state. /// </summary> /// <param name="id"></param> /// <param name="args"></param> public void ChangeState(NpcStates id) { Destroy(_currentState); if (!states.ContainsKey(id)) { _currentState = null; return; } _currentState = this.gameObject.AddComponent(states[id]) as State; }
/// <summary> /// Check if the checkState state is set. /// </summary> /// <param name="checkState">The state to check for.</param> /// <returns>True:set, False: not set.</returns> public bool IsStateSet(NpcStates checkState) { return((_status & checkState) != 0); }
/// <summary> /// Turns off the changeState flag. /// </summary> /// <param name="changeState">The flag to be turned off.</param> public void UnsetState(NpcStates changeState) { _status &= ~changeState; }
/// <summary> /// Turns on the changeState flag. /// </summary> /// <param name="changeState">The flag to turn on.</param> public void SetState(NpcStates changeState) { _status |= changeState; }
private void Update() { currentState = currentState.Enter(this); }
public StateID(NpcStates state, Type script) { stateName = state; stateScript = script; }
/// <summary> /// Add a state to the StateMachine. /// </summary> /// <param name="id"></param> /// <param name="state"></param> protected void AddState(NpcStates id, Type state) { states.Add(id, state); }