//移动 private IEnumerator PlayMotionAction(BattleUnitMotionAction action) { if (action == null) { UtilityHelper.LogError("Error BattleHeroMotionAction"); yield break; } UpdateRenderState(BattleUnitRenderState.Action); //手动操作的移动可能没有攻击目标 if (action.targetUnit != null) { action.targetUnit.battleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Selected); } //先显示区域 BattleFieldRenderer.Instance.SetCircularRangeRenderStateActive( true, GridRenderType.MoveRange, action.fromGrid.row, action.fromGrid.column, action.moveRange); //显示路径 BattleFieldRenderer.Instance.SetGridsRenderStateActive(true, action.gridPath); //yield return EGameConstL.WaitForTouchedScreen; //移动 for (int i = 0; i < action.gridPath.Length; ++i) { UpdatePositionByGrid(action.gridPath[i]); yield return(EGameConstL.WaitForDotOneSecond); } //清空范围和路径 BattleFieldRenderer.Instance.SetCircularRangeRenderStateActive(false, GridRenderType.MoveRange); //显示路径 BattleFieldRenderer.Instance.SetGridsRenderStateActive(false, null); //手动操作的移动可能没有攻击目标 if (action.targetUnit != null) { action.targetUnit.battleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Normal); } //TEMP if (!battleUnit.battleUnitAttribute.manualOperation) { UpdateRenderState(BattleUnitRenderState.Normal); } }
//向目标格子移动 public void MoveToTargetGrid(BattleUnitAction battleUnitAction, BattleUnit targetUnit, GridUnit targetGrid, GridUnit[] gridPath) { //是否需要记录过程 if (battleUnitAction != null) { battleUnitAction.motionAction = BattleUnitMotionAction.Get(); battleUnitAction.motionAction.targetUnit = targetUnit; battleUnitAction.motionAction.fromGrid = mapGrid; battleUnitAction.motionAction.gridPath = gridPath; battleUnitAction.motionAction.moveRange = battleUnitAttribute.mobility; } //进入格子,直接设置数据 EnterGrid(targetGrid); }
//向目标格子移动 public void MoveToTargetGrid(BattleUnit targetUnit, GridUnit targetGrid, GridUnit[] gridPath) { BattleUnitMotionAction action = BattleUnitActionEvent.CreateEvent <BattleUnitMotionAction>(BattleUnitActionType.MoveToTarget, this); action.targetUnit = targetUnit; action.fromGrid = mapGrid; action.gridPath = gridPath; action.moveRange = battleUnitAttribute.mobility; battleField.AppendBattleAction(action); //进入格子,直接设置数据 EnterGrid(targetGrid); }