// Use this for initialization void Start () { _levelGridComponent = LevelGridComponent.Instance; _currentCellPosition = _levelGridComponent.GetCellIndexes(CachedTransform.position); ChangeControllerState(ControllerStates.Stand); }
public void StartStep() { LevelGridComponent.CellPoint tmpCell = new LevelGridComponent.CellPoint(_targetController._currentCellPosition.x,_targetController._currentCellPosition.y); tmpCell.x += (int)_targetController.CachedTransform.forward.x; tmpCell.y += (int)_targetController.CachedTransform.forward.z; if(_targetController._levelGridComponent.isContainsCell(tmpCell) ) { if(_targetController._levelGridComponent.Grid[tmpCell.x,tmpCell.y].CellContainValue == LevelGridComponent.SCellValue.ECellContainValues.Empty) { _startPoint = _targetController.CachedTransform.position; _targetCell = tmpCell; _targetPoint = _targetController._levelGridComponent.GetCellPosition(tmpCell); _targetPoint.y = _targetController.CachedTransform.position.y; _distance = Vector3.Distance(_targetPoint,_targetController.CachedTransform.position); _movingTime = _distance/_targetController.MovingSpeed; isUpdateting = true; } else { _targetController.ChangeControllerState(ControllerStates.Stand); isUpdateting = false; Clear(); if(StateChangedEvent != null) StateChangedEvent(CharacterController.ControllerStates.Moving,CharacterController.ControllerStates.Stand, "false: " + _targetController._levelGridComponent.Grid[tmpCell.x,tmpCell.y].CellContainValue.ToString()); } } else { _targetController.ChangeControllerState(ControllerStates.Stand); isUpdateting = false; Clear(); if(StateChangedEvent != null) StateChangedEvent(CharacterController.ControllerStates.Moving,CharacterController.ControllerStates.Stand, "false: empty cell"); } }
public StepState(CharacterController targetController) { _targetController = targetController; _targetPoint = new Vector3(); _targetCell = new LevelGridComponent.CellPoint(); isUpdateting = false; }