public IWeaponLogic GetWeaponLogic(int?weaponId) { var realWeaponId = weaponId; if (!weaponId.HasValue) { realWeaponId = WeaponUtil.EmptyHandId; } var weaponAllConfig = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(realWeaponId.Value); if (weaponAllConfig.S_DefualtBehavior != null) { _defaultWeaponLogic.SetFireLogic(_fireLogicCreator.GetFireLogic(weaponAllConfig.NewWeaponCfg, weaponAllConfig.InitAbstractLogicConfig)); return(_defaultWeaponLogic); } else if (weaponAllConfig.S_TacticBehvior != null) { return(new TacticWeaponLogic(realWeaponId.Value, _freeArgs)); } else if (weaponAllConfig.S_DoubleBehavior != null) { return(new DoubleWeaponLogic(_fireLogicCreator.GetFireLogic(weaponAllConfig.NewWeaponCfg, weaponAllConfig.S_DoubleBehavior.LeftFireLogic), _fireLogicCreator.GetFireLogic(weaponAllConfig.NewWeaponCfg, weaponAllConfig.S_DoubleBehavior.RightFireLogic))); } return(null); }
public IWeaponLogic GetWeaponLogic(int?weaponId) { var realWeaponId = weaponId; if (!weaponId.HasValue) { realWeaponId = WeaponUtil.EmptyHandId; } if (!realWeaponId.HasValue) { return(null); } var weaponDataConfig = _weaponDataConfigManager.GetConfigById(realWeaponId.Value); var weaponConfig = _weaponConfigManager.GetConfigById(realWeaponId.Value); if (null == weaponConfig || null == weaponConfig) { realWeaponId = WeaponUtil.EmptyHandId; } if (!realWeaponId.HasValue) { Logger.Error("weaponId is illegal and no hand in config"); return(null); } var defaultConfig = weaponDataConfig.WeaponLogic as DefaultWeaponLogicConfig; if (null != defaultConfig) { _defaultWeaponLogic.SetFireLogic(_fireLogicCreator.GetFireLogic(weaponConfig, defaultConfig.FireLogic)); return(_defaultWeaponLogic); } var doubleConfig = weaponDataConfig.WeaponLogic as DoubleWeaponLogicConfig; if (null != doubleConfig) { return(new DoubleWeaponLogic(_fireLogicCreator.GetFireLogic(weaponConfig, doubleConfig.LeftFireLogic), _fireLogicCreator.GetFireLogic(weaponConfig, doubleConfig.RightFireLogic))); } var tacticConfig = weaponDataConfig.WeaponLogic as TacticWeaponLogicConfig; if (null != tacticConfig) { return(new TacticWeaponLogic(realWeaponId.Value, _freeArgs)); } Logger.ErrorFormat("illegal weaponLogic for id {0}", realWeaponId); return(null); }