public void MoveTroops(MainBaseVO from, MainBaseVO end) { if (from != null && end != null && !from.Equals(end)) { int soldierCount = from.soldierNum / 2; if (soldierCount <= 0) { return; } var msgParam = TreeMsgParamsPool <MainBaseVO, MainBaseVO, int> .Instance.Pop(); msgParam.InitParams(from, end, soldierCount); sender(GlobalSetting.Cmd_MoveTroops, msgParam); } }
public override void HandleNotification(INotification notification) { switch (notification.Name) { case GlobalSetting.Msg_InitMobilizeTroopsMediator: MobilizeTroopsInfoUIForm uiform = notification.Body as MobilizeTroopsInfoUIForm; if (uiform) { InitMobilizeTroopsMediator(uiform); } break; case GlobalSetting.Msg_PickMainBase: MainBaseVO vO = notification.Body as MainBaseVO; if (vO != null) { if (_OriginMainBaseVO == null && _TargetMainBaseVO == null) { _UIForm.OpenUIForm(GlobalSetting.UI_MobilizeTroopsInfoUIForm); } if (vO.ower.IsUser && _OriginMainBaseVO == null) { _OriginMainBaseVO = vO; _TroopSoldiers = vO.soldierNum / 2; _UIForm.SetOriginInfo(vO.tilePositon, _TroopSoldiers); } else if (_OriginMainBaseVO != null && vO.Equals(_OriginMainBaseVO)) { _TroopSoldiers = vO.soldierNum / 2; _UIForm.SetOriginInfo(vO.tilePositon, _TroopSoldiers); } else { _TargetMainBaseVO = vO; _UIForm.SetTargetInfo(vO.tilePositon); } if (_OriginMainBaseVO != null && _TargetMainBaseVO != null) { var threeCmdParams = TreeMsgParamsPool <MainBaseVO, MainBaseVO, int> .Instance.Pop(); threeCmdParams.InitParams(_OriginMainBaseVO, _TargetMainBaseVO, _TroopSoldiers); SendNotification(GlobalSetting.Cmd_MoveTroops, threeCmdParams); _OriginMainBaseVO = null; _TargetMainBaseVO = null; _UIForm.DelayClose(1); } } break; case GlobalSetting.Msg_EndBattle: _OriginMainBaseVO = null; _TargetMainBaseVO = null; _UIForm.CloseUIForm(); break; default: break; } }