示例#1
0
 public static void AddRecources(Dictionary <GlobalRecourceType, int> recourcesToAdd)
 {
     foreach (var kvp in recourcesToAdd)
     {
         recources[kvp.Key] += kvp.Value;
         RecourceChanged.Invoke(kvp.Key);
     }
     RecourcesChanged.Invoke();
 }
示例#2
0
    public static void SubstractRecources(Dictionary <GlobalRecourceType, int> recourcesToSubstract)
    {
        foreach (var kvp in recourcesToSubstract)
        {
            recources[kvp.Key] -= kvp.Value;
            RecourceChanged.Invoke(kvp.Key);
        }

        RecourcesChanged.Invoke();
    }
示例#3
0
    public static bool CanChangeAmount(GlobalRecourceType type, int amount)
    {
        if (recources[type] - amount < 0)
        {
            return(false);
        }

        recources[type] += amount;
        RecourceChanged.Invoke(type);
        RecourcesChanged.Invoke();
        return(true);
    }
示例#4
0
 public static void Initializtion(List <StaticRecource> addOnStart)
 {
     foreach (var item in Enum.GetValues(typeof(GlobalRecourceType)))
     {
         GlobalRecourceType type = (GlobalRecourceType)item;
         recources.Add(type, 0);
     }
     foreach (var res in addOnStart)
     {
         recources[res.Type] += res.Amount;
         RecourcesChanged.Invoke();
         RecourceChanged.Invoke(res.Type);
     }
 }
    void changeRecource(RecourceType type, int amount)
    {
        if (amount == 0)
        {
            return;
        }

        if (Recources.ContainsKey(type))
        {
            Recources[type] += amount;
        }
        else
        {
            Recources.Add(type, amount);
        }
        TotalAmountOfGoods += amount;
        RecourceChanged.Invoke(type, Recources[type], this);
        RecourcesChanged.Invoke(this);
    }