public BaseMobState(GameObject self) { this.self = self; controller = self.GetComponent <PlayerController>(); motor = self.GetComponent <GridMotor>(); player = GameObject.Find("Player"); }
// public event StateChangedEventHandler OnStateChanged // { // get { return sm.OnStateChanged; } // set { sm.OnStateChanged = value; } // } void Start() { motor = GetComponent <GridMotor>(); sm.RegisterState(PlayerState.Idle, new IdleState(gameObject)); sm.RegisterState(PlayerState.Moving, new MovingState(gameObject)); sm.RegisterState(PlayerState.Attacking, new AttackingState(gameObject)); sm.RegisterState(PlayerState.Blocking, new BlockingState(gameObject)); sm.RegisterState(PlayerState.Dying, new DyingState(gameObject)); sm.ChangeState(PlayerState.Start, PlayerState.Idle); }
public void RequestPath(GridMotor motor, Transform target, OnPathFound callback) { if (null != callback) { if (!isSearching) { OnSearchStart(new PathRequest() { motor = motor, source = motor.transform.position, target = target.position, callback = callback }); } else { requests.Enqueue(new PathRequest() { motor = motor, source = motor.transform.position, target = target.position, callback = callback }); } } }
public BasePlayerState(GameObject self) { this.self = self; controller = self.GetComponent <PlayerController>(); motor = self.GetComponent <GridMotor>(); }