public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options) { switch (messageType) { case ObserverMsgTypeEnum.PLAYER_START_TO_MOVE_BY_CLICK_GROUND: { _animatorComponent.SetFloat("OnAttack", 0f); // 如果之前有选中可攻击的作战单位,把选中的 maskGo Active设置 false _playerInfoBlackBoard.getSelectBattleUnitLocaltionMaskGo().SetActive(false); // 告诉移动组建,开始移动 RaycastHit raycastHit = (RaycastHit)paramsObj; this.doMoveToByPosition(raycastHit.point); break; } case ObserverMsgTypeEnum.PLAYER_START_ATTACK: { AIBattleUnit selectBattleUnit = this.getCurrSelectBattleUnit(paramsObj); if (_palyerBattleUnitComponent.gameObject != _playerInfoBlackBoard.getCurrleadGo()) { throw new Exception("PlayerUnitManager 只能添加到主角身上"); } // 如果攻击的不是自己 if (_palyerBattleUnitComponent != selectBattleUnit) { _palyerBattleUnitComponent.attack(selectBattleUnit); } break; } } }
protected override void actionAwake() { _playerInfoBlackBoard = SceneBlackBoard.getInstance().getBlackBoard <PlayerInfoBlackBoard>(); _playerUnitManagerComponent = _playerInfoBlackBoard.getCurrleadGo().GetComponent <PlayerUnitManager>(); }