예제 #1
0
        /*public List<ResourceItem> GetEffects () {
         *  List<ResourceItem> result = new List<ResourceItem> ();
         *  foreach (ResourceItem r in playerData.resources) {
         *      if (r.count == 0)
         *          continue;
         *      ResourceData d = Services.data.ResInfo (r.id);
         *      if (d.tags != null && d.tags.Equals (GameDataManager.EFFECT))
         *          result.Add (r);
         *  }
         *  return result;
         * }*/

        public int MaxResourceValue(int id)
        {
            ResourceItem rd = null;

            switch (Services.data.tutorStep)
            {
            case 0:
                rd = playerData.tutorial0.max.Find(_m => _m.id == id);
                break;

            case 1:
                rd = playerData.tutorial1.max.Find(_m => _m.id == id);
                break;

            default:
                rd = playerData.maxValue.Find(_m => _m.id == id);
                break;
            }

            return(rd == null ? 0 : rd.count);
        }
예제 #2
0
        public void SubResource(int id, int count)
        {
            ResourceItem res = playerData.resources.Find(r => r.id == id);

            if (res == null)
            {
                res       = new ResourceItem();
                res.id    = id;
                res.count = 0;
                playerData.resources.Add(res);
            }
            if (res.count - count <= 0)
            {
                res.count = 0;
            }
            else
            {
                res.count -= count;
            }

            SaveResLocal(res);
            OnResourceUpdated?.Invoke(res.id, -count);
        }
예제 #3
0
        public void AddResource(int id, int count)
        {
            ResourceItem res = playerData.resources.Find(r => r.id == id);

            if (res == null)
            {
                res       = new ResourceItem();
                res.id    = id;
                res.count = 0;
                playerData.resources.Add(res);
            }

            int max = MaxResourceValue(id);

            if (res.count + count > max)
            {
                count = max - res.count;
            }

            res.count += count;

            SaveResLocal(res);
            OnResourceUpdated?.Invoke(res.id, count);
        }
예제 #4
0
 private void SaveResLocal(ResourceItem res)
 {
 }
예제 #5
0
        public int AvailableResource(int id)
        {
            ResourceItem r = playerData.resources.Find(_r => _r.id == id);

            return(r == null ? 0 : r.count);
        }