Beispiel #1
0
    public void AddResource(ResourceTypeSO resType, int amount)
    {
        resourceAmountDic[resType] += amount;
        onResourceAmountChanged?.Invoke(resType, resourceAmountDic[resType]);

        TestLogResAmountDic();
    }
Beispiel #2
0
        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");
        }
Beispiel #3
0
    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);
    }
Beispiel #5
0
    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();
        }
    }
Beispiel #7
0
    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}");
                }
            };
        }
    }
Beispiel #8
0
        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");
        }
Beispiel #9
0
        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]);
 }
Beispiel #11
0
 public void addResource(ResourceTypeSO resourceType, int amount)
 {
     resourceAmountDictionary[resourceType] += amount;
 }
Beispiel #12
0
 public int GetResource(ResourceTypeSO resourceType)
 {
     return(_resourceAmounts[resourceType]);
 }
Beispiel #13
0
 private void AddResource(ResourceTypeSO resourceType, int amount)
 {
     ResourceManager.Instance.AddResource(resourceType, amount);
 }
Beispiel #14
0
 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);
 }
Beispiel #17
0
 public int GetResourceAmount(ResourceTypeSO resource) =>
 resourceAmoutDic[resource];
Beispiel #18
0
 public void AddResource(ResourceTypeSO resourceType, int amount)
 {
     resourceAmountDictionary[resourceType] += amount;
     OnResourceAmountChanged?.Invoke();
     TestLogResourceAmountDictionary();
 }
 public void AddResource(ResourceTypeSO resourceType, int amount)
 {
     resourceAmountDictionary[resourceType] += amount;
     TestLogResourceAmountDictionary();
 }
Beispiel #20
0
 private void Instance_onResourceAmountChanged(object sender, ResourceTypeSO e)
 {
     _resourceGUIText[e].SetText(ResourceManager.Instance.GetResource(e).ToString());
 }
Beispiel #21
0
 public void AddResource(ResourceTypeSO resourceType, int amount)
 {
     resourceAmoutDic[resourceType] += amount;
     OnResourceAmountChanged?.Invoke(this, EventArgs.Empty);
 }