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

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