void IPeMsg.OnMsg(EMsg msg, params object[] args) { switch (msg) { case EMsg.View_Prefab_Build: { BiologyViewRoot viewRoot = (BiologyViewRoot)args[1]; _boneCollector = (args[0] as BiologyViewCmpt).monoBoneCollector; _modelCmpt = viewRoot.armorBones; if (_armorObjects != null) { for (int i = 0; i < _armorObjects.Count; i++) { _armorObjects[i].CreateModel(); } } break; } case EMsg.Battle_BeAttacked: { int selected = SelectArmorPartToAttack(); if (selected >= 0) { _armorObjects[selected].OnBeAttacked((float)args[0] * PEVCConfig.instance.armorDamageRatio, (SkillSystem.SkEntity)args[1]); } break; } case EMsg.View_FirstPerson: { if ((bool)args[0] != _isFirstPersonMode) { _isFirstPersonMode = !_isFirstPersonMode; if (_armorObjects != null) { for (int i = 0; i < _armorObjects.Count; i++) { _armorObjects[i].SyncModelFirstPersonMode(); } } } break; } } }
/// <summary> /// 初始化 /// </summary> public void Init(PeViewController viewController, GameObject viewModel, PlayerArmorCmpt armorCmpt) { if (_vc != viewController) { _vc = viewController; _vc.moveHandle.OnTargetMove += OnMoveHandle; _vc.rotateHandle.OnTargetRotate += OnRotateHandle; _vc.scaleHandle.OnTargetScale += OnScaleHandle; _vc.moveHandle.OnBeginTargetMove += value => dragWindowEnabled = false; _vc.rotateHandle.OnBeginTargetRotate += value => dragWindowEnabled = false; _vc.scaleHandle.OnBeginTargetScale += value => dragWindowEnabled = false; _vc.moveHandle.OnEndTargetMove += value => dragWindowEnabled = true; _vc.rotateHandle.OnEndTargetRotate += value => dragWindowEnabled = true; _vc.scaleHandle.OnEndTargetScale += value => dragWindowEnabled = true; // 在线模式需要同步服务器数据 if (PeGameMgr.IsMulti) { _vc.moveHandle.OnEndTargetMove += value => { if (_target && _highlightIndex >= 0 && !_armorCmpt.hasRequest) { _armorCmpt.C2S_SyncArmorPartPosition( arrayIndexToBoneGroup[_highlightIndex], arrayIndexToBoneIndex[_highlightIndex], _isDecoration, _target.localPosition); } }; _vc.rotateHandle.OnEndTargetRotate += value => { if (_target && _highlightIndex >= 0 && !_armorCmpt.hasRequest) { _armorCmpt.C2S_SyncArmorPartRotation( arrayIndexToBoneGroup[_highlightIndex], arrayIndexToBoneIndex[_highlightIndex], _isDecoration, _target.localRotation); } }; _vc.scaleHandle.OnEndTargetScale += value => { if (_target && _highlightIndex >= 0 && !_armorCmpt.hasRequest) { _armorCmpt.C2S_SyncArmorPartScale( arrayIndexToBoneGroup[_highlightIndex], arrayIndexToBoneIndex[_highlightIndex], _isDecoration, _target.localScale); } }; } } _viewCamera = viewController.viewCam; _light = _viewCamera.GetComponentInParent <Light>(); _armorBones = viewModel.GetComponent <ArmorBones>(); _armorCmpt = armorCmpt; }