Esempio n. 1
0
        public static Cost FromJsonToken(JToken token)
        {
            //IL_0001: Unknown result type (might be due to invalid IL or missing references)
            //IL_0007: Invalid comparison between Unknown and I4
            //IL_000f: Unknown result type (might be due to invalid IL or missing references)
            if ((int)token.get_Type() != 1)
            {
                Debug.LogWarning((object)("Malformed token : type Object expected, but " + token.get_Type() + " found"));
                return(null);
            }
            JObject val  = Extensions.Value <JObject>((IEnumerable <JToken>)token);
            JToken  val2 = default(JToken);

            if (!val.TryGetValue("type", ref val2))
            {
                Debug.LogWarning((object)"Malformed json: no 'type' property in object of class Cost");
                return(null);
            }
            string text = Extensions.Value <string>((IEnumerable <JToken>)val2);
            Cost   cost;

            switch (text)
            {
            case "ActionPointsCost":
                cost = new ActionPointsCost();
                break;

            case "DrainActionPointsCost":
                cost = new DrainActionPointsCost();
                break;

            case "ReservePointsCost":
                cost = new ReservePointsCost();
                break;

            case "DrainReservePointsCost":
                cost = new DrainReservePointsCost();
                break;

            case "ElementPointsCost":
                cost = new ElementPointsCost();
                break;

            case "DrainElementsPoints":
                cost = new DrainElementsPoints();
                break;

            default:
                Debug.LogWarning((object)("Unknown type: " + text));
                return(null);
            }
            cost.PopulateFromJson(val);
            return(cost);
        }
        public new static ActionPointsCost FromJsonToken(JToken token)
        {
            //IL_0001: Unknown result type (might be due to invalid IL or missing references)
            //IL_0007: Invalid comparison between Unknown and I4
            //IL_000f: Unknown result type (might be due to invalid IL or missing references)
            if ((int)token.get_Type() != 1)
            {
                Debug.LogWarning((object)("Malformed token : type Object expected, but " + token.get_Type() + " found"));
                return(null);
            }
            JObject          jsonObject       = Extensions.Value <JObject>((IEnumerable <JToken>)token);
            ActionPointsCost actionPointsCost = new ActionPointsCost();

            actionPointsCost.PopulateFromJson(jsonObject);
            return(actionPointsCost);
        }
Esempio n. 3
0
        public int?GetCost(DynamicValueContext context)
        {
            int?num = null;

            foreach (Cost cost in m_costs)
            {
                ActionPointsCost actionPointsCost = cost as ActionPointsCost;
                if (actionPointsCost != null)
                {
                    if (!num.HasValue)
                    {
                        num = 0;
                    }
                    actionPointsCost.value.GetValue(context, out int value);
                    num += value;
                }
            }
            return(num);
        }
        public static ActionPointsCost FromJsonProperty(JObject jsonObject, string propertyName, ActionPointsCost defaultValue = null)
        {
            //IL_0011: Unknown result type (might be due to invalid IL or missing references)
            //IL_0018: Invalid comparison between Unknown and I4
            JProperty val = jsonObject.Property(propertyName);

            if (val == null || (int)val.get_Value().get_Type() == 10)
            {
                return(defaultValue);
            }
            return(FromJsonToken(val.get_Value()));
        }