コード例 #1
0
 public void Awake()
 {
     states = new Dictionary <string, ICameraState>();
     AddState("Action", new CameraActionState(this));
     AddState("Lock", new CameraLockState(this));
     current = Get("Action");
     current.Enter();
 }
コード例 #2
0
    // Use this for initialization
    public void Start()
    {
        if (current == null) //no states
        {
            throw new UnityException("STATE MACHINE IS EMPTY");
        }
        current.Enter();

        if (target == null) //no player selected
        {
            GameObject go = GameObject.FindGameObjectWithTag("Player");
            if (go != null)
            {
                target = go.transform;
                return;
            }
        }
    }
コード例 #3
0
 private void Switch(string newStateName)
 {
     current.Exit();
     current = states[newStateName];
     current.Enter();
 }