示例#1
0
    private void LoadScript()
    {
        ScriptParser scriptParser = new ScriptParser();

        scriptParser.Parse("Player/Player_InjuryTreatments", true);
        for (int i = 0; i < scriptParser.GetKeysCount(); i++)
        {
            Key key = scriptParser.GetKey(i);
            if (key.GetName() == "Treatment")
            {
                InjuryType      key2            = (InjuryType)Enum.Parse(typeof(InjuryType), key.GetVariable(0).SValue);
                InjuryTreatment injuryTreatment = new InjuryTreatment();
                string          svalue          = key.GetVariable(1).SValue;
                if (svalue != null)
                {
                    foreach (string text in svalue.Split(new char[]
                    {
                        ';'
                    }))
                    {
                        string[] array2 = text.Split(new char[]
                        {
                            '*'
                        });
                        ItemID item = (ItemID)Enum.Parse(typeof(ItemID), array2[0]);
                        injuryTreatment.AddItem(item, (array2.Length <= 1) ? 1 : int.Parse(array2[1]));
                    }
                }
                this.m_Treatments[(int)key2] = injuryTreatment;
            }
        }
    }
示例#2
0
    public InjuryTreatment GetTreatment(InjuryType type)
    {
        InjuryTreatment result = null;

        this.m_Treatments.TryGetValue((int)type, out result);
        return(result);
    }
示例#3
0
    public void TryHealInjury(Injury injury)
    {
        if (!this.CanHealInjury(injury))
        {
            return;
        }
        injury.GetSlot().SetInjury(null);
        this.m_Injuries.Remove(injury);
        InjuryTreatment treatment = this.GetTreatment(injury.GetInjuryType());

        DebugUtils.Assert(treatment != null, true);
        Dictionary <int, int> allItems = treatment.GetAllItems();

        using (Dictionary <int, int> .KeyCollection.Enumerator enumerator = allItems.Keys.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                ItemID itemID = (ItemID)enumerator.Current;
                InventoryBackpack.Get().RemoveItem(itemID, allItems[(int)itemID]);
            }
        }
        EventsManager.OnEvent(Enums.Event.HealWound, 1);
    }
示例#4
0
    public bool CanHealInjury(Injury injury)
    {
        if (injury == null)
        {
            return(false);
        }
        InjuryTreatment treatment = this.GetTreatment(injury.GetInjuryType());

        DebugUtils.Assert(treatment != null, true);
        Dictionary <int, int> allItems = treatment.GetAllItems();

        using (Dictionary <int, int> .KeyCollection.Enumerator enumerator = allItems.Keys.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                ItemID itemID = (ItemID)enumerator.Current;
                if (InventoryBackpack.Get().GetItemsCount(itemID) < allItems[(int)itemID])
                {
                    return(false);
                }
            }
        }
        return(true);
    }