public void AddResource(ResourceTypeSO resType, int amount) { resourceAmountDic[resType] += amount; onResourceAmountChanged?.Invoke(resType, resourceAmountDic[resType]); TestLogResAmountDic(); }
public override void SetUp() { base.SetUp(); TileTypeSO sandTileSO = ScriptableObject.CreateInstance <TileTypeSO>(); sandTileSO.name = "sand"; sandTileSO.Cost = 1f; sandTileSO.Color = Color.red; sandTileSO.Range = 1f; sandTileSO.hideFlags = HideFlags.HideAndDontSave; ResourceTypeSO coal = ScriptableObject.CreateInstance <ResourceTypeSO>(); coal.MovementCost = 2; coal.WorkRequired = 1f; coal.PiecesPerWork = 2; ResourceTypeSO coalHard = ScriptableObject.CreateInstance <ResourceTypeSO>(); coalHard.MovementCost = 2; coalHard.WorkRequired = 4f; coalHard.PiecesPerWork = 2; ResourceTypeSO fake = ScriptableObject.CreateInstance <ResourceTypeSO>(); BlobsMemory.FromSOs(new IBlobableSO[] { sandTileSO, coal, coalHard, fake }); var ese = _currentWorld.CreateSystem <EndSimulationEntityCommandBufferSystem>(); Inject(ese, "_removeCmdBufferSystem"); }
public void AddResource(ResourceTypeSO resourceType, int amount) { _resourceAmountDictionary[resourceType] += amount; OnResourceAmountChanged?.Invoke(this, EventArgs.Empty); TestLogResourceAmountDictionary(); }
//更新对应的资源类数量 public void AddResource(ResourceTypeSO resourceType, int amount) { resourceAmountDictionary[resourceType] += amount; /* * 广播该事件,this 表示事件发送者 * 问号无条件运算符,判断OnResourceAmountChanged 事件是否为null,不为null将其触发 * Invoke 事件重复调用 */ OnResourceAmountChanged?.Invoke(this, EventArgs.Empty); }
public void AddResource(ResourceTypeSO resourceType, int amount) { resourceAmountDictionary[resourceType] += amount; //use ?.Invoke to check the field before it, and only going to run when its not null -> has listner /* * if(OnResourceAmountChanged != null) * { * OnResourceAmountChanged(this, EventArgs.Empty); * } */ OnResourceAmountChanged?.Invoke(this, EventArgs.Empty); //event handeler signature :: take obj center and an opitinal arg, we use EventArgs.Empty becuase we not want to send any extra info.. //TestLogResourceAmountDictionary(); }
public void AddResource(ResourceTypeSO resourceType, int amount) { if (resourceAmountDictionary[resourceType] >= 99) { Debug.Log(resourceType.nameString + " capacity is full"); } else { resourceAmountDictionary[resourceType] += amount; OnResourceAmountChanged?.Invoke(this, EventArgs.Empty); TestLogResourceAmountDictionary(); } }
private void Start() { foreach (var item in resTypeTrmDict) { Transform thisitemTrn = item.Value; ResourceTypeSO thisitemSO = item.Key; ResourceManager.Instance.onResourceAmountChanged += (x, y) => { if (thisitemSO == x) { thisitemTrn.Find("text").GetComponent <TextMeshProUGUI>().SetText($"{y}"); } }; } }
public override void SetUp() { base.SetUp(); ResourceTypeSO coal = ScriptableObject.CreateInstance <ResourceTypeSO>(); coal.MovementCost = 2; coal.WorkRequired = 1f; coal.PiecesPerWork = 2; coal.UnitSize = 1; BlobsMemory.FromSOs(new IBlobableSO[] { coal }); var ese = _currentWorld.CreateSystem <EndSimulationEntityCommandBufferSystem>(); Inject(ese, "_removeCmdBufferSystem"); }
public override void SetUp() { base.SetUp(); TileTypeSO SandTileSO = ScriptableObject.CreateInstance <TileTypeSO>(); SandTileSO.name = "sand"; SandTileSO.Cost = 1f; SandTileSO.Color = Color.red; SandTileSO.Range = 1f; SandTileSO.hideFlags = HideFlags.HideAndDontSave; ResourceTypeSO coal = ScriptableObject.CreateInstance <ResourceTypeSO>(); coal.MovementCost = 2; coal.UnitSize = 1f; BlobsMemory.FromSOs(new IBlobableSO[] { SandTileSO, coal }); var ese = _currentWorld.CreateSystem <EndSimulationEntityCommandBufferSystem>(); Inject(ese, "_removeCmdBufferSystem"); }
public int GetResourceAmount(ResourceTypeSO resourceType) { return(resourceAmountDictionary[resourceType]); }
public void addResource(ResourceTypeSO resourceType, int amount) { resourceAmountDictionary[resourceType] += amount; }
public int GetResource(ResourceTypeSO resourceType) { return(_resourceAmounts[resourceType]); }
private void AddResource(ResourceTypeSO resourceType, int amount) { ResourceManager.Instance.AddResource(resourceType, amount); }
public void AddResource(ResourceTypeSO resourceType, int amount) { _resourceAmounts[resourceType] += amount; onResourceAmountChanged?.Invoke(this, resourceType); }
public void SetResourceAmount(ResourceTypeSO resType, int value) { resourceAmountDic[resType] = value; onResourceAmountChanged?.Invoke(resType, value); }
public void AddResource(ResourceTypeSO resourceType, int amount) { resourceAmountDictionary[resourceType] += amount; // ? means if not null, so if object isnt null, then run (is null if no listerners to event) OnResourceAmountChanged?.Invoke(this, EventArgs.Empty); }
public int GetResourceAmount(ResourceTypeSO resource) => resourceAmoutDic[resource];
public void AddResource(ResourceTypeSO resourceType, int amount) { resourceAmountDictionary[resourceType] += amount; OnResourceAmountChanged?.Invoke(); TestLogResourceAmountDictionary(); }
public void AddResource(ResourceTypeSO resourceType, int amount) { resourceAmountDictionary[resourceType] += amount; TestLogResourceAmountDictionary(); }
private void Instance_onResourceAmountChanged(object sender, ResourceTypeSO e) { _resourceGUIText[e].SetText(ResourceManager.Instance.GetResource(e).ToString()); }
public void AddResource(ResourceTypeSO resourceType, int amount) { resourceAmoutDic[resourceType] += amount; OnResourceAmountChanged?.Invoke(this, EventArgs.Empty); }