protected override UnitMoveLogic createMoveLogic() { if (!_g9) { _m9 = instance.Type.GetMethod("createMoveLogic", 0); _g9 = true; } if (_m9 != null && !_b9) { _b9 = true; UnitMoveLogic re = (UnitMoveLogic)appdomain.Invoke(_m9, instance, null); _b9 = false; return(re); } else { return(base.createMoveLogic()); } }
//logics /** 注册逻辑体 */ protected override void registLogics() { if ((identity = createIdentityLogic()) != null) { addLogic(identity); } else { Ctrl.throwError("不能没有identity"); } if ((pos = createPosLogic()) != null) { addLogic(pos); } //战斗单位再加 if (BaseC.constlist.unit_canFight(_type)) { if ((avatar = createAvatarLogic()) != null) { addLogic(avatar); } if ((move = createMoveLogic()) != null) { addLogic(move); } if ((fight = createFightLogic()) != null) { addLogic(fight); } if ((ai = createAILogic()) != null) { addLogic(ai); } if ((aiCommand = createAICommandLogic()) != null) { addLogic(aiCommand); } } //角色控制逻辑 if (isHero) { if ((control = createCharacterControlLogic()) != null) { addLogic(control); } } //show放下面 if ((show = createShowLogic()) != null) { addLogic(show); } else { Ctrl.throwError("不能没有show"); } //head最后 if (BaseC.constlist.unit_needHead(_type)) { if ((head = createHeadLogic()) != null) { addLogic(head); } } }
/** 更新指令(1秒10次) */ public void updateCommand(int delay) { switch (_commandType) { case UnitAICommandType.Protect: { } break; case UnitAICommandType.Escape: { _aiLogic.updateEscape(); } break; case UnitAICommandType.MoveTo: case UnitAICommandType.PickUpItem: { //没有移动中 if (!_unit.move.isMoving()) { //向目标移动 _unit.move.moveTo(_commandPos); } else { if (_commandType == UnitAICommandType.PickUpItem) { if (_unit.pos.calculateDistanceSq(_commandPos) <= Global.pickUpRadiusSq) { pickUpMoveOver(); } } } } break; case UnitAICommandType.MoveDir: { UnitMoveLogic unitMoveLogic = _unit.move; _commandPassTime += delay; //没有移动中 if (unitMoveLogic.canMoveNow() && (!unitMoveLogic.isMoving() || _commandPassTime >= Global.moveDirSendDelay)) { _commandPassTime = 0; doMoveDirOnce(); } } break; case UnitAICommandType.MoveToUnit: { //没有移动中 if (!_unit.move.isMoving()) { Unit unit = _commandUnit.getUnit(); if (unit != null) { //向目标移动 _unit.move.moveToUnit(unit, _commandDistance); } else { commandFailed(); } } } break; case UnitAICommandType.AttackMoveTo: { //没有移动中 if (_unit.ai.isIdle() && !_unit.move.isMoving()) { //向目标移动 _unit.move.moveTo(_commandPos); } } break; case UnitAICommandType.SpecialMoveTo: { } break; case UnitAICommandType.Follow: case UnitAICommandType.FollowAttack: { if (_unit.ai.isIdle() && _unit.move.canMoveNow()) { Unit unit = _commandUnit.getUnit(); if (unit == null) { commandOver(); } else { if (_unit.pos.calculateDistanceSq(unit.pos.getPos()) > _fightUnitConfig.followRadiusT) { _unit.move.moveToUnit(unit, _fightUnitConfig.followRadius); } } } } break; } }