//------------------------------------------------------------------------- public List <_ToolTipContentDetailInfo> getToolTipEquipContentDetailText(List <EffectData> list_effect, Dictionary <string, IProp> map_prop) { List <_ToolTipContentDetailInfo> list_detail = new List <_ToolTipContentDetailInfo>(); foreach (var i in list_effect) { if (i.ListParam == null || i.ListParam.Length <= 0) { continue; } TbDataEffect tb_effect = EbDataMgr.Instance.getData <TbDataEffect>(i.EffectId); Ps.PropOperate op = (Ps.PropOperate) byte.Parse(i.ListParam[0]); IProp p = null; map_prop.TryGetValue(tb_effect.SelfDefine1, out p); if (p == null) { IProp.setProp <int>(map_prop, tb_effect.SelfDefine1, 0); } Prop <int> prop = (Prop <int>)map_prop[tb_effect.SelfDefine1]; string value = tb_effect.FormatDesc.Replace("%s", ""); value += _getOperateStr(op); value += (" " + prop.get().ToString()); _ToolTipContentDetailInfo content_detail = new _ToolTipContentDetailInfo(); content_detail.detail_type = _eToolTipContentDetailType.NormalLable; content_detail.param = value; list_detail.Add(content_detail); } return(list_detail); }
private bool UpdateTargetWithStartingValue(WeakRefKey <IPropBag> bindingTarget, PropNode sourcePropNode) { IProp typedProp = sourcePropNode.PropData_Internal.TypedProp; PropStorageStrategyEnum ss = typedProp.PropTemplate.StorageStrategy; switch (ss) { case PropStorageStrategyEnum.Internal: { T newValue = (T)typedProp.TypedValueAsObject; bool result = UpdateTarget(bindingTarget, newValue); return(result); } case PropStorageStrategyEnum.External: goto case PropStorageStrategyEnum.Internal; // This property has no backing store, there is no concept of a starting value. case PropStorageStrategyEnum.Virtual: return(false); default: throw new InvalidOperationException($"{ss} is not a recognized or supported Prop Storage Strategy when used as a source for a local binding."); } }
//public virtual IProp CreateGenFromString(Type typeOfThisProperty, // string value, bool useDefault, // PropNameType propertyName, object extraInfo, // PropStorageStrategyEnum storageStrategy, bool isTypeSolid, PropKindEnum propKind, // Delegate comparer, bool useRefEquality = false, Type itemType = null) //{ // MemConsumptionTracker mct = new MemConsumptionTracker(enabled: false); // if (propKind == PropKindEnum.Prop) // { // CreateScalarProp propCreator = GetPropCreator(typeOfThisProperty); // mct.MeasureAndReport("GetPropCreator", $"for {propertyName}"); // // TODO: This is where strings are parsed to create objects of type T. // // TODO: This needs more work, to say the least. // IProp prop = propCreator(this, haveValue: true, value: value, useDefault: useDefault, propertyName: propertyName, // extraInfo: extraInfo, storageStrategy: storageStrategy, isTypeSolid: isTypeSolid, // comparer: comparer, useRefEquality: useRefEquality, getDefaultValFunc: null); // mct.MeasureAndReport("Ran propCreator to get IProp", $"for {propertyName}"); // return prop; // } // else if (propKind.IsCollection()) // { // CreateCPropFromStringDelegate propCreator = GetCPropFromStringCreator(typeOfThisProperty, itemType); // mct.MeasureAndReport("GetCPropFromStringCreator", $"for {propertyName}"); // IProp prop = propCreator(this, value: value, useDefault: useDefault, propertyName: propertyName, // extraInfo: extraInfo, storageStrategy: storageStrategy, isTypeSolid: isTypeSolid, // comparer: comparer, useRefEquality: useRefEquality); // mct.MeasureAndReport("Ran GetCPropFromStringCreator to get IProp", $"for {propertyName}"); // return prop; // } // else // { // throw new InvalidOperationException($"PropKind = {propKind} is not recognized or is not supported."); // } //} public virtual IProp CreateGenWithNoValue(Type typeOfThisProperty, PropNameType propertyName, object extraInfo, PropStorageStrategyEnum storageStrategy, bool isTypeSolid, PropKindEnum propKind, Delegate comparer, bool useRefEquality = false, Type itemType = null) { MemConsumptionTracker mct = new MemConsumptionTracker(enabled: false); if (propKind == PropKindEnum.Prop) { CreateScalarProp propCreator = GetPropCreator(typeOfThisProperty); mct.MeasureAndReport("GetPropCreator", $"for {propertyName}"); IProp prop = propCreator(this, haveValue: false, value: null, useDefault: false, propertyName: propertyName, extraInfo: extraInfo, storageStrategy: storageStrategy, isTypeSolid: isTypeSolid, comparer: comparer, useRefEquality: useRefEquality, getDefaultValFunc: null); mct.MeasureAndReport("Ran propCreator to get IProp", $"for {propertyName}"); return(prop); } else if (propKind.IsCollection()) { CreateCPropWithNoValueDelegate propCreator = GetCPropWithNoValueCreator(typeOfThisProperty, itemType); IProp prop = propCreator(this, propertyName: propertyName, extraInfo: extraInfo, storageStrategy: storageStrategy, isTypeSolid: isTypeSolid, comparer: comparer, useRefEquality: useRefEquality); return(prop); } else { throw new InvalidOperationException($"PropKind = {propKind} is not recognized or is not supported."); } }
private bool UpdateTargetWithStartingValue(WeakReference <IPropBagInternal> bindingTarget, StoreNodeProp sourcePropNode) { bool result; if (NoTarget_NotifiesReceiverInstead) { //WeakReference<IPropBagInternal> propItemParentPropBag_internal = sourcePropNode?.Parent?.PropBagProxy; //WeakReference<IPropBag> propItemParentPropBag = GetPublicVersion(propItemParentPropBag_internal); WeakReference <IPropBag> propItemParentPropBag_wr = GetPropItemParent(_propStoreAccessService_wr, sourcePropNode); result = NotifyReceiver(_storeNodeUpdateReceiver, propItemParentPropBag_wr); } else { IProp typedProp = sourcePropNode.PropData_Internal.TypedProp; if (typedProp.StorageStrategy == PropStorageStrategyEnum.Internal) { T newValue = (T)typedProp.TypedValueAsObject; result = UpdateTarget(_targetObject, newValue); } else { // This property has no backing store, there is no concept of a starting value. (Propably used to send messages.) result = false; } } return(result); }
/// <summary> /// 更新显示的UI,只在数量变化时改变 /// </summary> public void UpdateImage(int num) { E.gameObject.SetActive(Selected); if (num == Num) { return; } Num = num; // 数目>=0和数目<0的不同显示 if (num < 0) { img.sprite = null; img.color = Color.clear; HasItem = false; count.gameObject.SetActive(false); } else { IProp prop = UiInventory.Props[ID]; if (prop == null) { Debug.LogError("数据库中没有这个道具"); return; } img.sprite = prop.GetIcon(); HasItem = true; img.color = Color.white; count.gameObject.SetActive(true); count.text = num.ToString(); } }
/// <summary> /// Установить соответсвующее в контейнере значения /// </summary> /// <param name="prop">Устанавливаемое значение</param> public void Set(IProp prop) { if (prop != null && Dictionary.ContainsKey(prop.Name)) { Dictionary[prop.Name] = prop.Value; } }
public override void SetHeight(float height) { Vector3 newPosition = position; newPosition.y = height; if (PropLayer.Manager.GetSnappingState()) { float terrainHeight = Singleton <TerrainManager> .instance.SampleDetailHeight(newPosition); if (height > terrainHeight + 0.075f || height < terrainHeight - 0.075f) { PropLayer.Manager.SetFixedHeight(id, true); } else { PropLayer.Manager.SetFixedHeight(id, false); } } IProp prop = PropLayer.Manager.Buffer(id); prop.MoveProp(newPosition); prop.UpdatePropRenderer(true); }
public void TransferProp_Equipment_StoreEventsRaised() { // ARRANGE var equipmentScheme = new TestPropScheme { Equip = new TestPropEquipSubScheme() }; // Инвентарь var inventory = new InventoryModule(); // контейнер var containerProps = new IProp[] { new Equipment(equipmentScheme, System.Array.Empty <ITacticalActScheme>()) }; var container = new FixedPropChest(containerProps); // трансферная машина var transferMachine = new PropTransferMachine(inventory, container.Content); // ACT using var monitorInventory = transferMachine.Inventory.Monitor(); using var monitorContainer = transferMachine.Container.Monitor(); var transferResource = containerProps.First(); transferMachine.TransferProp(transferResource, PropTransferMachineStores.Container, PropTransferMachineStores.Inventory); // ASSERT monitorInventory.Should().Raise(nameof(PropTransferStore.Added)); monitorContainer.Should().Raise(nameof(PropTransferStore.Removed)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Model.PropInfo p = new Model.PropInfo(); p.PropId = Convert.ToInt32(Request["PropId"]); p.PropName = Request["PropName"].ToString(); p.PropIntroduction = Request["PropIntroduction"].ToString(); p.PropPrice = Convert.ToDecimal(Request["PropPrice"]); p.PropImage = Request["PropImage"].ToString(); p.createDate = DateTime.Now.ToString(); p.outNumber = Convert.ToInt32(Request["outNumber"]); IProp ip = BllFactory.BllAccess.CreateIPropBLL(); try { ip.updatePropInfo(p); Response.Write("{success:true,msg:'修改成功'}"); } catch (Exception ex) { string msg = ex.Message.ToStr(); Response.Write("{success:false,msg:'" + msg + "'}"); } } }
/// <summary> /// Установить значение, если отстутствует добавить в контейнер /// </summary> /// <param name="prop">Устанавливаемое значение</param> public void Assign(IProp prop) { if (prop != null && prop.Name.IsValue()) { Dictionary[prop.Name] = prop.Value; } }
//制造一个数据访问层的商城相关接口实例 public static IProp CreateIProp() { string typeName = path + ".PropAccess"; IProp IP = (IProp)Assembly.Load(path).CreateInstance(typeName); return(IP); }
public void TransferProp_Resources() { // ARRANGE var resourceScheme = new TestPropScheme(); // Инвентарь var inventory = new InventoryModule(); // контейнер var containerProps = new IProp[] { new Resource(resourceScheme, 1) }; var container = new FixedPropChest(containerProps); // трансферная машина var transferMachine = new PropTransferMachine(inventory, container.Content); // ACT var transferResource = new Resource(resourceScheme, 1); transferMachine.TransferProp(transferResource, PropTransferMachineStores.Container, PropTransferMachineStores.Inventory); // ASSERT transferMachine.Inventory.PropAdded[0].Should().BeOfType <Resource>(); var invResource = (Resource)transferMachine.Inventory.PropAdded[0]; invResource.Count.Should().Be(1); }
public void TransferProp_Equipment() { // ARRANGE var equipmentScheme = new TestPropScheme { Equip = new TestPropEquipSubScheme() }; // Инвентарь var inventory = new InventoryModule(); // контейнер var containerProps = new IProp[] { new Equipment(equipmentScheme, System.Array.Empty <ITacticalActScheme>()) }; var container = new FixedPropChest(containerProps); // трансферная машина var transferMachine = new PropTransferMachine(inventory, container.Content); // ACT var transferResource = containerProps.First(); transferMachine.TransferProp(transferResource, PropTransferMachineStores.Container, PropTransferMachineStores.Inventory); // ASSERT transferMachine.Inventory.PropAdded[0].Should().BeOfType <Equipment>(); transferMachine.Container.PropRemoved[0].Should().BeOfType <Equipment>(); }
/// <summary> /// Добавление предмета в хранилище. /// </summary> /// <param name="prop"> Целевой предмет. </param> public void Add(IProp prop) { switch (prop) { case Resource resource: // запоминаем предыдущее состояния для событий var oldProp = (Resource)CalcActualItems()?.SingleOrDefault(x => x.Scheme == prop.Scheme); TransferResource(resource, PropAdded, PropRemoved); // Выброс событий var currentProp = CalcActualItems()?.SingleOrDefault(x => x.Scheme == prop.Scheme); if (oldProp == null) { Added?.Invoke(this, new PropStoreEventArgs(currentProp)); } else { Changed?.Invoke(this, new PropStoreEventArgs(currentProp)); } break; case Equipment _: case Concept _: TransferNoCount(prop, PropRemoved, PropAdded); Added?.Invoke(this, new PropStoreEventArgs(prop)); break; } }
public void TransferProp_ChangesResources_StoreEventsRaised() { // ARRANGE var resourceScheme = new TestPropScheme(); // Инвентарь var inventory = new InventoryModule(); inventory.Add(new Resource(resourceScheme, 1)); // контейнер var containerProps = new IProp[] { new Resource(resourceScheme, 2) }; var container = new FixedPropChest(containerProps); // трансферная машина var transferMachine = new PropTransferMachine(inventory, container.Content); // ACT using var monitorInventory = transferMachine.Inventory.Monitor(); using var monitorContainer = transferMachine.Container.Monitor(); var transferResource = new Resource(resourceScheme, 1); transferMachine.TransferProp(transferResource, PropTransferMachineStores.Container, PropTransferMachineStores.Inventory); // ASSERT monitorInventory.Should().Raise(nameof(PropTransferStore.Changed)); monitorContainer.Should().Raise(nameof(PropTransferStore.Changed)); }
public void Add_AddResourceToInventoryWithThisResource_PropContains2UnitsOfResource() { // ARRANGE const int inventoryCount = 1; const int testedCount = 1; const int expectedCount = inventoryCount + testedCount; var testedScheme = new PropScheme(); var props = new IProp[] { new Resource(testedScheme, inventoryCount) }; var realStore = CreateContainer(props); var testedResource = new Resource(testedScheme, testedCount); var propTransferStore = new PropTransferStore(realStore); // ACT propTransferStore.Add(testedResource); // ASSERT var factProps = propTransferStore.CalcActualItems(); factProps.Length.Should().Be(1); // В инвентаре только один стак ресурсов. factProps[0].Should().BeOfType <Resource>(); factProps[0].Scheme.Should().Be(testedScheme); ((Resource)factProps[0]).Count.Should().Be(expectedCount); }
protected override TextButton[] InitItems(IProp prop) { _prop = prop; var inventoryState = _serviceProvider.GetRequiredService <IInventoryState>(); inventoryState.SelectedProp = new PropViewModel(prop); var list = new List <TextButton>(); var useCommand = _serviceProvider.GetRequiredService <UseSelfCommand>(); var commandPool = _serviceProvider.GetRequiredService <ICommandPool>(); switch (prop) { case Equipment: InitItemsForEquipment(list, commandPool); break; case Resource: InitItemsForResource(list, useCommand, commandPool); break; default: Debug.Fail($"Unknown type {prop.GetType()} of the prop."); break; } return(list.ToArray()); }
protected override TextButton[] InitItems(IProp prop) { var menuButton = new TextButton(_menuTitle, _uiContentStorage.GetMenuItemTexture(), _uiContentStorage.GetMenuItemFont(), new Rectangle( MENU_MARGIN + _position.X, MENU_MARGIN + _position.Y + (0 * MENU_ITEM_HEIGHT), MENU_WIDTH, MENU_ITEM_HEIGHT)); menuButton.OnClick += (s, e) => { var transferCommand = _serviceProvider.GetRequiredService <PropTransferCommand>(); var commandPool = _serviceProvider.GetRequiredService <ICommandPool>(); var transferMachine = new PropTransferMachine(_inventoryStore, _containerStore); transferMachine.TransferProp(prop, _sourceStore, _targetStore); transferCommand.TransferMachine = transferMachine; commandPool.Push(transferCommand); IsCommandUsed = true; CloseMenu(); }; return(new[] { menuButton }); }
/// <summary> /// 更新显示的UI,Sale /// </summary> public void InitializeSale(int num) { // 只有可出售且数目>0的才会显示出来 if (num <= 0 || !UiStore.Props[ID].CanSale) { img.sprite = null; img.color = Color.clear; HasProp = false; Price.gameObject.SetActive(false); } else { IProp prop = UiStore.Props[ID]; if (prop == null) { Debug.LogError("数据库中没有这个道具"); return; } img.sprite = prop.GetIcon(); HasProp = true; img.color = Color.white; Price.gameObject.SetActive(true); Price.text = prop.SalePrice.ToString(); } }
public void Add_AddResourceToEmptyInventory_PropContainsThisResource() { // ARRANGE const int expectedCount = 1; var props = new IProp[0]; var realStore = CreateContainer(props); var testedScheme = new PropScheme(); var testedResource = new Resource(testedScheme, expectedCount); var propTransferStore = new PropTransferStore(realStore); // ACT propTransferStore.Add(testedResource); // ASSERT var factProps = propTransferStore.CalcActualItems(); factProps[0].Should().BeOfType <Resource>(); factProps[0].Scheme.Should().Be(testedScheme); ((Resource)factProps[0]).Count.Should().Be(expectedCount); }
public InventoryUiItem(IconButton control, IProp prop, int uiIndex, Rectangle uiRect) { UiIndex = uiIndex; UiRect = uiRect; Prop = prop ?? throw new ArgumentNullException(nameof(prop)); Control = control ?? throw new ArgumentNullException(nameof(control)); }
public void Remove_RemoveResourceFromInventoryWithThisResource_PropContains() { // ARRANGE const int inventoryCount = 1; const int expectedCount = 1; var testedScheme = new PropScheme(); var props = new IProp[] { new Resource(testedScheme, inventoryCount) }; var realStore = CreateContainer(props); var testedResource = new Resource(testedScheme, expectedCount); var propTransferStore = new PropTransferStore(realStore); // ACT propTransferStore.Remove(testedResource); // ASSERT var factProps = propTransferStore.CalcActualItems(); factProps.Should().BeEmpty(); }
public IProp <T> AddPropObjComp <T>(string propertyName, Action <T, T> doIfChanged = null, bool doAfterNotify = false, object extraInfo = null, T initialValue = default(T)) { IProp <T> prop = propBag.AddPropObjComp <T>(propertyName, doIfChanged, doAfterNotify, extraInfo, initialValue); RegisterDynProp(propertyName, default(T)); return(prop); }
//------------------------------------------------------------------------- void _onPropIpAddressChanged(IProp prop, object param) { //UiMbPlayerProfile ui_profile = UiMgr.Instance.getCurrentUi<UiMbPlayerProfile>(); //if (ui_profile != null) //{ // ui_profile.playerInfoChanged(); //} }
public IProp <T> AddPropObjCompNoValue <T>(string propertyName, Action <T, T> doIfChanged = null, bool doAfterNotify = false, object extraInfo = null) { IProp <T> prop = propBag.AddPropObjCompNoValue <T>(propertyName, doIfChanged, doAfterNotify, extraInfo); // TODO: This is not quite right. RegisterDynProp(propertyName, default(T)); return(prop); }
public IProp <T> AddPropNoStore <T>(string propertyName, Action <T, T> doIfChanged, bool doAfterNotify = false, Func <T, T, bool> comparer = null, object extraInfo = null) { IProp <T> prop = propBag.AddPropNoStore <T>(propertyName, doIfChanged, doAfterNotify, comparer, extraInfo); // TODO: This is not quite right. RegisterDynProp(propertyName, default(T)); return(prop); }
private void CreatePropObject(Transform itemsParent, IProp prop) { var propItemViewModel = Instantiate(PropItemPrefab, itemsParent); propItemViewModel.Init(prop); propItemViewModel.Click += PropItemViewModel_Click; _propViewModels.Add(propItemViewModel); }
//------------------------------------------------------------------------- // AFK属性改变 void _onPropIsAFKChanged(IProp prop, object param) { // 广播玩家是否挂机消息 var ev = Publisher.genEvent <EvCellPlayerSetAFK>(); ev.is_afk = Def.mPropIsAFK.get(); ev.send(this); }
/// <summary> /// Конструктор с инициализацией параметров по интерфейсу /// </summary> /// <param name="prop">Интерфейс именованного свойства</param> public IPropImpl(IProp prop) { if (prop != null) { Name = prop.Name; Value = prop.Value; } }
public void UseProp(IProp usedProp) { var useData = usedProp.Scheme.Use; foreach (var rule in useData.CommonRules) { switch (rule.Direction) { case PersonRuleDirection.Positive: switch (rule.Type) { case ConsumeCommonRuleType.Satiety: RestoreStat(SurvivalStatType.Satiety, rule.Level); break; case ConsumeCommonRuleType.Thirst: RestoreStat(SurvivalStatType.Water, rule.Level); break; case ConsumeCommonRuleType.Health: RestoreStat(SurvivalStatType.Health, rule.Level); break; case ConsumeCommonRuleType.Undefined: default: throw new ArgumentOutOfRangeException($"Правило поглощения {rule.Type} не поддерживается."); } break; case PersonRuleDirection.Negative: switch (rule.Type) { case ConsumeCommonRuleType.Satiety: DecreaseStat(SurvivalStatType.Satiety, rule.Level); break; case ConsumeCommonRuleType.Thirst: DecreaseStat(SurvivalStatType.Water, rule.Level); break; case ConsumeCommonRuleType.Health: DecreaseStat(SurvivalStatType.Health, rule.Level); break; case ConsumeCommonRuleType.Undefined: default: throw new ArgumentOutOfRangeException($"Правило поглощения {rule.Type} не поддерживается."); } break; } } if (useData.Consumable) { ConsumeResource(usedProp); } }
//--------------------------------------------------------------------- internal void _addProp(string key, IProp prop) { mMapProp[key] = prop; }
}//.ctor public Value( IProp prop ) { Vt = Vtype.Prop; Ptr = prop; Str = null; Dta = new Vdata(); }//.ctor